Repaints Smooth-Sailing vs Jitter-Zone Indicator for Scalping For ThinkOrSwim

Repaints
Thank you for taking the time to create this indicator. I'm currently using the first version as it seems to work well for spotting divergences on the Renko chart. My question is if there is a way I could make the current version work for Renko as well. If there's a block of code I could remove or a simple alteration I could make (I'm not a skilled Thinkscripter by any stretch so the simpler the better), that would be very helpful as I would like to take full advantage of your latest innovations. Thanks again for all your work!
Thank you for your feedback - I was not aware of this issue with Renko charts. I will look into this.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

V8 is the latest version
More efficient code.
Code footprint - below 200 lines of instructions.

------------------------
V7 - First Code block below (on the top of this post)
V7 feaures-
* Added customizable cloud to indicate strong/weak trends zone.
* Vertical lines replace bubbles.
* Better default configuation.

Goal:
To help scalp choppy charts while avoiding jittery zones.
This indicator is inspired by the Directional Movement Index (DMI) and Volume Wave.
Arc Tangent is used to calculate the slope of the Directional Deltas.
Optionally combined with PPS.

Please read the top comment section in the code block before using.


UBomZSK.jpg

Code:
#-------------------------------------------------------------------------------------------------------
# Smooth_Sailing vs Jitter_Zone Indicator
# V 8.0
# Last update 09/02/2022 - Traderzen
#------------------------------------------------------------------------------------------------------

declare lower;

Input UseMTF = {"No", Default "Yes"};
Input MTF = AggregationPeriod.FIFTEEN_MIN;
Input VolumeSmoothing = { Default "Yes", "No"};
Input Slope = {Default "Incremental" , "Aggregate"};
Input Bar_Segment = { Default "HL", "OC" };
Input fast = 2; #Average Slope.
Input SuperSlow = 2; #Projection Curve Setting - Used for the divergence sensitivity.
Input ShowJitterZone = { Default "Yes", "No"};
Input ShowLabel = { default "Yes", "No"};  
Input ShowVerticalLine = {Default "yes", "No"};
Input ShowPPS = { Default "Yes", "No"};
Input Min_Theta_for_Mfactor = 25; # Buy/Short signal min avg angle.
Input CommonRate = .97125; #Sensitivity for geometric progression

def p_selected = if UseMTF == UseMTF."Yes" then MTF else getAggregationPeriod() ;

def p = if Slope == Slope."Incremental" then GetAggregationPeriod()
        else if p_selected < getAggregationPeriod() then getAggregationPeriod()
        else p_selected;

def mFactor = if UseMTF == UseMTF."Yes" and Slope == Slope."Incremental" then p_selected / getAggregationPeriod() else 1;

def SlopeF = if UseMTF == UseMTF."Yes" and Slope == Slope."Incremental" then (mFactor+fast) else 1;
def SlopeS = if UseMTF == UseMTF."Yes" and Slope == Slope."Incremental" then (mFactor+SuperSlow) else 1 ;

Def averageType = AverageType.wilders;
Def averageType2 = AverageType.Hull;

def hiDiff = IF Bar_Segment == Bar_segment."HL" then high(period=p) - high(period=p)[1] else  close(period=p) - close(period=p)[1];
def loDiff = If Bar_Segment == Bar_segment."HL" then low(period=p)[1] - low(period=p) else open(period=p)[1] - open(period=p);
def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM =  if loDiff > hiDiff and loDiff > 0 then loDiff else 0;
def ATR = MovingAverage(AverageType, TrueRange(high(period=p), close(period=p), low(period=p)), SlopeF);

Plot DIplus = 100 * MovingAverage(averageType, plusDM, SlopeF) / if bar_segment == bar_segment."HL" then ATR else ATR*.5;
Plot DIminus = 100 * MovingAverage(averageType, minusDM, SlopeF) / if bar_segment == bar_segment."HL" then ATR else ATR*.5;
plot DX = DIplus - DIminus;
Plot hz=0;

#-- Real deal Buy signal angle calculation for MTF using geomatric progression.
#-- For example: Do not trigger buy signal if then slope is less than 75 degrees for 1 min chart and 30 degrees for 30 min chart. 
def Theta = MIn_Theta_for_Mfactor*power(commonRate,Mfactor-1);

##-- Real deal scientific slope calculation using ArcTan formula.
def ATanP = (ATan(DX/SlopeF) * (180 / Double.Pi)); # MTF support

def v_1 = volume(period=p);
def v_2 = volume;

def w_1 = if ATanp > 0  and !(ATanP[1]> 0)then v_1
          else if ATanP < 0 and !(Atanp[1] < 0 ) then v_1
          else w_1[1] + v_1;

def w_2 = if ATanp > 0  and !(ATanP[1]> 0) then v_2
          else if ATanP < 0 and !(Atanp[1] < 0 ) then v_2
          else w_2[1] + v_2;

plot TDX;
Switch (VolumeSmoothing){
Case "No" :
    TDX = w_1 * if atanp>0 then 1 else -1;
Case "Yes" :
    TDX = w_2 * if atanp>0 then 1 else -1;
}

TDX.AssignValueColor(
    if ATanP >= ATanP[1] && ATanP > 0 and TDX >= TDX[1] then color.cyan
    else if ATanP <= ATanP[1]&& ATanP > 0 and TDX >= TDX[1] then color.light_green
    else if ATanP <= ATanP[1]&& ATanP < 0 and TDX <= TDX[1] then color.magenta
    else if ATanP >= ATanP[1]&& ATanP < 0 and TDX <= TDX[1] then color.Pink
    else Color.yellow
);
TDX.setLineWeight(1);
TDX.SetPaintingStrategy(PaintingStrategy.histogram);

def ATANPMA = MovingAverage(averageType2, ATanP,mFactor);
plot ATDX;
Switch (VolumeSmoothing){
Case "No" :
    ATDX = w_1 * if atanpma>0 then 1 else -1;
Case "Yes" :
    ATDX = w_2 * if atanpma>0 then 1 else -1;
}

Def JitterZone = if (ATanP>0 and ATanp[1]<0) or (ATanp<0 and ATanp[1]>0) then 1
                 else if (ATanPMA>0 and ATanpMA[1]<0) or (ATanpMA<0 and ATanpMA[1]>0) then 1
                 else 0;

ATDX.AssignValueColor(  if JitterZone then color.yellow
                        else if (tdx==atdx and tdX > 0) then color.uptick
                        else if (tdx==atdx and tdx<0) then color.downtick
                        else color.yellow
                    );

ATdx.setLineWeight(1);
ATdx.SetPaintingStrategy(PaintingStrategy.LiNE);

plot jz = if Jitterzone or (tdx!=atdx)  then atdx else double.nan;
jz.setpaintingstrategy(paintingStrategy.LINE_VS_Triangles);
jz.setlineweight(3);
jz.assignValueColor(color.yellow);

atdx.setHiding(ShowJitterZone);
jz.setHiding(ShowJitterZone);

addlabel(if showLabel == ShowLabel."yes" then yes else no, if JitterZone then "Jitter Zone" else "Smooth Sail", if JitterZone then color.yellow else if tdx==atdx and tdx>0 then color.uptick else if tdx == atdx and tdx<0 then color.downtick else color.White );

def zone = if (tdx==atdx and tdX > 0) then -5 else if (tdx==atdx and tdx < 0) then 5 else if (TDX != atdx) then 0 else double.nan;
plot ZoneLine = zone;
Zoneline.assignValuecolor(if JitterZone then Color.Yellow else if zoneline == -5 then color.uptick else if zoneline == 5 then color.downTICK else color.White);
zoneline.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);

HZ.AssignValueColor(color.gray);

def up = if (ShowPPS == ShowPPS."Yes") then PPS().BuySignal else double.nan;
def down = if (ShowPPS == ShowPPS."Yes") then PPS().SellSignal else double.nan;
def upArrow = if up then 0 else double.NaN;
def dnArrow = if down then 0 else double.NaN;

plot PPSup = upArrow;
Plot PPSdown = dnArrow;
PPSup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
PPSdown.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
PPSup.SetLineWeight(3);
PPSDown.SetLineWeight(3);
PPSUp.AssignValueColor(Color.UpTick);
PPSDown.AssignValueColor(Color.DownTick);

DIminus.hide();
DIplus.hide();
DX.hide();


# -- Buy / Sell Indicator -- #
def ATanP2 = (ATan(DX/Fast) * 180 / Double.Pi);
def ATANPMA_JZ = MovingAverage(averageType2, ATanP2,SuperSlow);

Def decision = if JitterZone == 0 and  ATANP > 0 and ATANP[1] > 0 and ATANP > ATANP[1] and !(ATanp <= Theta and atanp >= -Theta) then 1 #BUY
               else if JitterZone == 0 and  ATANPMA > 0 and ATANPMA[1] > 0 and ATANPMA > ATANPMA[1] and !(ATanp <= Theta and atanp >= -Theta) then 1 #BUY
               else if decision[1] == 1 and ATANP > ATANP[1] and !(ATanp <= Theta and atanp >= -Theta) then 5 #Buy More
               else if decision[1] == 1 and ATANPmA > ATANPMA[1] and !(ATanp <= Theta and atanp >= -Theta) then 5 #Buy More  
               else if ATANP < 0 and ATANP[1] >= 0 and (decision[1] == 1 or decision[1] == 5) then 2 #Sell
               else if ATANPMA < 0 and ATANPMA[1] >= 0 and (decision[1] == 1 or decision[1] == 5) then 2 #Sell
               else if JitterZone == 0 and ATANP <= 0 and ATANP[1] < 0 and ATANP < ATANP[1] and !(ATanp <= Theta and atanp >= -Theta) then 3  #Short
               else if JitterZone == 0 and ATANPMA <= 0 and ATANPMA[1] < 0 and ATANPMA < ATANPMA[1] and !(ATanp <= Theta and atanp >= -Theta) then 3 #Short
               else if decision[1] == 3 and ATANP < ATANP[1] and !(ATanp <= Theta and atanp >= -Theta) then 6 #Short More
               else if decision[1] == 3 and ATANPMA < ATANPMA[1] and !(ATanp <= Theta and atanp >= -Theta) then 6 #Short More  
               else if ATANP > 0 and ATANP[1] < 0 and (decision[1] == 3 or decision[1] == 6) then 4 #Cover
               else if ATANPMA > 0 and ATANPMA[1] < 0 and (decision[1] == 3 or decision[1] == 6) then 4 #Cover
               else decision[1] ;

Def entry = if  (!isNan(Decision) && (Decision != Decision[1]))  && (Decision == 1 or Decision == 3)  then close else entry[1];
def exit  = if  Decision != Decision[1]  && (Decision == 2 or Decision == 4) then close else exit[1];
def result = if Decision != Decision[1] && (decision == 2 or decision ==4) then
                        if decision == 2 then exit - entry
                        else entry - exit
             else result[1];

AddVerticalLine(ShowVerticalLine == ShowVerticalLine."Yes" and Decision == 1 and Decision != Decision[1],
                "Buy:" + AsDollars(close),
                Color.Green, Curve.SHORT_DASH);
AddVerticalLine(ShowVerticalLine == ShowVerticalLine."Yes" and Decision == 3 and Decision != Decision[1],
                "Short:"+AsDollars(close),
                Color.Light_ORANGE, Curve.SHORT_DASH);
AddVerticalLine(ShowVerticalLine == ShowVerticalLine."Yes" and Decision == 2 and Decision != Decision[1],
                "Sell:"+ AsDollars(close), Color.Red, Curve.Short_Dash);
AddVerticalLIne(ShowVerticalLine == ShowVerticalLine."Yes" and Decision == 4 and Decision !=Decision[1],
                "Cover:"+AsDollars(Close),Color.Light_green,Curve.Short_dash);

AddLabel( if  ShowLabel == ShowLabel."Yes" and (ATanpma <= 10 and atanpma >= -10) && !Jitterzone then yes else no , "Caution: Near JitterZone!", Color.yellow ); 
AddLabel( if  ShowLabel == ShowLabel."Yes" and JitterZone then yes else no ,  "Caution: Divergence!", Color.yellow ); 

AddLabel( if  ShowLabel == ShowLabel."Yes" and Decision != Decision[1] then yes else no,
          if decision == 1 or decision == 5 then "buy"
          else if decision == 2 then "sell ( " + result + " )"
          else if decision == 3 or decision == 6 then "short"
          else if decision == 4 then "Cover ( "  + result + " )"
          else "*",
          if decision == 1 or decision == 5 then color.uptick
          else if decision == 2 then color.downtick
          else if decision == 3 or decision == 6 then color.light_orange
          else if decision == 4 then color.light_green
          else color.white);

#Volume_Cloud
input showVolband = no;
input Daily_MovingAvgPeriod = 9;
input Band_Percent_of_DMA_P_Vol = 5;

def RefVol = If ShowVolBand then MovingAverage (3, Volume(period = AggregationPeriod.DAY) * (Band_percent_of_DMA_P_Vol/100), Daily_MovingAvgPeriod) else double.NaN;
AddCloud (refVol,-1*refvol, color.light_gray,color.dark_gray, yes);
# -- Happy Trading 9/2/2022 - Traderzen

V6 Features -

* Adjustable and more precise, less number of Buy/Sell or Short/Cover Signal Triggering based on Geometric progression formula.
* Better default settings.
* Misc. Cosmetic improvements and additional prompts.
* Entry and Exit prices and results of the suggested last trade.
* Best used on a 1 min chart with 15M / 30M setting. (prefer using two instances of 15m, 30m one below the other, if possible).



NxyrRPz.jpg


V6 Code ---
Code:
#-------------------------------------------------------------------------------------------------------
# Smooth_Sail
#-------------------------------------------------------------------------------------------------------
# Description: Smooth_Sailing vs Jitter_Zone indicator
# Scalping Indicator for smaller time frame trading.
#     *    Indicates directional smooth sailing and Jitterzone warning.
#     *    Indicates Momentum.
#     *    Jitterzone is indicated by the yellow divergent line and yellow dots at the base of the bars.
#     *    Cyan and Magenta histogram bars indicate aggressive in the direction move.
# V2 -
#    * MultiTimeFrame (MTF) Feature.
#    ** Imp: If the TimeFrame selected is less than the TimeFrame of the Chart then the TimeFrame of the Chart is used.
#    ** PPS uses the Chart's time Frame.
#    ** ArcTan uses the MTF angle based on the slope calculation selection.
# V3 -
#    VolumeSmoothing - If VolumeSmoothing is ON then Adds volume of the current bar to the total_volume in MTF calulcation.
#                      Else if VolumeSmoothing if OFF then Waits for the total volume to be updated based on the selected MTF TimeFrame.
#                      V4- Volumesmoothing auto applies for incremental scopes.
#  V4 -
#    * - Choose between High-Low or Open-Close for slope calculation
#    * - Choose between Incremental or Aggregate slope calculation for MTF
#        Incremental setting uses the adjusted average slope of the bars from current timeframe for the duration of MTF
#        Aggregate setting uses the slope of the bars from MTF timeframe
#        Volumesmooothing applies automatically for incremental slopes.
# V5 -
#     * BUY/Sell and Short/Cover Signals
#     * Defaults values set for most scalping scenarios.
#
# V6 -
#    * Adjustable Buy/Sell Signal Triggering based on Geometric progression formula.
#    * Misc. Cosmetic improvements and additional prompts.
#    * Entry and Exit prices and results of the suggested last trade.
#
#
#
# Observaations:
#    * Best suited on a 1 min chart with 15M and 30 min settings.
#    * Use two instances of different timeframes (say 15M and 30M) one below the other for trade decisions.
#    A PivotPoint in the JitterZone coinsiding with MACD crossover is a good sign of a possible reversal.
#    A long Jitterzone is a channel - generally followed by a breakout - Specially near Day VWAP.
#    A PivotPoint in the Smooth Sailing Zone is indicative of a possibly longer trend.
#------------------------------------------------------------------------------------------------------


declare lower;

Input UseMTF = {"No", Default "Yes"};
Input MTF = { "1M", "5M", Default "15M", "30M"};
Input VolumeSmoothing = { Default "Yes", "No"};
Input Slope = {Default "Incremental" , "Aggregate"};
Input Bar_Segment = {Default "HL", "OC" };
Input fast = 2; #Average Slope.
Input SuperSlow = 5; #Projection Curve Setting - Used for the divergence sensitivity.
Input ShowJitterZone = { Default "Yes", "No"};
Input ShowLabel = { default "Yes", "No"};
Input Showbubble = {Default "yes", "No"};
Input ShowPPS = { Default "Yes", "No"};
Input Max_Theta_for_Min_Mfactor = 70; # Buy/Short signal max angle.
Input CommonRate = .969; #Sensitivity for geometric progression

def p_selected = if UseMTF == UseMTF."Yes" and MTF == MTF."1M" then AggregationPeriod.Min
                else if UseMTF == UseMTF."Yes" and MTF == MTF."5M" then AggregationPeriod.Five_Min
                else if UseMTF == UseMTF."Yes" and MTF == MTF."15M" then AggregationPeriod.Fifteen_Min
                else if UseMTF == UseMTF."Yes" and MTF == MTF."30M" then AggregationPeriod.Thirty_Min
                else getAggregationPeriod() ;

def p = if Slope == Slope."Incremental" then GetAggregationPeriod()
        else if p_selected < getAggregationPeriod() then getAggregationPeriod()
        else p_selected;

def mFactor = if UseMTF == UseMTF."Yes" and Slope == Slope."Incremental" then p_selected / getAggregationPeriod() else 1;
def SlopeF = fast  + ( if UseMTF == UseMTF."Yes" and Slope == Slope."Incremental" then mFactor/fast else 0 );
def SlopeS = SuperSlow + ( if UseMTF == UseMTF."Yes" and Slope == Slope."Incremental" then mFactor/(SuperSlow) else 0 );

Def averageType = AverageType.wilders;
Def averageType2 = AverageType.Hull;

def hiDiff = IF Bar_Segment == Bar_segment."HL" then high(period=p) - high(period=p)[1] else  close(period=p) - close(period=p)[1];
def loDiff = If Bar_Segment == Bar_segment."HL" then low(period=p)[1] - low(period=p) else open(period=p)[1] - open(period=p);
def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM =  if loDiff > hiDiff and loDiff > 0 then loDiff else 0;
def ATR = MovingAverage(AverageType, TrueRange(high(period=p), close(period=p), low(period=p)), SlopeF);

Plot DIplus = 100 * MovingAverage(averageType, plusDM, SlopeF) / ATR;
Plot DIminus = 100 * MovingAverage(averageType, minusDM, SlopeF) / ATR;
plot DX = DIplus - DIminus;
Plot hz=0;

#-- Real deal Buy signal angle calculation for MTF using geomatric progression.
#-- For example: Do not trigger buy signal if then slope is less than 75 degrees for 1 min chart and 30 degrees for 30 min chart.
def Theta = Max_Theta_for_Min_Mfactor*power(commonRate,Mfactor-1);

##-- Real deal scientific slope calculation using ArcTan formula.
#def ATanP = (ATan(DX/fast) * 180 / Double.Pi);
def ATanP = (ATan(DX/SlopeF) * 180 / Double.Pi); # MTF support


def v_1 = volume(period=p);
def v_2 = volume;

#AddLabel(if showLabel == ShowLabel."yes" then yes else no,
#         "MFT=" + UseMTF + " TF=" + MTF + " Period=" + P/60000  + "M Bar=" + Bar_Segment + "Slp="
#         + if slope == slope."Incremental" then "Inc" else "Agg",      
#         color.white);

def w_1 = if ATanp > 0  and !(ATanP[1]> 0)
         then v_1
        else if ATanP < 0 and !(Atanp[1] < 0 )
         then v_1
        else w_1[1] + v_1;

def w_2 = if ATanp > 0  and !(ATanP[1]> 0)
         then v_2
        else if ATanP < 0 and !(Atanp[1] < 0 )
         then v_2
        else w_2[1] + v_2;


plot TDX;
Switch (VolumeSmoothing){
Case "No" :
    TDX = w_1 * if atanp>0 then 1 else -1;
Case "Yes" :
    TDX = w_2 * if atanp>0 then 1 else -1;
}

TDX.AssignValueColor(

    if ATanP >= ATanP[1] && ATanP > 0 and TDX >= TDX[1] then color.cyan
    else if ATanP <= ATanP[1]&& ATanP > 0 and TDX >= TDX[1] then color.green
    else if ATanP <= ATanP[1]&& ATanP < 0 and TDX <= TDX[1] then color.magenta
    else if ATanP >= ATanP[1]&& ATanP < 0 and TDX <= TDX[1] then color.pink
#    else if ATanP >= ATanP[1]&& ATanP > 0 then color.cyan
    else Color.yellow
);
TDX.setLineWeight(1);
TDX.SetPaintingStrategy(PaintingStrategy.histogram);

def ATANPMA = MovingAverage(averageType2, ATanP,mFactor);
#AddLabel(yes, "ATanPMA " + ATanPMA + "ATanPMA[1] " + ATanPMA[1], color.white);
plot ATDX;
Switch (VolumeSmoothing){
Case "No" :
    ATDX = w_1 * if atanpma>0 then 1 else -1;
Case "Yes" :
    ATDX = w_2 * if atanpma>0 then 1 else -1;
}


Def JitterZone = if (ATanP>0 and ATanp[1]<0) or (ATanp<0 and ATanp[1]>0) then 1
                 else if (ATanPMA>0 and ATanpMA[1]<0) or (ATanpMA<0 and ATanpMA[1]>0) then 1
                 else 0;


ATDX.AssignValueColor(  if JitterZone then color.yellow
                        else if (tdx==atdx and tdX > 0) then color.uptick
                        else if (tdx==atdx and tdx<0) then color.downtick
                        else color.White
                    );

ATdx.setLineWeight(1);
ATdx.SetPaintingStrategy(PaintingStrategy.LiNE);

atdx.setHiding(ShowJitterZone);

addlabel(if showLabel == ShowLabel."yes" then yes else no, if JitterZone then "Jitter Zone" else "Smooth Sail", if JitterZone then color.yellow else if tdx==atdx and tdx>0 then color.uptick else if tdx == atdx and tdx<0 then color.downtick else color.White );

def zone = if (tdx==atdx and tdX > 0) then -5 else if (tdx==atdx and tdx < 0) then 5 else if (TDX != atdx) then 0 else double.nan;
plot ZoneLine = zone;
Zoneline.assignValuecolor(if JitterZone then Color.Yellow else if zoneline == -5 then color.uptick else if zoneline == 5 then color.downTICK else color.White);
zoneline.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);

#hz.AssignValueColor(if JitterZone then Color.Yellow else if zoneline == -5 then color.uptick else if zoneline == 5 then color.downTICK else color.White);
HZ.AssignValueColor(color.gray);

def up = if (ShowPPS == ShowPPS."Yes") then PPS().BuySignal else double.nan;
def down = if (ShowPPS == ShowPPS."Yes") then PPS().SellSignal else double.nan;

def upArrow = if up then 0 else double.NaN;
def dnArrow = if down then 0 else double.NaN;

plot PPSup = upArrow;
Plot PPSdown = dnArrow;
PPSup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
PPSdown.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
PPSup.SetLineWeight(2);
PPSDown.SetLineWeight(2);
PPSUp.AssignValueColor(Color.UpTick);
PPSDown.AssignValueColor(Color.DownTick);

DIminus.hide();
DIplus.hide();
DX.hide();


#Addlabel(yes, atanp + " " + atanp[1] +  " " + atanpma +  " " + atanpma[1], color.white);

##############################
# -- Buy / Sell Indicator -- #
##############################
def ATanP2 = (ATan(DX/Fast) * 180 / Double.Pi);
def ATANPMA_JZ = MovingAverage(averageType2, ATanP2,SuperSlow);

Def decision = if JitterZone == 0 and  ATANP > 0 and ATANP[1] > 0 and ATANP > ATANP[1] and !(ATanp <= Theta and atanp >= -Theta) then 1 #BUY
               else if JitterZone == 0 and  ATANPMA > 0 and ATANPMA[1] > 0 and ATANPMA > ATANPMA[1] and !(ATanp <= Theta and atanp >= -Theta) then 1 #BUY
               else if decision[1] == 1 and ATANP > ATANP[1] and !(ATanp <= Theta and atanp >= -Theta) then 5 #Buy More
               else if decision[1] == 1 and ATANPmA > ATANPMA[1] and !(ATanp <= Theta and atanp >= -Theta) then 5 #Buy More
               else if ATANP < 0 and ATANP[1] >= 0 and (decision[1] == 1 or decision[1] == 5) then 2 #Sell
               else if ATANPMA < 0 and ATANPMA[1] >= 0 and (decision[1] == 1 or decision[1] == 5) then 2 #Sell
               else if JitterZone == 0 and ATANP <= 0 and ATANP[1] < 0 and ATANP < ATANP[1] and !(ATanp <= Theta and atanp >= -Theta) then 3  #Short
               else if JitterZone == 0 and ATANPMA <= 0 and ATANPMA[1] < 0 and ATANPMA < ATANPMA[1] and !(ATanp <= Theta and atanp >= -Theta) then 3 #Short
               else if decision[1] == 3 and ATANP < ATANP[1] and !(ATanp <= Theta and atanp >= -Theta) then 6 #Short More
               else if decision[1] == 3 and ATANPMA < ATANPMA[1] and !(ATanp <= Theta and atanp >= -Theta) then 6 #Short More
               else if ATANP > 0 and ATANP[1] < 0 and (decision[1] == 3 or decision[1] == 6) then 4 #Cover
               else if ATANPMA > 0 and ATANPMA[1] < 0 and (decision[1] == 3 or decision[1] == 6) then 4 #Cover
               else decision[1] ;

Def entry = if  (!isNan(Decision) && (Decision != Decision[1]))  && (Decision == 1 or Decision == 3)  then open else entry[1];
def exit  = if  Decision != Decision[1]  && (Decision == 2 or Decision == 4) then close else exit[1];
def result = if Decision != Decision[1] && (decision == 2 or decision ==4) then
                        if decision == 2 then exit - entry
                        else entry - exit
             else result[1];


AddChartBubble( Showbubble == ShowBubble."Yes" and Decision == 1 and Decision != Decision[1]
               , 0, open , Color.uptick,no );
AddChartBubble( Showbubble == ShowBubble."Yes" and Decision == 5 and Decision != Decision[1]
                , 0, "+" , Color.uptick,no );

AddChartBubble( Showbubble == ShowBubble."Yes" and Decision == 3 and Decision != Decision[1]
                , 0, open, color.LIGHT_ORANGE, no );
AddChartBubble( Showbubble == ShowBubble."Yes" and Decision == 6 and Decision != Decision[1]
               , 0, "+" , Color.LIGHT_ORANGE, no);

AddChartBubble( Showbubble == ShowBubble."Yes" and Decision == 2 and Decision != Decision[1], atanpma, Close , Color.downtick);
AddChartBubble( Showbubble == ShowBubble."Yes" and Decision == 4 and Decision != Decision[1], atanpma, close, color.Light_green);

AddChartBubble (Showbubble == ShowBubble."Yes" and ((ATanpma_JZ < 0 and atanpma_JZ[1]> 0) or (ATanpma_JZ[1] < 0 and atanpma_JZ>0 )), atanpma, "!", Color.yellow, no );

AddLabel( if  ShowLabel == ShowLabel."Yes" and (ATanpma <= 10 and atanpma >= -10) && !Jitterzone then yes else no , "Caution: Near JitterZone!", Color.yellow );
AddLabel( if  ShowLabel == ShowLabel."Yes" and JitterZone then yes else no ,  "Caution: Divergence!", Color.yellow );

AddLabel( if  ShowLabel == ShowLabel."Yes" and Decision != Decision[1] then yes else no,
          if decision == 1 or decision == 5 then "buy"
          else if decision == 2 then "sell ( " + result + " )"
          else if decision == 3 or decision == 6 then "short"
          else if decision == 4 then "Cover ( "  + result + " )"
          else "*",
          if decision == 1 or decision == 5 then color.uptick
          else if decision == 2 then color.downtick
          else if decision == 3 or decision == 6 then color.light_orange
          else if decision == 4 then color.light_green
          else color.white);

#addlabel(if showLabel == ShowLabel."Yes" then yes else no, "Entry " + entry + " Exit " + exit + " Result " + result, color.white);
#AddLabel(yes, "Mfactor " + mfactor + " CR " + commonRate  + " Theta " + theta , color.white);


---------------------------- OLD Versions -- V1 to V4 -----------

Code:
#-------------------------------------------------------------------------------------------------------
# Smooth_Sailing vs Jitter_Zone indicator
# Scalping Indicator for smaller time frame trading.
#     *    Indicates directional smooth sailing and Jitterzone warning.
#     *    Indicates Momentum.
#     *    Jitterzone is indicated by the yellow divergent line and yellow dots at the base of the bars.
#     *    Cyan and Magenta histogram bars indicate aggressive in the direction move.
# Observaations:
#    A PivotPoint in the JitterZone coinsiding with MACD crossover is a good sign of a possible reversal.
#    A long Jitterzone is a channel - generally followed by a breakout - Specially near Day VWAP.
#    A PivotPoint in the Smooth Sailing Zone is indicative of a possibly longer trend.
#------------------------------------------------------------------------------------------------------


declare lower;

Input fast = 2; #Average Slope.
Input SuperSlow = 5; #Projection Curve Setting - Used for the divergence sensitivity.

Input ShowJitterZone = { Default "Yes", "No"};
Input ShowLabel = { default "Yes", "No"};
Input ShowPPS = { Default "Yes", "No"};

Def averageType = AverageType.wilders;
Def averageType2 = AverageType.hull;
def hiDiff = high - high[1];
def loDiff = low[1] - low;

def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM =  if loDiff > hiDiff and loDiff > 0 then loDiff else 0;

def ATR = MovingAverage(AverageType, TrueRange(high, close, low), fast);
Plot "DI+" = 100 * MovingAverage(averageType, plusDM, fast) / ATR;
Plot "DI-" = 100 * MovingAverage(averageType, minusDM, fast) / ATR;

plot DX = "DI+" - "DI-";

Plot hz=0;

##-- Real deal scientific slope calculation using ArcTan formula.
def ATanP = (ATan(DX/fast) * 180 / Double.Pi);

def v = volume;

def w = if ATanp > 0  and !(ATanP[1]> 0)
        then v
        else if ATanP < 0 and !(Atanp[1] < 0 )
        then v
        else w[1] + v;

plot TDX = w * if atanp>0 then 1 else -1;

TDX.AssignValueColor(

    if ATanP >= ATanP[1] && ATanP > 0 then color.cyan
    else if ATanP < ATanP[1]&& ATanP > 0 and  ATanP < TDX[1] then color.green
    else if ATanP < ATanP[1]&& ATanP < 0 then color.magenta
    else if ATanP >= ATanP[1]&& ATanP < 0 and ATanP > TDX[1] then color.pink
    else if ATanP >= ATanP[1]&& ATanP > 0 then color.cyan
    else Color.white
);
TDX.setLineWeight(1);
TDX.SetPaintingStrategy(PaintingStrategy.histogram);

def ATANPMA = MovingAverage(averageType2, ATanP, Superslow);
plot ATDX =  W * if ATANPMA > 0 then 1 else -1  ;

Def JitterZone = if (ATanP>0 and ATanp[1]<0) or (ATanp<0 and ATanp[1]>0) then 1
                 else if (ATanPMA>0 and ATanpMA[1]<0) or (ATanpMA<0 and ATanpMA[1]>0) then 1
                 else 0;

ATDX.AssignValueColor(  if JitterZone then color.yellow
                        else if (tdx==atdx and tdX > 0) then color.uptick
                        else if (tdx==atdx and tdx<0) then color.downtick
                        else color.White
                    );

ATdx.setLineWeight(1);
ATdx.SetPaintingStrategy(PaintingStrategy.LiNE_vs_Triangles);

atdx.setHiding(ShowJitterZone);
addlabel(if showLabel == ShowLabel."yes" then yes else no, if JitterZone then "Jitter Zone" else "Smooth Sail", if JitterZone then color.yellow else if tdx==atdx and tdx>0 then color.uptick else if tdx == atdx and tdx<0 then color.downtick else color.White );

def zone = if (tdx==atdx and tdX > 0) then -5 else if (tdx==atdx and tdx < 0) then 5 else if (TDX != atdx) then 0 else double.nan;
plot ZoneLine = zone;
Zoneline.assignValuecolor(if JitterZone then Color.Yellow else if zoneline == -5 then color.uptick else if zoneline == 5 then color.downTICK else color.White);
zoneline.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);

#hz.AssignValueColor(if JitterZone then Color.Yellow else if zoneline == -5 then color.uptick else if zoneline == 5 then color.downTICK else color.White);
HZ.AssignValueColor(color.gray);

def up = if (ShowPPS == ShowPPS."Yes") then PPS().BuySignal else double.nan;
def down = if (ShowPPS == ShowPPS."Yes") then PPS().SellSignal else double.nan;

def upArrow = if up then 0 else double.NaN;
def dnArrow = if down then 0 else double.NaN;

plot PPSup = upArrow;
Plot PPSdown = dnArrow;
PPSup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
PPSdown.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
PPSup.SetLineWeight(2);
PPSDown.SetLineWeight(2);
PPSUp.AssignValueColor(Color.UpTick);
PPSDown.AssignValueColor(Color.DownTick);

"DI-".hide();
"DI+".hide();
DX.hide();




sI6x1DN.png


clJCqBp.png



V2 -- with Multi-Time-Frame Support

Code:
#-------------------------------------------------------------------------------------------------------
# Smooth_Sailing vs Jitter_Zone indicator
# Scalping Indicator for smaller time frame trading.
#     *    Indicates directional smooth sailing and Jitterzone warning.
#     *    Indicates Momentum.
#     *    Jitterzone is indicated by the yellow divergent line and yellow dots at the base of the bars.
#     *    Cyan and Magenta histogram bars indicate aggressive in the direction move.
# V2 -
#    * MultiTimeFrame Feature.
#    ** Imp: If the TimeFrame selected is less than the TimeFrame of the Chart then the TimeFrame of the Chart is used.
#    ** PPS uses the Chart's time Frame.
#    ** ArcTan uses the MTF angle
# Observaations:
#    A PivotPoint in the JitterZone coinsiding with MACD crossover is a good sign of a possible reversal.
#    A long Jitterzone is a channel - generally followed by a breakout - Specially near Day VWAP.
#    A PivotPoint in the Smooth Sailing Zone is indicative of a possibly longer trend.
#------------------------------------------------------------------------------------------------------


declare lower;

Input fast = 2; #Average Slope.
Input SuperSlow = 5; #Projection Curve Setting - Used for the divergence sensitivity.

Input ShowJitterZone = { Default "Yes", "No"};
Input ShowLabel = { default "Yes", "No"};
Input ShowPPS = { Default "Yes", "No"};
Input UseMTF = {Default "No", "Yes"};
Input MTF = {Default "1_Min", "5_Min", "15_Min", "30_Min"};

def p_selected = if UseMTF == UseMTF."Yes" and MTF == MTF."1_Min" then AggregationPeriod.Min
                else if UseMTF == UseMTF."Yes" and MTF == MTF."5_Min" then AggregationPeriod.Five_Min
                else if UseMTF == UseMTF."Yes" and MTF == MTF."15_Min" then AggregationPeriod.Fifteen_Min
                else if UseMTF == UseMTF."Yes" and MTF == MTF."30_Min" then AggregationPeriod.Thirty_Min
                else getAggregationPeriod() ;

def p = if p_selected < getAggregationPeriod() then getAggregationPeriod() else p_selected;

Def averageType = AverageType.wilders;
Def averageType2 = AverageType.hull;
def hiDiff = high(period=p) - high(period=p)[1];
def loDiff = low(period=p)[1] - low(period=p);

def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM =  if loDiff > hiDiff and loDiff > 0 then loDiff else 0;

def ATR = MovingAverage(AverageType, TrueRange(high(period=p), close(period=p), low(period=p)), fast);
Plot "DI+" = 100 * MovingAverage(averageType, plusDM, fast) / ATR;
Plot "DI-" = 100 * MovingAverage(averageType, minusDM, fast) / ATR;

plot DX = "DI+" - "DI-";

Plot hz=0;

##-- Real deal scientific slope calculation using ArcTan formula.
def ATanP = (ATan(DX/fast) * 180 / Double.Pi);

def v  = volume(period=p);

AddLabel(if showLabel == ShowLabel."yes" then yes else no, "UseMFT= " + UseMTF + ", MTF= " + MTF + ", Period= " + P , color.white);

def w = if ATanp > 0  and !(ATanP[1]> 0)
        then v
        else if ATanP < 0 and !(Atanp[1] < 0 )
        then v
        else w[1] + v;

plot TDX = w * if atanp>0 then 1 else -1;

TDX.AssignValueColor(

    if ATanP >= ATanP[1] && ATanP > 0 then color.cyan
    else if ATanP < ATanP[1]&& ATanP > 0 and  ATanP < TDX[1] then color.green
    else if ATanP < ATanP[1]&& ATanP < 0 then color.magenta
    else if ATanP >= ATanP[1]&& ATanP < 0 and ATanP > TDX[1] then color.pink
    else if ATanP >= ATanP[1]&& ATanP > 0 then color.cyan
    else Color.white
);
TDX.setLineWeight(1);
TDX.SetPaintingStrategy(PaintingStrategy.histogram);

def ATANPMA = MovingAverage(averageType2, ATanP, Superslow);
plot ATDX =  W * if ATANPMA > 0 then 1 else -1  ;

Def JitterZone = if (ATanP>0 and ATanp[1]<0) or (ATanp<0 and ATanp[1]>0) then 1
                 else if (ATanPMA>0 and ATanpMA[1]<0) or (ATanpMA<0 and ATanpMA[1]>0) then 1
                 else 0;

ATDX.AssignValueColor(  if JitterZone then color.yellow
                        else if (tdx==atdx and tdX > 0) then color.uptick
                        else if (tdx==atdx and tdx<0) then color.downtick
                        else color.White
                    );

ATdx.setLineWeight(1);
ATdx.SetPaintingStrategy(PaintingStrategy.LiNE_vs_Triangles);

atdx.setHiding(ShowJitterZone);
addlabel(if showLabel == ShowLabel."yes" then yes else no, if JitterZone then "Jitter Zone" else "Smooth Sail", if JitterZone then color.yellow else if tdx==atdx and tdx>0 then color.uptick else if tdx == atdx and tdx<0 then color.downtick else color.White );

def zone = if (tdx==atdx and tdX > 0) then -5 else if (tdx==atdx and tdx < 0) then 5 else if (TDX != atdx) then 0 else double.nan;
plot ZoneLine = zone;
Zoneline.assignValuecolor(if JitterZone then Color.Yellow else if zoneline == -5 then color.uptick else if zoneline == 5 then color.downTICK else color.White);
zoneline.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);

#hz.AssignValueColor(if JitterZone then Color.Yellow else if zoneline == -5 then color.uptick else if zoneline == 5 then color.downTICK else color.White);
HZ.AssignValueColor(color.gray);

def up = if (ShowPPS == ShowPPS."Yes") then PPS().BuySignal else double.nan;
def down = if (ShowPPS == ShowPPS."Yes") then PPS().SellSignal else double.nan;

def upArrow = if up then 0 else double.NaN;
def dnArrow = if down then 0 else double.NaN;

plot PPSup = upArrow;
Plot PPSdown = dnArrow;
PPSup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
PPSdown.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
PPSup.SetLineWeight(2);
PPSDown.SetLineWeight(2);
PPSUp.AssignValueColor(Color.UpTick);
PPSDown.AssignValueColor(Color.DownTick);

"DI-".hide();
"DI+".hide();
DX.hide();
3MvSt2k.png

V3 - Volume Smoothing for Multi Time Frame Histograms.

Code:
#-------------------------------------------------------------------------------------------------------
# Smooth_Sailing vs Jitter_Zone indicator
# Scalping Indicator for smaller time frame trading.
#     *    Indicates directional smooth sailing and Jitterzone warning.
#     *    Indicates Momentum.
#     *    Jitterzone is indicated by the yellow divergent line and yellow dots at the base of the bars.
#     *    Cyan and Magenta histogram bars indicate aggressive in the direction move.
# V2 -
#    * MultiTimeFrame Feature.
#    ** Imp: If the TimeFrame selected is less than the TimeFrame of the Chart then the TimeFrame of the Chart is used.
#    ** PPS uses the Chart's time Frame.
#    ** ArcTan uses the MTF angle
# V3 -
#    VolumeSmoothing - If VolumeSmoothing is ON then Adds volume of the current bar to the total_volume in MTF calulcation.
#                      Else if VolumeSmoothing if OFF then Waits for the total volume to be updated based on the selected MTF TimeFrame.
# Observaations:
#    A PivotPoint in the JitterZone coinsiding with MACD crossover is a good sign of a possible reversal.
#    A long Jitterzone is a channel - generally followed by a breakout - Specially near Day VWAP.
#    A PivotPoint in the Smooth Sailing Zone is indicative of a possibly longer trend.
#------------------------------------------------------------------------------------------------------


declare lower;

Input fast = 2; #Average Slope.
Input SuperSlow = 5; #Projection Curve Setting - Used for the divergence sensitivity.

Input ShowJitterZone = { Default "Yes", "No"};
Input ShowLabel = { default "Yes", "No"};
Input ShowPPS = { Default "Yes", "No"};
Input UseMTF = {Default "No", "Yes"};
Input MTF = {Default "1_Min", "5_Min", "15_Min", "30_Min"};
Input VolumeSmoothing = { "Yes", default "No"};


def p_selected = if UseMTF == UseMTF."Yes" and MTF == MTF."1_Min" then AggregationPeriod.Min
                else if UseMTF == UseMTF."Yes" and MTF == MTF."5_Min" then AggregationPeriod.Five_Min
                else if UseMTF == UseMTF."Yes" and MTF == MTF."15_Min" then AggregationPeriod.Fifteen_Min
                else if UseMTF == UseMTF."Yes" and MTF == MTF."30_Min" then AggregationPeriod.Thirty_Min
                else getAggregationPeriod() ;

def p = if p_selected < getAggregationPeriod() then getAggregationPeriod() else p_selected;

Def averageType = AverageType.wilders;
Def averageType2 = AverageType.hull;
def hiDiff = high(period=p) - high(period=p)[1];
def loDiff = low(period=p)[1] - low(period=p);
#def hiDiff = close(period=p) - close(period=p)[1];
#def loDiff = open(period=p)[1] - open(period=p);


def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM =  if loDiff > hiDiff and loDiff > 0 then loDiff else 0;

def ATR = MovingAverage(AverageType, TrueRange(high(period=p), close(period=p), low(period=p)), fast);
Plot "DI+" = 100 * MovingAverage(averageType, plusDM, fast) / ATR;
Plot "DI-" = 100 * MovingAverage(averageType, minusDM, fast) / ATR;

plot DX = "DI+" - "DI-";

Plot hz=0;

##-- Real deal scientific slope calculation using ArcTan formula.
def ATanP = (ATan(DX/fast) * 180 / Double.Pi);

def v_1 = volume(period=p);
def v_2 = volume;

AddLabel(if showLabel == ShowLabel."yes" then yes else no, "UseMFT= " + UseMTF + ", MTF= " + MTF + ", Period= " + P/60000  + " Min", color.white);
AddLabel(if showLabel == ShowLabel."yes" then yes else no, "VolumeSmoothing " + VolumeSmoothing, color.white);


def w_1 = if ATanp > 0  and !(ATanP[1]> 0)
         then v_1
        else if ATanP < 0 and !(Atanp[1] < 0 )
         then v_1
        else w_1[1] + v_1;

def w_2 = if ATanp > 0  and !(ATanP[1]> 0)
         then v_2
        else if ATanP < 0 and !(Atanp[1] < 0 )
         then v_2
        else w_2[1] + v_2;

plot TDX;
Switch (VolumeSmoothing){
Case "No" :
    TDX = w_1 * if atanp>0 then 1 else -1;
Case "Yes" :
    TDX = w_2 * if atanp>0 then 1 else -1;
}

TDX.AssignValueColor(

    if ATanP >= ATanP[1] && ATanP > 0 then color.cyan
    else if ATanP < ATanP[1]&& ATanP > 0 and  ATanP < TDX[1] then color.green
    else if ATanP < ATanP[1]&& ATanP < 0 then color.magenta
    else if ATanP >= ATanP[1]&& ATanP < 0 and ATanP > TDX[1] then color.pink
    else if ATanP >= ATanP[1]&& ATanP > 0 then color.cyan
    else Color.white
);
TDX.setLineWeight(1);
TDX.SetPaintingStrategy(PaintingStrategy.histogram);

def ATANPMA = MovingAverage(averageType2, ATanP, Superslow);
plot ATDX;
Switch (VolumeSmoothing){
Case "No" :
    ATDX = w_1 * if atanpma>0 then 1 else -1;
Case "Yes" :
    ATDX = w_2 * if atanpma>0 then 1 else -1;
}


Def JitterZone = if (ATanP>0 and ATanp[1]<0) or (ATanp<0 and ATanp[1]>0) then 1
                 else if (ATanPMA>0 and ATanpMA[1]<0) or (ATanpMA<0 and ATanpMA[1]>0) then 1
                 else 0;

ATDX.AssignValueColor(  if JitterZone then color.yellow
                        else if (tdx==atdx and tdX > 0) then color.uptick
                        else if (tdx==atdx and tdx<0) then color.downtick
                        else color.White
                    );

ATdx.setLineWeight(1);
ATdx.SetPaintingStrategy(PaintingStrategy.LiNE_vs_Triangles);

atdx.setHiding(ShowJitterZone);
addlabel(if showLabel == ShowLabel."yes" then yes else no, if JitterZone then "Jitter Zone" else "Smooth Sail", if JitterZone then color.yellow else if tdx==atdx and tdx>0 then color.uptick else if tdx == atdx and tdx<0 then color.downtick else color.White );

def zone = if (tdx==atdx and tdX > 0) then -5 else if (tdx==atdx and tdx < 0) then 5 else if (TDX != atdx) then 0 else double.nan;
plot ZoneLine = zone;
Zoneline.assignValuecolor(if JitterZone then Color.Yellow else if zoneline == -5 then color.uptick else if zoneline == 5 then color.downTICK else color.White);
zoneline.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);

#hz.AssignValueColor(if JitterZone then Color.Yellow else if zoneline == -5 then color.uptick else if zoneline == 5 then color.downTICK else color.White);
HZ.AssignValueColor(color.gray);

def up = if (ShowPPS == ShowPPS."Yes") then PPS().BuySignal else double.nan;
def down = if (ShowPPS == ShowPPS."Yes") then PPS().SellSignal else double.nan;

def upArrow = if up then 0 else double.NaN;
def dnArrow = if down then 0 else double.NaN;

plot PPSup = upArrow;
Plot PPSdown = dnArrow;
PPSup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
PPSdown.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
PPSup.SetLineWeight(2);
PPSDown.SetLineWeight(2);
PPSUp.AssignValueColor(Color.UpTick);
PPSDown.AssignValueColor(Color.DownTick);

"DI-".hide();
"DI+".hide();
DX.hide();

V4 is now available -
Recommended settings -
1) On the 1 Min chart choose MTF = 5_Min for higher sensitivity [quick exits] OR MTF=15_Min to stay in the trade longer.

2) Use Bar_Segment = OpenClose for very choppy stocks to further adjust sensitivity.

ShiCNYU.jpg

#-------------------------------------------------------------------------------------------------------
# Smooth_Sailing vs Jitter_Zone indicator
# Scalping Indicator for smaller time frame trading.
# * Indicates directional smooth sailing and Jitterzone warning.
# * Indicates Momentum.
# * Jitterzone is indicated by the yellow divergent line and yellow dots at the base of the bars.
# * Cyan and Magenta histogram bars indicate aggressive in the direction move.
# V2 -
# * MultiTimeFrame (MTF) Feature.
# ** Imp: If the TimeFrame selected is less than the TimeFrame of the Chart then the TimeFrame of the Chart is used.
# ** PPS uses the Chart's time Frame.
# ** ArcTan uses the MTF angle based on the slope calculation selection.
# V3 -
# VolumeSmoothing - If VolumeSmoothing is ON then Adds volume of the current bar to the total_volume in MTF calulcation.
# Else if VolumeSmoothing if OFF then Waits for the total volume to be updated based on the selected MTF TimeFrame.
# V4- Volumesmoothing auto applies for incremental scopes.
# V4 -
# * - Choose between High-Low or Open-Close for slope calculation
# * - Choose between Incremental or Aggregate slope calculation for MTF
# Incremental setting uses the adjusted average slope of the bars from current timeframe for the duration of MTF
# Aggregate setting uses the slope of the bars from MTF timeframe
# Volumesmooothing applies automatically for incremental slopes.
#
# Observaations:
# A PivotPoint in the JitterZone coinsiding with MACD crossover is a good sign of a possible reversal.
# A long Jitterzone is a channel - generally followed by a breakout - Specially near Day VWAP.
# A PivotPoint in the Smooth Sailing Zone is indicative of a possibly longer trend.
#------------------------------------------------------------------------------------------------------

Code:
#-------------------------------------------------------------------------------------------------------
# Smooth_Sailing vs Jitter_Zone indicator
# Scalping Indicator for smaller time frame trading.
#     *    Indicates directional smooth sailing and Jitterzone warning.
#     *    Indicates Momentum.
#     *    Jitterzone is indicated by the yellow divergent line and yellow dots at the base of the bars.
#     *    Cyan and Magenta histogram bars indicate aggressive in the direction move.
# V2 -
#    * MultiTimeFrame (MTF) Feature.
#    ** Imp: If the TimeFrame selected is less than the TimeFrame of the Chart then the TimeFrame of the Chart is used.
#    ** PPS uses the Chart's time Frame.
#    ** ArcTan uses the MTF angle based on the slope calculation selection.
# V3 -
#    VolumeSmoothing - If VolumeSmoothing is ON then Adds volume of the current bar to the total_volume in MTF calulcation.
#                      Else if VolumeSmoothing if OFF then Waits for the total volume to be updated based on the selected MTF TimeFrame.
#                      V4- Volumesmoothing auto applies for incremental scopes.
#  V4 -
#    * - Choose between High-Low or Open-Close for slope calculation
#    * - Choose between Incremental or Aggregate slope calculation for MTF
#        Incremental setting uses the adjusted average slope of the bars from current timeframe for the duration of MTF
#        Aggregate setting uses the slope of the bars from MTF timeframe
#        Volumesmooothing applies automatically for incremental slopes.
#
# Observaations:
#    A PivotPoint in the JitterZone coinsiding with MACD crossover is a good sign of a possible reversal.
#    A long Jitterzone is a channel - generally followed by a breakout - Specially near Day VWAP.
#    A PivotPoint in the Smooth Sailing Zone is indicative of a possibly longer trend.
#------------------------------------------------------------------------------------------------------


declare lower;

Input fast = 2; #Average Slope.
Input SuperSlow = 5; #Projection Curve Setting - Used for the divergence sensitivity.

Input ShowJitterZone = { Default "Yes", "No"};
Input ShowLabel = { default "Yes", "No"};
Input ShowPPS = { Default "Yes", "No"};
Input UseMTF = {Default "No", "Yes"};
Input MTF = {Default "1_Min", "5_Min", "15_Min", "30_Min"};
Input VolumeSmoothing = { "Yes", default "No"};
Input Slope = {Default "Incremental" , "Aggregate"};
Input Bar_Segment = {Default "HiLo", "OpenClose" };

def p_selected = if UseMTF == UseMTF."Yes" and MTF == MTF."1_Min" then AggregationPeriod.Min
                else if UseMTF == UseMTF."Yes" and MTF == MTF."5_Min" then AggregationPeriod.Five_Min
                else if UseMTF == UseMTF."Yes" and MTF == MTF."15_Min" then AggregationPeriod.Fifteen_Min
                else if UseMTF == UseMTF."Yes" and MTF == MTF."30_Min" then AggregationPeriod.Thirty_Min
                else getAggregationPeriod() ;

def p = if Slope == Slope."Incremental" then GetAggregationPeriod()
        else if p_selected < getAggregationPeriod() then getAggregationPeriod()
        else p_selected;

def mFactor = if UseMTF == UseMTF."Yes" and Slope == Slope."Incremental" then p_selected / getAggregationPeriod() else 1;

def SlopeF = fast  + ( if UseMTF == UseMTF."Yes" and Slope == Slope."Incremental" then mFactor/fast else 0 );
def SlopeS = SuperSlow + ( if UseMTF == UseMTF."Yes" and Slope == Slope."Incremental" then mFactor*(fast/SuperSlow) else 0 );

Def averageType = AverageType.wilders;
Def averageType2 = AverageType.hull;
def hiDiff = IF Bar_Segment == Bar_segment."HiLo" then high(period=p) - high(period=p)[1] else  close(period=p) - close(period=p)[1];
def loDiff = If Bar_Segment == Bar_segment."HiLo" then low(period=p)[1] - low(period=p) else open(period=p)[1] - open(period=p);
#def hiDiff = close(period=p) - close(period=p)[1];
#def loDiff = open(period=p)[1] - open(period=p);


def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM =  if loDiff > hiDiff and loDiff > 0 then loDiff else 0;

def ATR = MovingAverage(AverageType, TrueRange(high(period=p), close(period=p), low(period=p)), SlopeF);
Plot "DI+" = 100 * MovingAverage(averageType, plusDM, SlopeF) / ATR;
Plot "DI-" = 100 * MovingAverage(averageType, minusDM, SlopeF) / ATR;

plot DX = "DI+" - "DI-";

Plot hz=0;

##-- Real deal scientific slope calculation using ArcTan formula.
def ATanP = (ATan(DX/fast) * 180 / Double.Pi);

def v_1 = volume(period=p);
def v_2 = volume;

AddLabel(if showLabel == ShowLabel."yes" then yes else no, "UseMFT= " + UseMTF + ", MTF= " + MTF + ", Period= " + P/60000  + " Min", color.white);
#AddLabel(if showLabel == ShowLabel."yes" then yes else no, "VolumeSmoothing " + VolumeSmoothing, color.white);


def w_1 = if ATanp > 0  and !(ATanP[1]> 0)
         then v_1
        else if ATanP < 0 and !(Atanp[1] < 0 )
         then v_1
        else w_1[1] + v_1;

def w_2 = if ATanp > 0  and !(ATanP[1]> 0)
         then v_2
        else if ATanP < 0 and !(Atanp[1] < 0 )
         then v_2
        else w_2[1] + v_2;


plot TDX;
Switch (VolumeSmoothing){
Case "No" :
    TDX = w_1 * if atanp>0 then 1 else -1;
Case "Yes" :
    TDX = w_2 * if atanp>0 then 1 else -1;
}

TDX.AssignValueColor(

    if ATanP >= ATanP[1] && ATanP > 0 then color.cyan
    else if ATanP < ATanP[1]&& ATanP > 0 and  ATanP < TDX[1] then color.green
    else if ATanP < ATanP[1]&& ATanP < 0 then color.magenta
    else if ATanP >= ATanP[1]&& ATanP < 0 and ATanP > TDX[1] then color.pink
    else if ATanP >= ATanP[1]&& ATanP > 0 then color.cyan
    else Color.white
);
TDX.setLineWeight(1);
TDX.SetPaintingStrategy(PaintingStrategy.histogram);

def ATANPMA = MovingAverage(averageType2, ATanP, If UseMTF == UseMTF."Yes" then 3 else SlopeS );
plot ATDX;
Switch (VolumeSmoothing){
Case "No" :
    ATDX = w_1 * if atanpma>0 then 1 else -1;
Case "Yes" :
    ATDX = w_2 * if atanpma>0 then 1 else -1;
}


Def JitterZone = if (ATanP>0 and ATanp[1]<0) or (ATanp<0 and ATanp[1]>0) then 1
                 else if (ATanPMA>0 and ATanpMA[1]<0) or (ATanpMA<0 and ATanpMA[1]>0) then 1
                 else 0;

ATDX.AssignValueColor(  if JitterZone then color.yellow
                        else if (tdx==atdx and tdX > 0) then color.uptick
                        else if (tdx==atdx and tdx<0) then color.downtick
                        else color.White
                    );

ATdx.setLineWeight(1);
ATdx.SetPaintingStrategy(PaintingStrategy.LiNE_vs_Triangles);

atdx.setHiding(ShowJitterZone);
addlabel(if showLabel == ShowLabel."yes" then yes else no, if JitterZone then "Jitter Zone" else "Smooth Sail", if JitterZone then color.yellow else if tdx==atdx and tdx>0 then color.uptick else if tdx == atdx and tdx<0 then color.downtick else color.White );

def zone = if (tdx==atdx and tdX > 0) then -5 else if (tdx==atdx and tdx < 0) then 5 else if (TDX != atdx) then 0 else double.nan;
plot ZoneLine = zone;
Zoneline.assignValuecolor(if JitterZone then Color.Yellow else if zoneline == -5 then color.uptick else if zoneline == 5 then color.downTICK else color.White);
zoneline.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);

#hz.AssignValueColor(if JitterZone then Color.Yellow else if zoneline == -5 then color.uptick else if zoneline == 5 then color.downTICK else color.White);
HZ.AssignValueColor(color.gray);

def up = if (ShowPPS == ShowPPS."Yes") then PPS().BuySignal else double.nan;
def down = if (ShowPPS == ShowPPS."Yes") then PPS().SellSignal else double.nan;

def upArrow = if up then 0 else double.NaN;
def dnArrow = if down then 0 else double.NaN;

plot PPSup = upArrow;
Plot PPSdown = dnArrow;
PPSup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
PPSdown.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
PPSup.SetLineWeight(2);
PPSDown.SetLineWeight(2);
PPSUp.AssignValueColor(Color.UpTick);
PPSDown.AssignValueColor(Color.DownTick);

"DI-".hide();
"DI+".hide();
DX.hide();
V1 to V4 works fine, but V8 doesn't work for me It just comes out blank. Can you help?
 
V8 is now available.
V8 replaces V7.
New code available at the top of the first post.
More efficient code - Smaller codebase.
Hi TradeZen, Thanks for the indicator looks promising based on the thread. I tried adding v8 version but TOS is not showing the indicator though though aggregation set to 15M/30M on 1 min chart. Any suggestions? Thank you.
 
@TraderZen how do you adjust the volume cloud? I am currently using version 8.0 but I don't see it anywhere in the settings.

Thank you in in advance for your help and for writing this awesome indicator!
 
Hi TradeZen, Thanks for the indicator looks promising based on the thread. I tried adding v8 version but TOS is not showing the indicator though though aggregation set to 15M/30M on 1 min chart. Any suggestions? Thank you.
I downloaded the code and tried, it is working just fine for me.
 
@TraderZen how do you adjust the volume cloud? I am currently using version 8.0 but I don't see it anywhere in the settings.

Thank you in in advance for your help and for writing this awesome indicator!
In order to adjust the volume cloud - change the Daily Moving Avg Period and Band % of DMA Period Volume values..
 
Thank you for your feedback - I was not aware of this issue with Renko charts. I will look into this.
Thank you for taking the time to create this indicator. I'm currently using the first version as it seems to work well for spotting divergences on the Renko chart. My question is if there is a way I could make the current version work for Renko as well. If there's a block of code I could remove or a simple alteration I could make (I'm not a skilled Thinkscripter by any stretch so the simpler the better), that would be very helpful as I would like to take full advantage of your latest innovations. Thanks again for all your work!
Sorry for the delay. So this is what happened - I had created it for the chart timeframe. There was a demand for MTF. Version 4 works well with Ranko / Range chart because it does not use the MTF functions.
I would not recommend a non-programmer to mess with the code - this code is not very difficult but you'll have to handle the Time-Frame parameters properly and they are intermediate level functions.
I can retrofit the buy/sell indicators in the V4 code. - that is a possibility. Also I can merge the two codes and let the user choose from settings. Buy for now I recommend using v4 for range charts and v8 for multiple minute time-frames.
 
Sorry for the delay. So this is what happened - I had created it for the chart timeframe. There was a demand for MTF. Version 4 works well with Ranko / Range chart because it does not use the MTF functions.
I would not recommend a non-programmer to mess with the code - this code is not very difficult but you'll have to handle the Time-Frame parameters properly and they are intermediate level functions.
I can retrofit the buy/sell indicators in the V4 code. - that is a possibility. Also I can merge the two codes and let the user choose from settings. Buy for now I recommend using v4 for range charts and v8 for multiple minute time-frames.
Thanks very much, and no worries on the delay, I appreciate the work you put in to this. I'll chk out V4 and see how it goes.
 
@TraderZen Thank you so much for this, I've been using it in conjunction with B4 and Shark Fins to day trade SPY options. I notice that Smooth Sailing and Shark Fins work with /ES, but not with SPX. Is there some limitation with SPX that prevents them from even showing up on my chart? Is this something you plan on addressing in future updates?
 
@TraderZen Thank you so much for this, I've been using it in conjunction with B4 and Shark Fins to day trade SPY options. I notice that Smooth Sailing and Shark Fins work with /ES, but not with SPX. Is there some limitation with SPX that prevents them from even showing up on my chart? Is this something you plan on addressing in future updates?
Futures have volume, ETFs have volume, Indices do not have volume. so instead find a parallel ETF/Futures based ETF - try SPY instead. Sharkfins and This indicator depends on volume.
 
@TraderZen Hi. Thanks so much for this study.
May I ask if there's a way to use a scanner for this specially for that transition from one trend to another (the yellow triangle if I was describing it right).

Thanks in advanced.
 
@TraderZen Hi. Thanks so much for this study.
May I ask if there's a way to use a scanner for this specially for that transition from one trend to another (the yellow triangle if I was describing it right).

Thanks in advanced.
Not from this code as is - MTF will become a hurdle. But this can be attempted. I'll included this request in my wishlist.
 
Not from this code as is - MTF will become a hurdle. But this can be attempted. I'll included this request in my wishlist.

Thanks. Figured it out ( I think) but I had to remove the bottom half of unneeded code since TOS was giving out a warning that it was too complex.

The trick is in the scan settings specially MTF must be set to "DAY" and "JZ" being true as the trigger. Picture and reduced code for reference attached below.

So far it's working for me as daily aggregation scan for possible (non-intraday) swing trades. Thanks again for your code.

wiYQvMo.png



Code:
#-------------------------------------------------------------------------------------------------------
# Smooth_Sailing vs Jitter_Zone Indicator
# V 8.0
# Last update 09/02/2022 - Traderzen
#------------------------------------------------------------------------------------------------------

declare lower;

Input UseMTF = {"No", Default "Yes"};
Input MTF = AggregationPeriod.FIFTEEN_MIN;
Input VolumeSmoothing = { Default "Yes", "No"};
Input Slope = {Default "Incremental" , "Aggregate"};
Input Bar_Segment = { Default "HL", "OC" };
Input fast = 2; #Average Slope.
Input SuperSlow = 2; #Projection Curve Setting - Used for the divergence sensitivity.
Input ShowJitterZone = { Default "Yes", "No"};
Input ShowLabel = { default "Yes", "No"}; 
Input ShowVerticalLine = {Default "yes", "No"};
Input ShowPPS = { Default "Yes", "No"};
Input Min_Theta_for_Mfactor = 25; # Buy/Short signal min avg angle.
Input CommonRate = .97125; #Sensitivity for geometric progression

def p_selected = if UseMTF == UseMTF."Yes" then MTF else getAggregationPeriod() ;

def p = if Slope == Slope."Incremental" then GetAggregationPeriod()
        else if p_selected < getAggregationPeriod() then getAggregationPeriod()
        else p_selected;

def mFactor = if UseMTF == UseMTF."Yes" and Slope == Slope."Incremental" then p_selected / getAggregationPeriod() else 1;

def SlopeF = if UseMTF == UseMTF."Yes" and Slope == Slope."Incremental" then (mFactor+fast) else 1;
def SlopeS = if UseMTF == UseMTF."Yes" and Slope == Slope."Incremental" then (mFactor+SuperSlow) else 1 ;

Def averageType = AverageType.wilders;
Def averageType2 = AverageType.Hull;

def hiDiff = IF Bar_Segment == Bar_segment."HL" then high(period=p) - high(period=p)[1] else  close(period=p) - close(period=p)[1];
def loDiff = If Bar_Segment == Bar_segment."HL" then low(period=p)[1] - low(period=p) else open(period=p)[1] - open(period=p);
def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM =  if loDiff > hiDiff and loDiff > 0 then loDiff else 0;
def ATR = MovingAverage(AverageType, TrueRange(high(period=p), close(period=p), low(period=p)), SlopeF);

Plot DIplus = 100 * MovingAverage(averageType, plusDM, SlopeF) / if bar_segment == bar_segment."HL" then ATR else ATR*.5;
Plot DIminus = 100 * MovingAverage(averageType, minusDM, SlopeF) / if bar_segment == bar_segment."HL" then ATR else ATR*.5;
plot DX = DIplus - DIminus;
Plot hz=0;

#-- Real deal Buy signal angle calculation for MTF using geomatric progression.
#-- For example: Do not trigger buy signal if then slope is less than 75 degrees for 1 min chart and 30 degrees for 30 min chart.
def Theta = MIn_Theta_for_Mfactor*power(commonRate,Mfactor-1);

##-- Real deal scientific slope calculation using ArcTan formula.
def ATanP = (ATan(DX/SlopeF) * (180 / Double.Pi)); # MTF support

def v_1 = volume(period=p);
def v_2 = volume;

def w_1 = if ATanp > 0  and !(ATanP[1]> 0)then v_1
          else if ATanP < 0 and !(Atanp[1] < 0 ) then v_1
          else w_1[1] + v_1;

def w_2 = if ATanp > 0  and !(ATanP[1]> 0) then v_2
          else if ATanP < 0 and !(Atanp[1] < 0 ) then v_2
          else w_2[1] + v_2;

plot TDX;
Switch (VolumeSmoothing){
Case "No" :
    TDX = w_1 * if atanp>0 then 1 else -1;
Case "Yes" :
    TDX = w_2 * if atanp>0 then 1 else -1;
}

TDX.AssignValueColor(
    if ATanP >= ATanP[1] && ATanP > 0 and TDX >= TDX[1] then color.cyan
    else if ATanP <= ATanP[1]&& ATanP > 0 and TDX >= TDX[1] then color.light_green
    else if ATanP <= ATanP[1]&& ATanP < 0 and TDX <= TDX[1] then color.magenta
    else if ATanP >= ATanP[1]&& ATanP < 0 and TDX <= TDX[1] then color.Pink
    else Color.yellow
);
TDX.setLineWeight(1);
TDX.SetPaintingStrategy(PaintingStrategy.histogram);

def ATANPMA = MovingAverage(averageType2, ATanP,mFactor);
plot ATDX;
Switch (VolumeSmoothing){
Case "No" :
    ATDX = w_1 * if atanpma>0 then 1 else -1;
Case "Yes" :
    ATDX = w_2 * if atanpma>0 then 1 else -1;
}

Def JitterZone = if (ATanP>0 and ATanp[1]<0) or (ATanp<0 and ATanp[1]>0) then 1
                 else if (ATanPMA>0 and ATanpMA[1]<0) or (ATanpMA<0 and ATanpMA[1]>0) then 1
                 else 0;

ATDX.AssignValueColor(  if JitterZone then color.yellow
                        else if (tdx==atdx and tdX > 0) then color.uptick
                        else if (tdx==atdx and tdx<0) then color.downtick
                        else color.yellow
                    );

ATdx.setLineWeight(1);
ATdx.SetPaintingStrategy(PaintingStrategy.LiNE);

plot jz = if Jitterzone or (tdx!=atdx)  then atdx else double.nan;
jz.setpaintingstrategy(paintingStrategy.LINE_VS_Triangles);
jz.setlineweight(3);
jz.assignValueColor(color.yellow);

atdx.setHiding(ShowJitterZone);
jz.setHiding(ShowJitterZone);

addlabel(if showLabel == ShowLabel."yes" then yes else no, if JitterZone then "Jitter Zone" else "Smooth Sail", if JitterZone then color.yellow else if tdx==atdx and tdx>0 then color.uptick else if tdx == atdx and tdx<0 then color.downtick else color.White );
 
Last edited:
Thanks. Figured it out ( I think) but I had to removed the bottom half of unneeded code since TOS was giving out a warning that it was to complex.

The trick is in the scan settings specially MTF must be set to "DAY" and "JZ" being true as the trigger. Picture and reduced code for reference attached below.

So far it's working for me as daily aggregation scan for possible (non-intraday) swing trades. Thanks again for your code.

wiYQvMo.png



Code:
#-------------------------------------------------------------------------------------------------------
# Smooth_Sailing vs Jitter_Zone Indicator
# V 8.0
# Last update 09/02/2022 - Traderzen
#------------------------------------------------------------------------------------------------------

declare lower;

Input UseMTF = {"No", Default "Yes"};
Input MTF = AggregationPeriod.FIFTEEN_MIN;
Input VolumeSmoothing = { Default "Yes", "No"};
Input Slope = {Default "Incremental" , "Aggregate"};
Input Bar_Segment = { Default "HL", "OC" };
Input fast = 2; #Average Slope.
Input SuperSlow = 2; #Projection Curve Setting - Used for the divergence sensitivity.
Input ShowJitterZone = { Default "Yes", "No"};
Input ShowLabel = { default "Yes", "No"}; 
Input ShowVerticalLine = {Default "yes", "No"};
Input ShowPPS = { Default "Yes", "No"};
Input Min_Theta_for_Mfactor = 25; # Buy/Short signal min avg angle.
Input CommonRate = .97125; #Sensitivity for geometric progression

def p_selected = if UseMTF == UseMTF."Yes" then MTF else getAggregationPeriod() ;

def p = if Slope == Slope."Incremental" then GetAggregationPeriod()
        else if p_selected < getAggregationPeriod() then getAggregationPeriod()
        else p_selected;

def mFactor = if UseMTF == UseMTF."Yes" and Slope == Slope."Incremental" then p_selected / getAggregationPeriod() else 1;

def SlopeF = if UseMTF == UseMTF."Yes" and Slope == Slope."Incremental" then (mFactor+fast) else 1;
def SlopeS = if UseMTF == UseMTF."Yes" and Slope == Slope."Incremental" then (mFactor+SuperSlow) else 1 ;

Def averageType = AverageType.wilders;
Def averageType2 = AverageType.Hull;

def hiDiff = IF Bar_Segment == Bar_segment."HL" then high(period=p) - high(period=p)[1] else  close(period=p) - close(period=p)[1];
def loDiff = If Bar_Segment == Bar_segment."HL" then low(period=p)[1] - low(period=p) else open(period=p)[1] - open(period=p);
def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM =  if loDiff > hiDiff and loDiff > 0 then loDiff else 0;
def ATR = MovingAverage(AverageType, TrueRange(high(period=p), close(period=p), low(period=p)), SlopeF);

Plot DIplus = 100 * MovingAverage(averageType, plusDM, SlopeF) / if bar_segment == bar_segment."HL" then ATR else ATR*.5;
Plot DIminus = 100 * MovingAverage(averageType, minusDM, SlopeF) / if bar_segment == bar_segment."HL" then ATR else ATR*.5;
plot DX = DIplus - DIminus;
Plot hz=0;

#-- Real deal Buy signal angle calculation for MTF using geomatric progression.
#-- For example: Do not trigger buy signal if then slope is less than 75 degrees for 1 min chart and 30 degrees for 30 min chart.
def Theta = MIn_Theta_for_Mfactor*power(commonRate,Mfactor-1);

##-- Real deal scientific slope calculation using ArcTan formula.
def ATanP = (ATan(DX/SlopeF) * (180 / Double.Pi)); # MTF support

def v_1 = volume(period=p);
def v_2 = volume;

def w_1 = if ATanp > 0  and !(ATanP[1]> 0)then v_1
          else if ATanP < 0 and !(Atanp[1] < 0 ) then v_1
          else w_1[1] + v_1;

def w_2 = if ATanp > 0  and !(ATanP[1]> 0) then v_2
          else if ATanP < 0 and !(Atanp[1] < 0 ) then v_2
          else w_2[1] + v_2;

plot TDX;
Switch (VolumeSmoothing){
Case "No" :
    TDX = w_1 * if atanp>0 then 1 else -1;
Case "Yes" :
    TDX = w_2 * if atanp>0 then 1 else -1;
}

TDX.AssignValueColor(
    if ATanP >= ATanP[1] && ATanP > 0 and TDX >= TDX[1] then color.cyan
    else if ATanP <= ATanP[1]&& ATanP > 0 and TDX >= TDX[1] then color.light_green
    else if ATanP <= ATanP[1]&& ATanP < 0 and TDX <= TDX[1] then color.magenta
    else if ATanP >= ATanP[1]&& ATanP < 0 and TDX <= TDX[1] then color.Pink
    else Color.yellow
);
TDX.setLineWeight(1);
TDX.SetPaintingStrategy(PaintingStrategy.histogram);

def ATANPMA = MovingAverage(averageType2, ATanP,mFactor);
plot ATDX;
Switch (VolumeSmoothing){
Case "No" :
    ATDX = w_1 * if atanpma>0 then 1 else -1;
Case "Yes" :
    ATDX = w_2 * if atanpma>0 then 1 else -1;
}

Def JitterZone = if (ATanP>0 and ATanp[1]<0) or (ATanp<0 and ATanp[1]>0) then 1
                 else if (ATanPMA>0 and ATanpMA[1]<0) or (ATanpMA<0 and ATanpMA[1]>0) then 1
                 else 0;

ATDX.AssignValueColor(  if JitterZone then color.yellow
                        else if (tdx==atdx and tdX > 0) then color.uptick
                        else if (tdx==atdx and tdx<0) then color.downtick
                        else color.yellow
                    );

ATdx.setLineWeight(1);
ATdx.SetPaintingStrategy(PaintingStrategy.LiNE);

plot jz = if Jitterzone or (tdx!=atdx)  then atdx else double.nan;
jz.setpaintingstrategy(paintingStrategy.LINE_VS_Triangles);
jz.setlineweight(3);
jz.assignValueColor(color.yellow);

atdx.setHiding(ShowJitterZone);
jz.setHiding(ShowJitterZone);

addlabel(if showLabel == ShowLabel."yes" then yes else no, if JitterZone then "Jitter Zone" else "Smooth Sail", if JitterZone then color.yellow else if tdx==atdx and tdx>0 then color.uptick else if tdx == atdx and tdx<0 then color.downtick else color.White );
Awesome I think that addlabel statement in the end can be dropped too.
 
Awesome I think that addlabel statement in the end can be dropped too.
Thanks. I'm still an amateur in thinkscript so I just removed what I thought was safe to remove. It's working so far.

May next goal/ request perhaps is specific scan of transition from bullish to JZ and vice versa. What's currently scanning is a bit non-specific (JZ is true regardless if it's from the bullish or bearish). Current status is good enough but it could always be better.

Thanks again.
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
357 Online
Create Post

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top