Capturing recent highs and lows

SJP07

Member
I am looking for a code that can generate a downward arrow when a candle displays a lower high on both its left and right sides. Additionally, I require a code that can produce an upward arrow when a candle shows a higher low on its left and right sides. I attempted to code it myself, but it is not correctly identifying these patterns. Here's what I have so far:

def Highest = if High[1] is greater than High && High[1] is greater than High[2] then High[1] else double.nan;
Plot HH = Highest;
HH.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_Down);
HH.SetLineWeight(1);
HH.SetDefaultColor(Color.Downtick);

def Lowest = if Low[1] is less than low && low[1] is less than low[2] then low[1] else double.nan;
Plot LL = Lowest;
LL.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
LL.SetLineWeight(1);
LL.SetDefaultColor(Color.Uptick);
 
Solution
Ruby:
def Highest = if High[-1] is less than High && High[1] is less than High then High else double.nan;
Plot HH = Highest;
HH.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_Down);
HH.SetLineWeight(1);
HH.SetDefaultColor(Color.Downtick);

def Lowest = if Low[-1] is greater than low && low[1] is greater than low then low else double.nan;
Plot LL = Lowest;
LL.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
LL.SetLineWeight(1);
LL.SetDefaultColor(Color.Uptick);
Ruby:
def Highest = if High[-1] is less than High && High[1] is less than High then High else double.nan;
Plot HH = Highest;
HH.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_Down);
HH.SetLineWeight(1);
HH.SetDefaultColor(Color.Downtick);

def Lowest = if Low[-1] is greater than low && low[1] is greater than low then low else double.nan;
Plot LL = Lowest;
LL.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
LL.SetLineWeight(1);
LL.SetDefaultColor(Color.Uptick);
 
Solution
Ruby:
def Highest = if High[-1] is less than High && High[1] is less than High then High else double.nan;
Plot HH = Highest;
HH.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_Down);
HH.SetLineWeight(1);
HH.SetDefaultColor(Color.Downtick);

def Lowest = if Low[-1] is greater than low && low[1] is greater than low then low else double.nan;
Plot LL = Lowest;
LL.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
LL.SetLineWeight(1);
LL.SetDefaultColor(Color.Uptick);
Is it possible to create input that adds a horizontal line for the last five HH and LL plots? The horizontal line should be extended all the way to the right.
 
mAUKwxo.png

Ruby:
def Highest = if high[-1] is less than high && high[1] is less than high then high else Double.NaN;
plot HH = Highest;
HH.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
HH.SetLineWeight(1);
HH.SetDefaultColor(Color.DOWNTICK);

def Lowest = if low[-1] is greater than low && low[1] is greater than low then low else Double.NaN;
plot LL = Lowest;
LL.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
LL.SetLineWeight(1);
LL.SetDefaultColor(Color.UPTICK);

def HighestCounter = CompoundValue(1, if !IsNaN(Highest) then HighestCounter[1] + 1 else HighestCounter[1], 0);
def LowestCounter = CompoundValue(1, if !IsNaN(Lowest) then LowestCounter[1] + 1 else LowestCounter[1], 0);

script Line {
    input Counter = 0;
    input Count = 0;
    input value = 0;

    def L = if Counter == HighestAll(Counter) - (Count - 1)
            and GetValue(Counter,1) <> Counter
            then value
            else L[1];
    plot Line = L;
    }

plot HH1P = if Line(HighestCounter,1,high) then Line(HighestCounter,1,high) else Double.NaN;
plot HH2P = if Line(HighestCounter,2,high) then Line(HighestCounter,2,high) else Double.NaN;
plot HH3P = if Line(HighestCounter,3,high) then Line(HighestCounter,3,high) else Double.NaN;
plot HH4P = if Line(HighestCounter,4,high) then Line(HighestCounter,4,high) else Double.NaN;
plot HH5P = if Line(HighestCounter,5,high) then Line(HighestCounter,5,high) else Double.NaN;

plot LL1P = if Line(LowestCounter,1,low) then Line(LowestCounter,1,low) else Double.NaN;
plot LL2P = if Line(LowestCounter,2,low) then Line(LowestCounter,2,low) else Double.NaN;
plot LL3P = if Line(LowestCounter,3,low) then Line(LowestCounter,3,low) else Double.NaN;
plot LL4P = if Line(LowestCounter,4,low) then Line(LowestCounter,4,low) else Double.NaN;
plot LL5P = if Line(LowestCounter,5,low) then Line(LowestCounter,5,low) else Double.NaN;

You may want to actually plot 2nd through 6th instead of 1st through 5th as the last HH and LL could repaint.
 
Last edited:
Ruby:
def Highest = if High[-1] is less than High && High[1] is less than High then High else double.nan;
Plot HH = Highest;
HH.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_Down);
HH.SetLineWeight(1);
HH.SetDefaultColor(Color.Downtick);

def Lowest = if Low[-1] is greater than low && low[1] is greater than low then low else double.nan;
Plot LL = Lowest;
LL.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
LL.SetLineWeight(1);
LL.SetDefaultColor(Color.Uptick);

I'm looking for another edit to this fantastic code.

I want to turn a candle white when it has a high point with two lower highs on each side and a low point is established with a higher low on each side.

I've included a screenshot as an example.
 

Attachments

  • HH_LL.png
    HH_LL.png
    40.9 KB · Views: 95
Last edited by a moderator:
Take it for test run

Code:
def o = open;
def h = high;
def l = low;
def c = close;
def max = max(o, c);
def min = min(o, c);



input Hide_Main_Cloud = NO;
input Hide_Main_Lines = YES;
input Hide_Lines = NO;
DefineGlobalColor("sup", Color.lIGHT_GREEN);
DefineGlobalColor("res", Color.LIGHT_RED);

input HideCloud = NO;



DefineGlobalColor("Support", Color.green);
DefineGlobalColor("Resistance", Color.red);

#--------------------------------------------------------------


def Highest = if high[-1] is less than high && high[1] is less than high then high else Double.NaN;
plot HH = Highest;
HH.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
HH.SetLineWeight(1);
HH.SetDefaultColor(Color.DOWNTICK);

def Lowest = if low[-1] is greater than low && low[1] is greater than low then low else Double.NaN;
plot LL = Lowest;
LL.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
LL.SetLineWeight(1);
LL.SetDefaultColor(Color.UPTICK);

def HighestCounter = CompoundValue(1, if !IsNaN(Highest) then HighestCounter[1] + 1 else HighestCounter[1], 0);
def LowestCounter = CompoundValue(1, if !IsNaN(Lowest) then LowestCounter[1] + 1 else LowestCounter[1], 0);

script Line {
    input Counter = 0;
    input Count = 0;
    input value = 0;

    def L = if Counter == HighestAll(Counter) - (Count - 1)
            and GetValue(Counter,1) <> Counter
            then value
            else L[1];
    plot Line = L;
    }

plot HH1P = if Line(HighestCounter,1,high) then Line(HighestCounter,1,high) else Double.NaN;

plot LL1P = if Line(LowestCounter,1,low) then Line(LowestCounter,1,low) else Double.NaN;



#--------------------------------------------------------------



#-------------------------- Support Levels --------------------------------------------------#

plot SupportLevel =
if Lowest  then low else Double.NaN;
supportLevel.SetDefaultColor(Color.green);

def SLine0;
def SLine1;
def SLine2;
def SLine3;
def SLine4;
def SLine5;
def SLine6;
def SLine7;
def SLine8;
def SLine9;
def SLine10;
def SLine11;
def SLine12;
def SLine13;
def SLine14;
def SLine15;
def SLine16;
def SLine17;
def SLine18;
def SLine19;
def SLine20;
#Cwparker23#
def SLineCount;
If SupportLevel == 1 { SLineCount = 1;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine1[1]) and min<=SLine1[1]) { SLineCount=0;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine2[1]) and min<=SLine2[1]) { SLineCount=1;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine3[1]) and min<=SLine3[1]) { SLineCount=2;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine4[1]) and min<=SLine4[1]) { SLineCount=3;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine5[1]) and min<=SLine5[1]) { SLineCount=4;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine6[1]) and min<=SLine6[1]) { SLineCount=5;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine7[1]) and min<=SLine7[1]) { SLineCount=6;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine8[1]) and min<=SLine8[1]) { SLineCount=7;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine9[1]) and min<=SLine9[1]) { SLineCount=8;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine10[1]) and min<=SLine10[1]) { SLineCount=9;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine11[1]) and min<=SLine11[1]) { SLineCount=10;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine12[1]) and min<=SLine12[1]) { SLineCount=11;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine13[1]) and min<=SLine13[1]) { SLineCount=12;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine14[1]) and min<=SLine14[1]) { SLineCount=13;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine15[1]) and min<=SLine15[1]) { SLineCount=14;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine16[1]) and min<=SLine16[1]) { SLineCount=15;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine17[1]) and min<=SLine17[1]) { SLineCount=16;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine18[1]) and min<=SLine18[1]) { SLineCount=17;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine19[1]) and min<=SLine19[1]) { SLineCount=18;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine20[1]) and min<=SLine20[1]) { SLineCount=19;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine0[1]) and min<=SLine0[1]) { SLineCount=20;

}else if (!IsNaN(SupportLevel) and !IsNaN(SLine0[1]) and min<=SLine0[1]) { SLineCount=0;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine1[1]) and min<=SLine1[1]) { SLineCount=1;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine2[1]) and min<=SLine2[1]) { SLineCount=2;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine3[1]) and min<=SLine3[1]) { SLineCount=3;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine4[1]) and min<=SLine4[1]) { SLineCount=4;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine5[1]) and min<=SLine5[1]) { SLineCount=5;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine6[1]) and min<=SLine6[1]) { SLineCount=6;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine7[1]) and min<=SLine7[1]) { SLineCount=7;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine8[1]) and min<=SLine8[1]) { SLineCount=8;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine9[1]) and min<=SLine9[1]) { SLineCount=9;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine10[1]) and min<=SLine10[1]) { SLineCount=10;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine11[1]) and min<=SLine11[1]) { SLineCount=11;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine12[1]) and min<=SLine12[1]) { SLineCount=12;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine13[1]) and min<=SLine13[1]) { SLineCount=13;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine14[1]) and min<=SLine14[1]) { SLineCount=14;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine15[1]) and min<=SLine15[1]) { SLineCount=15;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine16[1]) and min<=SLine16[1]) { SLineCount=16;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine17[1]) and min<=SLine17[1]) { SLineCount=17;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine18[1]) and min<=SLine18[1]) { SLineCount=18;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine19[1]) and min<=SLine19[1]) { SLineCount=19;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine20[1]) and min<=SLine20[1]) { SLineCount=20;
}else if (!IsNaN(SupportLevel)) and SLineCount[1]!=20 { SLineCount = SLineCount[1] + 1;
}else if (IsNaN(SupportLevel)) and SLineCount[1]==20 { SLineCount = 0;
} else { SLineCount = SLineCount[1];
}
#Cwparker23#
#============================================================================================#
SLine0 = if !IsNaN(SupportLevel) and SLineCount == 0 then SupportLevel else if !IsNaN(SLine0[1]) and min <= SLine0[1] then 0 else SLine0[1];
plot SLineP0 = if SLine0 > 0 then SLine0 else Double.NaN;
SLineP0.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP0.SetDefaultColor(Color.LIGHT_GREEN);
SLineP0.SetHiding(Hide_Lines);
SLineP0.HideBubble();
#Cwparker23#


#----------------------------------------------------------------------------------
SLine1 = if !IsNaN(SupportLevel) and SLineCount == 1 then SupportLevel else if !IsNaN(SLine1[1]) and min <= SLine1[1] then 0 else SLine1[1];
plot SLineP1 = if SLine1 > 0 then SLine1 else Double.NaN;
SLineP1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP1.SetDefaultColor(Color.LIGHT_GREEN);
SLineP1.SetHiding(Hide_Lines);
SLineP1.HideBubble();

#----------------------------------------------------------------------------------
SLine2 = if !IsNaN(SupportLevel) and SLineCount == 2 then SupportLevel else if !IsNaN(SLine2[1]) and min <= SLine2[1] then 0 else SLine2[1];
plot SLineP2 = if SLine2 > 0 then SLine2 else Double.NaN;
SLineP2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP2.SetDefaultColor(Color.LIGHT_GREEN);
SLineP2.SetHiding(Hide_Lines);
SLineP2.HideBubble();
#Cwparker23#

#----------------------------------------------------------------------------------
SLine3 = if !IsNaN(SupportLevel) and SLineCount == 3 then SupportLevel else if !IsNaN(SLine3[1]) and min <= SLine3[1] then 0 else SLine3[1];
plot SLineP3 = if SLine3 > 0 then SLine3 else Double.NaN;
SLineP3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP3.SetDefaultColor(Color.LIGHT_GREEN);
SLineP3.SetHiding(Hide_Lines);
SLineP3.HideBubble();

#----------------------------------------------------------------------------------
SLine4 = if !IsNaN(SupportLevel) and SLineCount == 4 then SupportLevel else if !IsNaN(SLine4[1]) and min <= SLine4[1] then 0 else SLine4[1];
plot SLineP4 = if SLine4 > 0 then SLine4 else Double.NaN;
SLineP4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP4.SetDefaultColor(Color.LIGHT_GREEN);
SLineP4.SetHiding(Hide_Lines);
SLineP4.HideBubble();
def SLine4Length = if SLine4 != SLine4[1] then 1 else if !IsNaN(SLine4[1]) and IsNaN(SLine4) then 0 else if !IsNaN(SLine4) then SLine4Length[1] + 1 else 0;


#----------------------------------------------------------------------------------
SLine5 = if !IsNaN(SupportLevel) and SLineCount == 5 then SupportLevel else if !IsNaN(SLine5[1]) and min <= SLine5[1] then 0 else SLine5[1];
plot SLineP5 = if SLine5 > 0 then SLine5 else Double.NaN;
SLineP5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP5.SetDefaultColor(Color.LIGHT_GREEN);
SLineP5.SetHiding(Hide_Lines);
SLineP5.HideBubble();

#----------------------------------------------------------------------------------
SLine6 = if !IsNaN(SupportLevel) and SLineCount == 6 then SupportLevel else if !IsNaN(SLine6[1]) and min <= SLine6[1] then 0 else SLine6[1];
plot SLineP6 = if SLine6 > 0 then SLine6 else Double.NaN;
SLineP6.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP6.SetDefaultColor(Color.LIGHT_GREEN);
SLineP6.SetHiding(Hide_Lines);
SLineP6.HideBubble();
#Cwparker23#

#----------------------------------------------------------------------------------
SLine7 = if !IsNaN(SupportLevel) and SLineCount == 7 then SupportLevel else if !IsNaN(SLine7[1]) and min <= SLine7[1] then 0 else SLine7[1];
plot SLineP7 = if SLine7 > 0 then SLine7 else Double.NaN;
SLineP7.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP7.SetDefaultColor(Color.LIGHT_GREEN);
SLineP7.SetHiding(Hide_Lines);
SLineP7.HideBubble();

#----------------------------------------------------------------------------------
SLine8 = if !IsNaN(SupportLevel) and SLineCount == 8 then SupportLevel else if !IsNaN(SLine8[1]) and min <= SLine8[1] then 0 else SLine8[1];
plot SLineP8 = if SLine8 > 0 then SLine8 else Double.NaN;
SLineP8.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP8.SetDefaultColor(Color.LIGHT_GREEN);
SLineP8.SetHiding(Hide_Lines);
SLineP8.HideBubble();

#----------------------------------------------------------------------------------
SLine9 = if !IsNaN(SupportLevel) and SLineCount == 9 then SupportLevel else if !IsNaN(SLine9[1]) and min <= SLine9[1] then 0 else SLine9[1];
plot SLineP9 = if SLine9 > 0 then SLine9 else Double.NaN;
SLineP9.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP9.SetDefaultColor(Color.LIGHT_GREEN);
SLineP9.SetHiding(Hide_Lines);
SLineP9.HideBubble();

#----------------------------------------------------------------------------------
SLine10 = if !IsNaN(SupportLevel) and SLineCount == 10 then SupportLevel else if !IsNaN(SLine10[1]) and min <= SLine10[1] then 0 else SLine10[1];
plot SLineP10 = if SLine10 > 0 then SLine10 else Double.NaN;
SLineP10.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP10.SetDefaultColor(Color.LIGHT_GREEN);
SLineP10.SetHiding(Hide_Lines);
SLineP10.HideBubble();

#----------------------------------------------------------------------------------
SLine11 = if !IsNaN(SupportLevel) and SLineCount == 11 then SupportLevel else if !IsNaN(SLine11[1]) and min <= SLine11[1] then 0 else SLine11[1];
plot SLineP11 = if SLine11 > 0 then SLine11 else Double.NaN;
SLineP11.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP11.SetDefaultColor(Color.LIGHT_GREEN);
SLineP11.SetHiding(Hide_Lines);
SLineP11.HideBubble();

#----------------------------------------------------------------------------------
SLine12 = if !IsNaN(SupportLevel) and SLineCount == 12 then SupportLevel else if !IsNaN(SLine12[1]) and min <= SLine12[1] then 0 else SLine12[1];
plot SLineP12 = if SLine12 > 0 then SLine12 else Double.NaN;
SLineP12.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP12.SetDefaultColor(Color.LIGHT_GREEN);
SLineP12.SetHiding(Hide_Lines);
SLineP12.HideBubble();
#Cwparker23#

#----------------------------------------------------------------------------------
SLine13 = if !IsNaN(SupportLevel) and SLineCount == 13 then SupportLevel else if !IsNaN(SLine13[1]) and min <= SLine13[1] then 0 else SLine13[1];
plot SLineP13 = if SLine13 > 0 then SLine13 else Double.NaN;
SLineP13.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP13.SetDefaultColor(Color.LIGHT_GREEN);
SLineP13.SetHiding(Hide_Lines);
SLineP13.HideBubble();

#----------------------------------------------------------------------------------
SLine14 = if !IsNaN(SupportLevel) and SLineCount == 14 then SupportLevel else if !IsNaN(SLine14[1]) and min <= SLine14[1] then 0 else SLine14[1];
plot SLineP14 = if SLine14 > 0 then SLine14 else Double.NaN;
SLineP14.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP14.SetDefaultColor(Color.LIGHT_GREEN);
SLineP14.SetHiding(Hide_Lines);
SLineP14.HideBubble();


#----------------------------------------------------------------------------------
SLine15 = if !IsNaN(SupportLevel) and SLineCount == 15 then SupportLevel else if !IsNaN(SLine15[1]) and min <= SLine15[1] then 0 else SLine15[1];
plot SLineP15 = if SLine15 > 0 then SLine15 else Double.NaN;
SLineP15.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP15.SetDefaultColor(Color.LIGHT_GREEN);
SLineP15.SetHiding(Hide_Lines);
SLineP15.HideBubble();


#----------------------------------------------------------------------------------
SLine16 = if !IsNaN(SupportLevel) and SLineCount == 16 then SupportLevel else if !IsNaN(SLine16[1]) and min <= SLine16[1] then 0 else SLine16[1];
plot SLineP16 = if SLine16 > 0 then SLine16 else Double.NaN;
SLineP16.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP16.SetDefaultColor(Color.LIGHT_GREEN);
SLineP16.SetHiding(Hide_Lines);
SLineP16.HideBubble();

#----------------------------------------------------------------------------------
SLine17 = if !IsNaN(SupportLevel) and SLineCount == 17 then SupportLevel else if !IsNaN(SLine17[1]) and min <= SLine17[1] then 0 else SLine17[1];
plot SLineP17 = if SLine17 > 0 then SLine17 else Double.NaN;
SLineP17.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP17.SetDefaultColor(Color.LIGHT_GREEN);
SLineP17.SetHiding(Hide_Lines);
SLineP17.HideBubble();


#----------------------------------------------------------------------------------
SLine18 = if !IsNaN(SupportLevel) and SLineCount == 18 then SupportLevel else if !IsNaN(SLine18[1]) and min < SLine18[1] then 0 else SLine18[1];
plot SLineP18 = if SLine18 > 0 then SLine18 else Double.NaN;
SLineP18.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP18.SetDefaultColor(Color.LIGHT_GREEN);
SLineP18.SetHiding(Hide_Lines);
SLineP18.HideBubble();
#Cwparker23#

#----------------------------------------------------------------------------------
SLine19 = if !IsNaN(SupportLevel) and SLineCount == 19 then SupportLevel else if !IsNaN(SLine19[1]) and min <= SLine19[1] then 0 else SLine19[1];
plot SLineP19 = if SLine19 > 0 then SLine19 else Double.NaN;
SLineP19.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP19.SetDefaultColor(Color.LIGHT_GREEN);
SLineP19.SetHiding(Hide_Lines);
SLineP19.HideBubble();


#----------------------------------------------------------------------------------
SLine20 = if !IsNaN(SupportLevel) and SLineCount == 20 then SupportLevel else if !IsNaN(SLine20[1]) and min <= SLine20[1] then 0 else SLine20[1];
plot SLineP20 = if SLine20 > 0 then SLine20 else Double.NaN;
SLineP20.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP20.SetDefaultColor(Color.LIGHT_GREEN);
SLineP20.SetHiding(Hide_Lines);
SLineP20.HideBubble();





#Definitons of Resistance Levels.#####################################################
######################################################################################
plot ResistanceLevel = if Highest then high else Double.NaN;
resistanceLevel.SetDefaultColor(Color.RED);

def RLine0;
def RLine1;
def RLine2;
def RLine3;
def RLine4;
def RLine5;
def RLine6;
def RLine7;
def RLine8;
def RLine9;
def RLine10;
def RLine11;
def RLine12;
def RLine13;
def RLine14;
def RLine15;
def RLine16;
def RLine17;
def RLine18;
def RLine19;
def RLine20;

def RLineCount;
If ResistanceLevel == 1 { RLineCount = 1;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine1[1]) and max>=RLine1[1]) { RLineCount=0;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine2[1]) and max>=RLine2[1]) { RLineCount=1;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine3[1]) and max>=RLine3[1]) { RLineCount=2;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine4[1]) and max>=RLine4[1]) { RLineCount=3;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine5[1]) and max>=RLine5[1]) { RLineCount=4;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine6[1]) and max>=RLine6[1]) { RLineCount=5;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine7[1]) and max>=RLine7[1]) { RLineCount=6;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine8[1]) and max>=RLine8[1]) { RLineCount=7;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine9[1]) and max>=RLine9[1]) { RLineCount=8;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine10[1]) and max>=RLine10[1]) { RLineCount=9;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine11[1]) and max>=RLine11[1]) { RLineCount=10;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine12[1]) and max>=RLine12[1]) { RLineCount=11;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine13[1]) and max>=RLine13[1]) { RLineCount=12;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine14[1]) and max>=RLine14[1]) { RLineCount=13;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine15[1]) and max>=RLine15[1]) { RLineCount=14;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine16[1]) and max>=RLine16[1]) { RLineCount=15;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine17[1]) and max>=RLine17[1]) { RLineCount=16;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine18[1]) and max>=RLine18[1]) { RLineCount=17;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine19[1]) and max>=RLine19[1]) { RLineCount=18;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine20[1]) and max>=RLine20[1]) { RLineCount=19;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine0[1]) and max>=RLine0[1]) { RLineCount=20;

}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine0[1]) and max>=RLine0[1]) { RLineCount=0;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine1[1]) and max>=RLine1[1]) { RLineCount=1;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine2[1]) and max>=RLine2[1]) { RLineCount=2;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine3[1]) and max>=RLine3[1]) { RLineCount=3;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine4[1]) and max>=RLine4[1]) { RLineCount=4;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine5[1]) and max>=RLine5[1]) { RLineCount=5;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine6[1]) and max>=RLine6[1]) { RLineCount=6;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine7[1]) and max>=RLine7[1]) { RLineCount=7;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine8[1]) and max>=RLine8[1]) { RLineCount=8;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine9[1]) and max>=RLine9[1]) { RLineCount=9;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine10[1]) and max>=RLine10[1]) { RLineCount=10;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine11[1]) and max>=RLine11[1]) { RLineCount=11;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine12[1]) and max>=RLine12[1]) { RLineCount=12;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine13[1]) and max>=RLine13[1]) { RLineCount=13;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine14[1]) and max>=RLine14[1]) { RLineCount=14;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine15[1]) and max>=RLine15[1]) { RLineCount=15;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine16[1]) and max>=RLine16[1]) { RLineCount=16;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine17[1]) and max>=RLine17[1]) { RLineCount=17;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine18[1]) and max>=RLine18[1]) { RLineCount=18;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine19[1]) and max>=RLine19[1]) { RLineCount=19;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine20[1]) and max>=RLine20[1]) { RLineCount=20;
}else if (!IsNaN(ResistanceLevel)) and RLineCount[1]!=20 { RLineCount = RLineCount[1] + 1;
}else if (!IsNaN(ResistanceLevel)) and RLineCount[1]==20 { RLineCount = 0;
} else {
    RLineCount = RLineCount[1];
}

#-------------------------- Resistance Levels ----------------------------------------------

RLine0 = if !IsNaN(ResistanceLevel) and RLineCount == 0 then ResistanceLevel else if !IsNaN(RLine0[1]) and max >= RLine0[1] then Double.NaN else RLine0[1];
plot RLineP0 = if RLine0 > 0 then RLine0 else Double.NaN;
RLineP0.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP0.SetDefaultColor(Color.LIGHT_RED);
RLineP0.SetHiding(Hide_Lines);
RLineP0.HideBubble();
def RLine0Length = if RLine0 != RLine0[1] then 1 else if !IsNaN(RLine0[1]) and IsNaN(RLine0) then 0 else if !IsNaN(RLine0) then RLine0Length[1] + 1 else 0;

#----------------------------------------------------------------------------------
RLine1 = if !IsNaN(ResistanceLevel) and RLineCount == 1 then ResistanceLevel else if !IsNaN(RLine1[1]) and max >= RLine1[1] then Double.NaN else RLine1[1];
plot RLineP1 = if RLine1 > 0 then RLine1 else Double.NaN;
RLineP1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP1.SetDefaultColor(Color.LIGHT_RED);
RLineP1.SetHiding(Hide_Lines);
RLineP1.HideBubble();
def RLine1Length = if RLine1 != RLine1[1] then 1 else if !IsNaN(RLine1[1]) and IsNaN(RLine1) then 0 else if !IsNaN(RLine1) then RLine1Length[1] + 1 else 0;

#----------------------------------------------------------------------------------
RLine2 = if !IsNaN(ResistanceLevel) and RLineCount == 2 then ResistanceLevel else if !IsNaN(RLine2[1]) and max >= RLine2[1] then Double.NaN else RLine2[1];
plot RLineP2 = if RLine2 > 0 then RLine2 else Double.NaN;
RLineP2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP2.SetDefaultColor(Color.LIGHT_RED);
RLineP2.SetHiding(Hide_Lines);
RLineP2.HideBubble();
def RLine2Length = if RLine2 != RLine2[1] then 1 else if !IsNaN(RLine2[1]) and IsNaN(RLine2) then 0 else if !IsNaN(RLine2) then RLine2Length[1] + 1 else 0;

#----------------------------------------------------------------------------------
RLine3 = if !IsNaN(ResistanceLevel) and RLineCount == 3 then ResistanceLevel else if !IsNaN(RLine3[1]) and max >= RLine3[1] then Double.NaN else RLine3[1];
plot RLineP3 = if RLine3 > 0 then RLine3 else Double.NaN;
RLineP3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP3.SetDefaultColor(Color.LIGHT_RED);
RLineP3.SetHiding(Hide_Lines);
RLineP3.HideBubble();
def RLine3Length = if RLine3 != RLine3[1] then 1 else if !IsNaN(RLine3[1]) and IsNaN(RLine3) then 0 else if !IsNaN(RLine3) then RLine3Length[1] + 1 else 0;

#----------------------------------------------------------------------------------
RLine4 = if !IsNaN(ResistanceLevel) and RLineCount == 4 then ResistanceLevel else if !IsNaN(RLine4[1]) and max >= RLine4[1] then Double.NaN else RLine4[1];
plot RLineP4 = if RLine4 > 0 then RLine4 else Double.NaN;
RLineP4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP4.SetDefaultColor(Color.LIGHT_RED);
RLineP4.SetHiding(Hide_Lines);
RLineP4.HideBubble();
def RLine4Length = if RLine4 != RLine4[1] then 1 else if !IsNaN(RLine4[1]) and IsNaN(RLine4) then 0 else if !IsNaN(RLine4) then RLine4Length[1] + 1 else 0;

#----------------------------------------------------------------------------------
RLine5 = if !IsNaN(ResistanceLevel) and RLineCount == 5 then ResistanceLevel else if !IsNaN(RLine5[1]) and max >= RLine5[1] then Double.NaN else RLine5[1];
plot RLineP5 = if RLine5 > 0 then RLine5 else Double.NaN;
RLineP5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP5.SetDefaultColor(Color.LIGHT_RED);
RLineP5.SetHiding(Hide_Lines);
RLineP5.HideBubble();
def RLine5Length = if RLine5 != RLine5[1] then 1 else if !IsNaN(RLine5[1]) and IsNaN(RLine5) then 0 else if !IsNaN(RLine5) then RLine5Length[1] + 1 else 0;


#----------------------------------------------------------------------------------
RLine6 = if !IsNaN(ResistanceLevel) and RLineCount == 6 then ResistanceLevel else if !IsNaN(RLine6[1]) and max >= RLine6[1] then Double.NaN else RLine6[1];
plot RLineP6 = if RLine6 > 0 then RLine6 else Double.NaN;
RLineP6.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP6.SetDefaultColor(Color.LIGHT_RED);
RLineP6.SetHiding(Hide_Lines);
RLineP6.HideBubble();
#Cwparker23#

#----------------------------------------------------------------------------------
RLine7 = if !IsNaN(ResistanceLevel) and RLineCount == 7 then ResistanceLevel else if !IsNaN(RLine7[1]) and max >= RLine7[1] then Double.NaN else RLine7[1];
plot RLineP7 = if RLine7 > 0 then RLine7 else Double.NaN;
RLineP7.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP7.SetDefaultColor(Color.LIGHT_RED);
RLineP7.SetHiding(Hide_Lines);
RLineP7.HideBubble();

#----------------------------------------------------------------------------------
RLine8 = if !IsNaN(ResistanceLevel) and RLineCount == 8 then ResistanceLevel else if !IsNaN(RLine8[1]) and max >= RLine8[1] then Double.NaN else RLine8[1];
plot RLineP8 = if RLine8 > 0 then RLine8 else Double.NaN;
RLineP8.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP8.SetDefaultColor(Color.LIGHT_RED);
RLineP8.SetHiding(Hide_Lines);
RLineP8.HideBubble();

#----------------------------------------------------------------------------------
RLine9 = if !IsNaN(ResistanceLevel) and RLineCount == 9 then ResistanceLevel else if !IsNaN(RLine9[1]) and max >= RLine9[1] then Double.NaN else RLine9[1];
plot RLineP9 = if RLine9 > 0 then RLine9 else Double.NaN;
RLineP9.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP9.SetDefaultColor(Color.LIGHT_RED);
RLineP9.SetHiding(Hide_Lines);
RLineP9.HideBubble();

#----------------------------------------------------------------------------------
RLine10 = if !IsNaN(ResistanceLevel) and RLineCount == 10 then ResistanceLevel else if !IsNaN(RLine10[1]) and max >= RLine10[1] then Double.NaN else RLine10[1];
plot RLineP10 = if RLine10 > 0 then RLine10 else Double.NaN;
RLineP10.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP10.SetDefaultColor(Color.LIGHT_RED);
RLineP10.SetHiding(Hide_Lines);
RLineP10.HideBubble();

#----------------------------------------------------------------------------------
RLine11 = if !IsNaN(ResistanceLevel) and RLineCount == 11 then ResistanceLevel else if !IsNaN(RLine11[1]) and max >= RLine11[1] then Double.NaN else RLine11[1];
plot RLineP11 = if RLine11 > 0 then RLine11 else Double.NaN;
RLineP11.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP11.SetDefaultColor(Color.LIGHT_RED);
RLineP11.SetHiding(Hide_Lines);
RLineP11.HideBubble();

#----------------------------------------------------------------------------------
RLine12 = if !IsNaN(ResistanceLevel) and RLineCount == 12 then ResistanceLevel else if !IsNaN(RLine12[1]) and max >= RLine12[1] then Double.NaN else RLine12[1];
plot RLineP12 = if RLine12 > 0 then RLine12 else Double.NaN;
RLineP12.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP12.SetDefaultColor(Color.LIGHT_RED);
RLineP12.SetHiding(Hide_Lines);
RLineP12.HideBubble();

#----------------------------------------------------------------------------------
RLine13 = if !IsNaN(ResistanceLevel) and RLineCount == 13 then ResistanceLevel else if !IsNaN(RLine13[1]) and max >= RLine13[1] then Double.NaN else RLine13[1];
plot RLineP13 = if RLine13 > 0 then RLine13 else Double.NaN;
RLineP13.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP13.SetDefaultColor(Color.LIGHT_RED);
RLineP13.SetHiding(Hide_Lines);
RLineP13.HideBubble();

#----------------------------------------------------------------------------------
RLine14 = if !IsNaN(ResistanceLevel) and RLineCount == 14 then ResistanceLevel else if !IsNaN(RLine14[1]) and max >= RLine14[1] then Double.NaN else RLine14[1];
plot RLineP14 = if RLine14 > 0 then RLine14 else Double.NaN;
RLineP14.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP14.SetDefaultColor(Color.LIGHT_RED);
RLineP14.SetHiding(Hide_Lines);
RLineP14.HideBubble();

#----------------------------------------------------------------------------------
RLine15 = if !IsNaN(ResistanceLevel) and RLineCount == 15 then ResistanceLevel else if !IsNaN(RLine15[1]) and max >= RLine15[1] then Double.NaN else RLine15[1];
plot RLineP15 = if RLine15 > 0 then RLine15 else Double.NaN;
RLineP15.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP15.SetDefaultColor(Color.LIGHT_RED);
RLineP15.SetHiding(Hide_Lines);
RLineP15.HideBubble();

#----------------------------------------------------------------------------------
RLine16 = if !IsNaN(ResistanceLevel) and RLineCount == 16 then ResistanceLevel else if !IsNaN(RLine16[1]) and max >= RLine16[1] then Double.NaN else RLine16[1];
plot RLineP16 = if RLine16 > 0 then RLine16 else Double.NaN;
RLineP16.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP16.SetDefaultColor(Color.LIGHT_RED);
RLineP16.SetHiding(Hide_Lines);
RLineP16.HideBubble();


#----------------------------------------------------------------------------------
RLine17 = if !IsNaN(ResistanceLevel) and RLineCount == 17 then ResistanceLevel else if !IsNaN(RLine17[1]) and max >= RLine17[1] then Double.NaN else RLine17[1];
plot RLineP17 = if RLine17 > 0 then RLine17 else Double.NaN;
RLineP17.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP17.SetDefaultColor(Color.LIGHT_RED);
RLineP17.SetHiding(Hide_Lines);
RLineP17.HideBubble();

#----------------------------------------------------------------------------------
RLine18 = if !IsNaN(ResistanceLevel) and RLineCount == 18 then ResistanceLevel else if !IsNaN(RLine18[1]) and max >= RLine18[1] then Double.NaN else RLine18[1];
plot RLineP18 = if RLine18 > 0 then RLine18 else Double.NaN;
RLineP18.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP18.SetDefaultColor(Color.LIGHT_RED);
RLineP18.SetHiding(Hide_Lines);
RLineP18.HideBubble();

#----------------------------------------------------------------------------------
RLine19 = if !IsNaN(ResistanceLevel) and RLineCount == 19 then ResistanceLevel else if !IsNaN(RLine19[1]) and max >= RLine19[1] then Double.NaN else RLine19[1];
plot RLineP19 = if RLine19 > 0 then RLine19 else Double.NaN;
RLineP19.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP19.SetDefaultColor(Color.LIGHT_RED);
RLineP19.SetHiding(Hide_Lines);
RLineP19.HideBubble();

#----------------------------------------------------------------------------------
RLine20 = if !IsNaN(ResistanceLevel) and RLineCount == 20 then ResistanceLevel else if !IsNaN(RLine20[1]) and max >= RLine20[1] then Double.NaN else RLine20[1];
plot RLineP20 = if RLine20 > 0 then RLine20 else Double.NaN;
RLineP20.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP20.SetDefaultColor(Color.LIGHT_RED);
RLineP20.SetHiding(Hide_Lines);
RLineP20.HideBubble();
 
Take it for test run

Code:
def o = open;
def h = high;
def l = low;
def c = close;
def max = max(o, c);
def min = min(o, c);



input Hide_Main_Cloud = NO;
input Hide_Main_Lines = YES;
input Hide_Lines = NO;
DefineGlobalColor("sup", Color.lIGHT_GREEN);
DefineGlobalColor("res", Color.LIGHT_RED);

input HideCloud = NO;



DefineGlobalColor("Support", Color.green);
DefineGlobalColor("Resistance", Color.red);

#--------------------------------------------------------------


def Highest = if high[-1] is less than high && high[1] is less than high then high else Double.NaN;
plot HH = Highest;
HH.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
HH.SetLineWeight(1);
HH.SetDefaultColor(Color.DOWNTICK);

def Lowest = if low[-1] is greater than low && low[1] is greater than low then low else Double.NaN;
plot LL = Lowest;
LL.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
LL.SetLineWeight(1);
LL.SetDefaultColor(Color.UPTICK);

def HighestCounter = CompoundValue(1, if !IsNaN(Highest) then HighestCounter[1] + 1 else HighestCounter[1], 0);
def LowestCounter = CompoundValue(1, if !IsNaN(Lowest) then LowestCounter[1] + 1 else LowestCounter[1], 0);

script Line {
    input Counter = 0;
    input Count = 0;
    input value = 0;

    def L = if Counter == HighestAll(Counter) - (Count - 1)
            and GetValue(Counter,1) <> Counter
            then value
            else L[1];
    plot Line = L;
    }

plot HH1P = if Line(HighestCounter,1,high) then Line(HighestCounter,1,high) else Double.NaN;

plot LL1P = if Line(LowestCounter,1,low) then Line(LowestCounter,1,low) else Double.NaN;



#--------------------------------------------------------------



#-------------------------- Support Levels --------------------------------------------------#

plot SupportLevel =
if Lowest  then low else Double.NaN;
supportLevel.SetDefaultColor(Color.green);

def SLine0;
def SLine1;
def SLine2;
def SLine3;
def SLine4;
def SLine5;
def SLine6;
def SLine7;
def SLine8;
def SLine9;
def SLine10;
def SLine11;
def SLine12;
def SLine13;
def SLine14;
def SLine15;
def SLine16;
def SLine17;
def SLine18;
def SLine19;
def SLine20;
#Cwparker23#
def SLineCount;
If SupportLevel == 1 { SLineCount = 1;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine1[1]) and min<=SLine1[1]) { SLineCount=0;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine2[1]) and min<=SLine2[1]) { SLineCount=1;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine3[1]) and min<=SLine3[1]) { SLineCount=2;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine4[1]) and min<=SLine4[1]) { SLineCount=3;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine5[1]) and min<=SLine5[1]) { SLineCount=4;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine6[1]) and min<=SLine6[1]) { SLineCount=5;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine7[1]) and min<=SLine7[1]) { SLineCount=6;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine8[1]) and min<=SLine8[1]) { SLineCount=7;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine9[1]) and min<=SLine9[1]) { SLineCount=8;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine10[1]) and min<=SLine10[1]) { SLineCount=9;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine11[1]) and min<=SLine11[1]) { SLineCount=10;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine12[1]) and min<=SLine12[1]) { SLineCount=11;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine13[1]) and min<=SLine13[1]) { SLineCount=12;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine14[1]) and min<=SLine14[1]) { SLineCount=13;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine15[1]) and min<=SLine15[1]) { SLineCount=14;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine16[1]) and min<=SLine16[1]) { SLineCount=15;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine17[1]) and min<=SLine17[1]) { SLineCount=16;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine18[1]) and min<=SLine18[1]) { SLineCount=17;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine19[1]) and min<=SLine19[1]) { SLineCount=18;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine20[1]) and min<=SLine20[1]) { SLineCount=19;
}else if (IsNaN(SupportLevel) and !IsNaN(SLine0[1]) and min<=SLine0[1]) { SLineCount=20;

}else if (!IsNaN(SupportLevel) and !IsNaN(SLine0[1]) and min<=SLine0[1]) { SLineCount=0;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine1[1]) and min<=SLine1[1]) { SLineCount=1;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine2[1]) and min<=SLine2[1]) { SLineCount=2;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine3[1]) and min<=SLine3[1]) { SLineCount=3;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine4[1]) and min<=SLine4[1]) { SLineCount=4;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine5[1]) and min<=SLine5[1]) { SLineCount=5;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine6[1]) and min<=SLine6[1]) { SLineCount=6;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine7[1]) and min<=SLine7[1]) { SLineCount=7;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine8[1]) and min<=SLine8[1]) { SLineCount=8;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine9[1]) and min<=SLine9[1]) { SLineCount=9;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine10[1]) and min<=SLine10[1]) { SLineCount=10;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine11[1]) and min<=SLine11[1]) { SLineCount=11;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine12[1]) and min<=SLine12[1]) { SLineCount=12;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine13[1]) and min<=SLine13[1]) { SLineCount=13;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine14[1]) and min<=SLine14[1]) { SLineCount=14;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine15[1]) and min<=SLine15[1]) { SLineCount=15;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine16[1]) and min<=SLine16[1]) { SLineCount=16;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine17[1]) and min<=SLine17[1]) { SLineCount=17;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine18[1]) and min<=SLine18[1]) { SLineCount=18;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine19[1]) and min<=SLine19[1]) { SLineCount=19;
}else if (!IsNaN(SupportLevel) and !IsNaN(SLine20[1]) and min<=SLine20[1]) { SLineCount=20;
}else if (!IsNaN(SupportLevel)) and SLineCount[1]!=20 { SLineCount = SLineCount[1] + 1;
}else if (IsNaN(SupportLevel)) and SLineCount[1]==20 { SLineCount = 0;
} else { SLineCount = SLineCount[1];
}
#Cwparker23#
#============================================================================================#
SLine0 = if !IsNaN(SupportLevel) and SLineCount == 0 then SupportLevel else if !IsNaN(SLine0[1]) and min <= SLine0[1] then 0 else SLine0[1];
plot SLineP0 = if SLine0 > 0 then SLine0 else Double.NaN;
SLineP0.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP0.SetDefaultColor(Color.LIGHT_GREEN);
SLineP0.SetHiding(Hide_Lines);
SLineP0.HideBubble();
#Cwparker23#


#----------------------------------------------------------------------------------
SLine1 = if !IsNaN(SupportLevel) and SLineCount == 1 then SupportLevel else if !IsNaN(SLine1[1]) and min <= SLine1[1] then 0 else SLine1[1];
plot SLineP1 = if SLine1 > 0 then SLine1 else Double.NaN;
SLineP1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP1.SetDefaultColor(Color.LIGHT_GREEN);
SLineP1.SetHiding(Hide_Lines);
SLineP1.HideBubble();

#----------------------------------------------------------------------------------
SLine2 = if !IsNaN(SupportLevel) and SLineCount == 2 then SupportLevel else if !IsNaN(SLine2[1]) and min <= SLine2[1] then 0 else SLine2[1];
plot SLineP2 = if SLine2 > 0 then SLine2 else Double.NaN;
SLineP2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP2.SetDefaultColor(Color.LIGHT_GREEN);
SLineP2.SetHiding(Hide_Lines);
SLineP2.HideBubble();
#Cwparker23#

#----------------------------------------------------------------------------------
SLine3 = if !IsNaN(SupportLevel) and SLineCount == 3 then SupportLevel else if !IsNaN(SLine3[1]) and min <= SLine3[1] then 0 else SLine3[1];
plot SLineP3 = if SLine3 > 0 then SLine3 else Double.NaN;
SLineP3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP3.SetDefaultColor(Color.LIGHT_GREEN);
SLineP3.SetHiding(Hide_Lines);
SLineP3.HideBubble();

#----------------------------------------------------------------------------------
SLine4 = if !IsNaN(SupportLevel) and SLineCount == 4 then SupportLevel else if !IsNaN(SLine4[1]) and min <= SLine4[1] then 0 else SLine4[1];
plot SLineP4 = if SLine4 > 0 then SLine4 else Double.NaN;
SLineP4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP4.SetDefaultColor(Color.LIGHT_GREEN);
SLineP4.SetHiding(Hide_Lines);
SLineP4.HideBubble();
def SLine4Length = if SLine4 != SLine4[1] then 1 else if !IsNaN(SLine4[1]) and IsNaN(SLine4) then 0 else if !IsNaN(SLine4) then SLine4Length[1] + 1 else 0;


#----------------------------------------------------------------------------------
SLine5 = if !IsNaN(SupportLevel) and SLineCount == 5 then SupportLevel else if !IsNaN(SLine5[1]) and min <= SLine5[1] then 0 else SLine5[1];
plot SLineP5 = if SLine5 > 0 then SLine5 else Double.NaN;
SLineP5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP5.SetDefaultColor(Color.LIGHT_GREEN);
SLineP5.SetHiding(Hide_Lines);
SLineP5.HideBubble();

#----------------------------------------------------------------------------------
SLine6 = if !IsNaN(SupportLevel) and SLineCount == 6 then SupportLevel else if !IsNaN(SLine6[1]) and min <= SLine6[1] then 0 else SLine6[1];
plot SLineP6 = if SLine6 > 0 then SLine6 else Double.NaN;
SLineP6.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP6.SetDefaultColor(Color.LIGHT_GREEN);
SLineP6.SetHiding(Hide_Lines);
SLineP6.HideBubble();
#Cwparker23#

#----------------------------------------------------------------------------------
SLine7 = if !IsNaN(SupportLevel) and SLineCount == 7 then SupportLevel else if !IsNaN(SLine7[1]) and min <= SLine7[1] then 0 else SLine7[1];
plot SLineP7 = if SLine7 > 0 then SLine7 else Double.NaN;
SLineP7.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP7.SetDefaultColor(Color.LIGHT_GREEN);
SLineP7.SetHiding(Hide_Lines);
SLineP7.HideBubble();

#----------------------------------------------------------------------------------
SLine8 = if !IsNaN(SupportLevel) and SLineCount == 8 then SupportLevel else if !IsNaN(SLine8[1]) and min <= SLine8[1] then 0 else SLine8[1];
plot SLineP8 = if SLine8 > 0 then SLine8 else Double.NaN;
SLineP8.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP8.SetDefaultColor(Color.LIGHT_GREEN);
SLineP8.SetHiding(Hide_Lines);
SLineP8.HideBubble();

#----------------------------------------------------------------------------------
SLine9 = if !IsNaN(SupportLevel) and SLineCount == 9 then SupportLevel else if !IsNaN(SLine9[1]) and min <= SLine9[1] then 0 else SLine9[1];
plot SLineP9 = if SLine9 > 0 then SLine9 else Double.NaN;
SLineP9.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP9.SetDefaultColor(Color.LIGHT_GREEN);
SLineP9.SetHiding(Hide_Lines);
SLineP9.HideBubble();

#----------------------------------------------------------------------------------
SLine10 = if !IsNaN(SupportLevel) and SLineCount == 10 then SupportLevel else if !IsNaN(SLine10[1]) and min <= SLine10[1] then 0 else SLine10[1];
plot SLineP10 = if SLine10 > 0 then SLine10 else Double.NaN;
SLineP10.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP10.SetDefaultColor(Color.LIGHT_GREEN);
SLineP10.SetHiding(Hide_Lines);
SLineP10.HideBubble();

#----------------------------------------------------------------------------------
SLine11 = if !IsNaN(SupportLevel) and SLineCount == 11 then SupportLevel else if !IsNaN(SLine11[1]) and min <= SLine11[1] then 0 else SLine11[1];
plot SLineP11 = if SLine11 > 0 then SLine11 else Double.NaN;
SLineP11.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP11.SetDefaultColor(Color.LIGHT_GREEN);
SLineP11.SetHiding(Hide_Lines);
SLineP11.HideBubble();

#----------------------------------------------------------------------------------
SLine12 = if !IsNaN(SupportLevel) and SLineCount == 12 then SupportLevel else if !IsNaN(SLine12[1]) and min <= SLine12[1] then 0 else SLine12[1];
plot SLineP12 = if SLine12 > 0 then SLine12 else Double.NaN;
SLineP12.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP12.SetDefaultColor(Color.LIGHT_GREEN);
SLineP12.SetHiding(Hide_Lines);
SLineP12.HideBubble();
#Cwparker23#

#----------------------------------------------------------------------------------
SLine13 = if !IsNaN(SupportLevel) and SLineCount == 13 then SupportLevel else if !IsNaN(SLine13[1]) and min <= SLine13[1] then 0 else SLine13[1];
plot SLineP13 = if SLine13 > 0 then SLine13 else Double.NaN;
SLineP13.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP13.SetDefaultColor(Color.LIGHT_GREEN);
SLineP13.SetHiding(Hide_Lines);
SLineP13.HideBubble();

#----------------------------------------------------------------------------------
SLine14 = if !IsNaN(SupportLevel) and SLineCount == 14 then SupportLevel else if !IsNaN(SLine14[1]) and min <= SLine14[1] then 0 else SLine14[1];
plot SLineP14 = if SLine14 > 0 then SLine14 else Double.NaN;
SLineP14.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP14.SetDefaultColor(Color.LIGHT_GREEN);
SLineP14.SetHiding(Hide_Lines);
SLineP14.HideBubble();


#----------------------------------------------------------------------------------
SLine15 = if !IsNaN(SupportLevel) and SLineCount == 15 then SupportLevel else if !IsNaN(SLine15[1]) and min <= SLine15[1] then 0 else SLine15[1];
plot SLineP15 = if SLine15 > 0 then SLine15 else Double.NaN;
SLineP15.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP15.SetDefaultColor(Color.LIGHT_GREEN);
SLineP15.SetHiding(Hide_Lines);
SLineP15.HideBubble();


#----------------------------------------------------------------------------------
SLine16 = if !IsNaN(SupportLevel) and SLineCount == 16 then SupportLevel else if !IsNaN(SLine16[1]) and min <= SLine16[1] then 0 else SLine16[1];
plot SLineP16 = if SLine16 > 0 then SLine16 else Double.NaN;
SLineP16.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP16.SetDefaultColor(Color.LIGHT_GREEN);
SLineP16.SetHiding(Hide_Lines);
SLineP16.HideBubble();

#----------------------------------------------------------------------------------
SLine17 = if !IsNaN(SupportLevel) and SLineCount == 17 then SupportLevel else if !IsNaN(SLine17[1]) and min <= SLine17[1] then 0 else SLine17[1];
plot SLineP17 = if SLine17 > 0 then SLine17 else Double.NaN;
SLineP17.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP17.SetDefaultColor(Color.LIGHT_GREEN);
SLineP17.SetHiding(Hide_Lines);
SLineP17.HideBubble();


#----------------------------------------------------------------------------------
SLine18 = if !IsNaN(SupportLevel) and SLineCount == 18 then SupportLevel else if !IsNaN(SLine18[1]) and min < SLine18[1] then 0 else SLine18[1];
plot SLineP18 = if SLine18 > 0 then SLine18 else Double.NaN;
SLineP18.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP18.SetDefaultColor(Color.LIGHT_GREEN);
SLineP18.SetHiding(Hide_Lines);
SLineP18.HideBubble();
#Cwparker23#

#----------------------------------------------------------------------------------
SLine19 = if !IsNaN(SupportLevel) and SLineCount == 19 then SupportLevel else if !IsNaN(SLine19[1]) and min <= SLine19[1] then 0 else SLine19[1];
plot SLineP19 = if SLine19 > 0 then SLine19 else Double.NaN;
SLineP19.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP19.SetDefaultColor(Color.LIGHT_GREEN);
SLineP19.SetHiding(Hide_Lines);
SLineP19.HideBubble();


#----------------------------------------------------------------------------------
SLine20 = if !IsNaN(SupportLevel) and SLineCount == 20 then SupportLevel else if !IsNaN(SLine20[1]) and min <= SLine20[1] then 0 else SLine20[1];
plot SLineP20 = if SLine20 > 0 then SLine20 else Double.NaN;
SLineP20.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SLineP20.SetDefaultColor(Color.LIGHT_GREEN);
SLineP20.SetHiding(Hide_Lines);
SLineP20.HideBubble();





#Definitons of Resistance Levels.#####################################################
######################################################################################
plot ResistanceLevel = if Highest then high else Double.NaN;
resistanceLevel.SetDefaultColor(Color.RED);

def RLine0;
def RLine1;
def RLine2;
def RLine3;
def RLine4;
def RLine5;
def RLine6;
def RLine7;
def RLine8;
def RLine9;
def RLine10;
def RLine11;
def RLine12;
def RLine13;
def RLine14;
def RLine15;
def RLine16;
def RLine17;
def RLine18;
def RLine19;
def RLine20;

def RLineCount;
If ResistanceLevel == 1 { RLineCount = 1;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine1[1]) and max>=RLine1[1]) { RLineCount=0;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine2[1]) and max>=RLine2[1]) { RLineCount=1;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine3[1]) and max>=RLine3[1]) { RLineCount=2;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine4[1]) and max>=RLine4[1]) { RLineCount=3;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine5[1]) and max>=RLine5[1]) { RLineCount=4;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine6[1]) and max>=RLine6[1]) { RLineCount=5;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine7[1]) and max>=RLine7[1]) { RLineCount=6;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine8[1]) and max>=RLine8[1]) { RLineCount=7;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine9[1]) and max>=RLine9[1]) { RLineCount=8;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine10[1]) and max>=RLine10[1]) { RLineCount=9;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine11[1]) and max>=RLine11[1]) { RLineCount=10;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine12[1]) and max>=RLine12[1]) { RLineCount=11;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine13[1]) and max>=RLine13[1]) { RLineCount=12;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine14[1]) and max>=RLine14[1]) { RLineCount=13;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine15[1]) and max>=RLine15[1]) { RLineCount=14;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine16[1]) and max>=RLine16[1]) { RLineCount=15;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine17[1]) and max>=RLine17[1]) { RLineCount=16;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine18[1]) and max>=RLine18[1]) { RLineCount=17;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine19[1]) and max>=RLine19[1]) { RLineCount=18;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine20[1]) and max>=RLine20[1]) { RLineCount=19;
}else if (IsNaN(ResistanceLevel) and !IsNaN(RLine0[1]) and max>=RLine0[1]) { RLineCount=20;

}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine0[1]) and max>=RLine0[1]) { RLineCount=0;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine1[1]) and max>=RLine1[1]) { RLineCount=1;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine2[1]) and max>=RLine2[1]) { RLineCount=2;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine3[1]) and max>=RLine3[1]) { RLineCount=3;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine4[1]) and max>=RLine4[1]) { RLineCount=4;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine5[1]) and max>=RLine5[1]) { RLineCount=5;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine6[1]) and max>=RLine6[1]) { RLineCount=6;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine7[1]) and max>=RLine7[1]) { RLineCount=7;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine8[1]) and max>=RLine8[1]) { RLineCount=8;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine9[1]) and max>=RLine9[1]) { RLineCount=9;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine10[1]) and max>=RLine10[1]) { RLineCount=10;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine11[1]) and max>=RLine11[1]) { RLineCount=11;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine12[1]) and max>=RLine12[1]) { RLineCount=12;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine13[1]) and max>=RLine13[1]) { RLineCount=13;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine14[1]) and max>=RLine14[1]) { RLineCount=14;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine15[1]) and max>=RLine15[1]) { RLineCount=15;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine16[1]) and max>=RLine16[1]) { RLineCount=16;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine17[1]) and max>=RLine17[1]) { RLineCount=17;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine18[1]) and max>=RLine18[1]) { RLineCount=18;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine19[1]) and max>=RLine19[1]) { RLineCount=19;
}else if (!IsNaN(ResistanceLevel) and !IsNaN(RLine20[1]) and max>=RLine20[1]) { RLineCount=20;
}else if (!IsNaN(ResistanceLevel)) and RLineCount[1]!=20 { RLineCount = RLineCount[1] + 1;
}else if (!IsNaN(ResistanceLevel)) and RLineCount[1]==20 { RLineCount = 0;
} else {
    RLineCount = RLineCount[1];
}

#-------------------------- Resistance Levels ----------------------------------------------

RLine0 = if !IsNaN(ResistanceLevel) and RLineCount == 0 then ResistanceLevel else if !IsNaN(RLine0[1]) and max >= RLine0[1] then Double.NaN else RLine0[1];
plot RLineP0 = if RLine0 > 0 then RLine0 else Double.NaN;
RLineP0.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP0.SetDefaultColor(Color.LIGHT_RED);
RLineP0.SetHiding(Hide_Lines);
RLineP0.HideBubble();
def RLine0Length = if RLine0 != RLine0[1] then 1 else if !IsNaN(RLine0[1]) and IsNaN(RLine0) then 0 else if !IsNaN(RLine0) then RLine0Length[1] + 1 else 0;

#----------------------------------------------------------------------------------
RLine1 = if !IsNaN(ResistanceLevel) and RLineCount == 1 then ResistanceLevel else if !IsNaN(RLine1[1]) and max >= RLine1[1] then Double.NaN else RLine1[1];
plot RLineP1 = if RLine1 > 0 then RLine1 else Double.NaN;
RLineP1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP1.SetDefaultColor(Color.LIGHT_RED);
RLineP1.SetHiding(Hide_Lines);
RLineP1.HideBubble();
def RLine1Length = if RLine1 != RLine1[1] then 1 else if !IsNaN(RLine1[1]) and IsNaN(RLine1) then 0 else if !IsNaN(RLine1) then RLine1Length[1] + 1 else 0;

#----------------------------------------------------------------------------------
RLine2 = if !IsNaN(ResistanceLevel) and RLineCount == 2 then ResistanceLevel else if !IsNaN(RLine2[1]) and max >= RLine2[1] then Double.NaN else RLine2[1];
plot RLineP2 = if RLine2 > 0 then RLine2 else Double.NaN;
RLineP2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP2.SetDefaultColor(Color.LIGHT_RED);
RLineP2.SetHiding(Hide_Lines);
RLineP2.HideBubble();
def RLine2Length = if RLine2 != RLine2[1] then 1 else if !IsNaN(RLine2[1]) and IsNaN(RLine2) then 0 else if !IsNaN(RLine2) then RLine2Length[1] + 1 else 0;

#----------------------------------------------------------------------------------
RLine3 = if !IsNaN(ResistanceLevel) and RLineCount == 3 then ResistanceLevel else if !IsNaN(RLine3[1]) and max >= RLine3[1] then Double.NaN else RLine3[1];
plot RLineP3 = if RLine3 > 0 then RLine3 else Double.NaN;
RLineP3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP3.SetDefaultColor(Color.LIGHT_RED);
RLineP3.SetHiding(Hide_Lines);
RLineP3.HideBubble();
def RLine3Length = if RLine3 != RLine3[1] then 1 else if !IsNaN(RLine3[1]) and IsNaN(RLine3) then 0 else if !IsNaN(RLine3) then RLine3Length[1] + 1 else 0;

#----------------------------------------------------------------------------------
RLine4 = if !IsNaN(ResistanceLevel) and RLineCount == 4 then ResistanceLevel else if !IsNaN(RLine4[1]) and max >= RLine4[1] then Double.NaN else RLine4[1];
plot RLineP4 = if RLine4 > 0 then RLine4 else Double.NaN;
RLineP4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP4.SetDefaultColor(Color.LIGHT_RED);
RLineP4.SetHiding(Hide_Lines);
RLineP4.HideBubble();
def RLine4Length = if RLine4 != RLine4[1] then 1 else if !IsNaN(RLine4[1]) and IsNaN(RLine4) then 0 else if !IsNaN(RLine4) then RLine4Length[1] + 1 else 0;

#----------------------------------------------------------------------------------
RLine5 = if !IsNaN(ResistanceLevel) and RLineCount == 5 then ResistanceLevel else if !IsNaN(RLine5[1]) and max >= RLine5[1] then Double.NaN else RLine5[1];
plot RLineP5 = if RLine5 > 0 then RLine5 else Double.NaN;
RLineP5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP5.SetDefaultColor(Color.LIGHT_RED);
RLineP5.SetHiding(Hide_Lines);
RLineP5.HideBubble();
def RLine5Length = if RLine5 != RLine5[1] then 1 else if !IsNaN(RLine5[1]) and IsNaN(RLine5) then 0 else if !IsNaN(RLine5) then RLine5Length[1] + 1 else 0;


#----------------------------------------------------------------------------------
RLine6 = if !IsNaN(ResistanceLevel) and RLineCount == 6 then ResistanceLevel else if !IsNaN(RLine6[1]) and max >= RLine6[1] then Double.NaN else RLine6[1];
plot RLineP6 = if RLine6 > 0 then RLine6 else Double.NaN;
RLineP6.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP6.SetDefaultColor(Color.LIGHT_RED);
RLineP6.SetHiding(Hide_Lines);
RLineP6.HideBubble();
#Cwparker23#

#----------------------------------------------------------------------------------
RLine7 = if !IsNaN(ResistanceLevel) and RLineCount == 7 then ResistanceLevel else if !IsNaN(RLine7[1]) and max >= RLine7[1] then Double.NaN else RLine7[1];
plot RLineP7 = if RLine7 > 0 then RLine7 else Double.NaN;
RLineP7.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP7.SetDefaultColor(Color.LIGHT_RED);
RLineP7.SetHiding(Hide_Lines);
RLineP7.HideBubble();

#----------------------------------------------------------------------------------
RLine8 = if !IsNaN(ResistanceLevel) and RLineCount == 8 then ResistanceLevel else if !IsNaN(RLine8[1]) and max >= RLine8[1] then Double.NaN else RLine8[1];
plot RLineP8 = if RLine8 > 0 then RLine8 else Double.NaN;
RLineP8.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP8.SetDefaultColor(Color.LIGHT_RED);
RLineP8.SetHiding(Hide_Lines);
RLineP8.HideBubble();

#----------------------------------------------------------------------------------
RLine9 = if !IsNaN(ResistanceLevel) and RLineCount == 9 then ResistanceLevel else if !IsNaN(RLine9[1]) and max >= RLine9[1] then Double.NaN else RLine9[1];
plot RLineP9 = if RLine9 > 0 then RLine9 else Double.NaN;
RLineP9.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP9.SetDefaultColor(Color.LIGHT_RED);
RLineP9.SetHiding(Hide_Lines);
RLineP9.HideBubble();

#----------------------------------------------------------------------------------
RLine10 = if !IsNaN(ResistanceLevel) and RLineCount == 10 then ResistanceLevel else if !IsNaN(RLine10[1]) and max >= RLine10[1] then Double.NaN else RLine10[1];
plot RLineP10 = if RLine10 > 0 then RLine10 else Double.NaN;
RLineP10.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP10.SetDefaultColor(Color.LIGHT_RED);
RLineP10.SetHiding(Hide_Lines);
RLineP10.HideBubble();

#----------------------------------------------------------------------------------
RLine11 = if !IsNaN(ResistanceLevel) and RLineCount == 11 then ResistanceLevel else if !IsNaN(RLine11[1]) and max >= RLine11[1] then Double.NaN else RLine11[1];
plot RLineP11 = if RLine11 > 0 then RLine11 else Double.NaN;
RLineP11.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP11.SetDefaultColor(Color.LIGHT_RED);
RLineP11.SetHiding(Hide_Lines);
RLineP11.HideBubble();

#----------------------------------------------------------------------------------
RLine12 = if !IsNaN(ResistanceLevel) and RLineCount == 12 then ResistanceLevel else if !IsNaN(RLine12[1]) and max >= RLine12[1] then Double.NaN else RLine12[1];
plot RLineP12 = if RLine12 > 0 then RLine12 else Double.NaN;
RLineP12.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP12.SetDefaultColor(Color.LIGHT_RED);
RLineP12.SetHiding(Hide_Lines);
RLineP12.HideBubble();

#----------------------------------------------------------------------------------
RLine13 = if !IsNaN(ResistanceLevel) and RLineCount == 13 then ResistanceLevel else if !IsNaN(RLine13[1]) and max >= RLine13[1] then Double.NaN else RLine13[1];
plot RLineP13 = if RLine13 > 0 then RLine13 else Double.NaN;
RLineP13.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP13.SetDefaultColor(Color.LIGHT_RED);
RLineP13.SetHiding(Hide_Lines);
RLineP13.HideBubble();

#----------------------------------------------------------------------------------
RLine14 = if !IsNaN(ResistanceLevel) and RLineCount == 14 then ResistanceLevel else if !IsNaN(RLine14[1]) and max >= RLine14[1] then Double.NaN else RLine14[1];
plot RLineP14 = if RLine14 > 0 then RLine14 else Double.NaN;
RLineP14.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP14.SetDefaultColor(Color.LIGHT_RED);
RLineP14.SetHiding(Hide_Lines);
RLineP14.HideBubble();

#----------------------------------------------------------------------------------
RLine15 = if !IsNaN(ResistanceLevel) and RLineCount == 15 then ResistanceLevel else if !IsNaN(RLine15[1]) and max >= RLine15[1] then Double.NaN else RLine15[1];
plot RLineP15 = if RLine15 > 0 then RLine15 else Double.NaN;
RLineP15.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP15.SetDefaultColor(Color.LIGHT_RED);
RLineP15.SetHiding(Hide_Lines);
RLineP15.HideBubble();

#----------------------------------------------------------------------------------
RLine16 = if !IsNaN(ResistanceLevel) and RLineCount == 16 then ResistanceLevel else if !IsNaN(RLine16[1]) and max >= RLine16[1] then Double.NaN else RLine16[1];
plot RLineP16 = if RLine16 > 0 then RLine16 else Double.NaN;
RLineP16.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP16.SetDefaultColor(Color.LIGHT_RED);
RLineP16.SetHiding(Hide_Lines);
RLineP16.HideBubble();


#----------------------------------------------------------------------------------
RLine17 = if !IsNaN(ResistanceLevel) and RLineCount == 17 then ResistanceLevel else if !IsNaN(RLine17[1]) and max >= RLine17[1] then Double.NaN else RLine17[1];
plot RLineP17 = if RLine17 > 0 then RLine17 else Double.NaN;
RLineP17.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP17.SetDefaultColor(Color.LIGHT_RED);
RLineP17.SetHiding(Hide_Lines);
RLineP17.HideBubble();

#----------------------------------------------------------------------------------
RLine18 = if !IsNaN(ResistanceLevel) and RLineCount == 18 then ResistanceLevel else if !IsNaN(RLine18[1]) and max >= RLine18[1] then Double.NaN else RLine18[1];
plot RLineP18 = if RLine18 > 0 then RLine18 else Double.NaN;
RLineP18.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP18.SetDefaultColor(Color.LIGHT_RED);
RLineP18.SetHiding(Hide_Lines);
RLineP18.HideBubble();

#----------------------------------------------------------------------------------
RLine19 = if !IsNaN(ResistanceLevel) and RLineCount == 19 then ResistanceLevel else if !IsNaN(RLine19[1]) and max >= RLine19[1] then Double.NaN else RLine19[1];
plot RLineP19 = if RLine19 > 0 then RLine19 else Double.NaN;
RLineP19.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP19.SetDefaultColor(Color.LIGHT_RED);
RLineP19.SetHiding(Hide_Lines);
RLineP19.HideBubble();

#----------------------------------------------------------------------------------
RLine20 = if !IsNaN(ResistanceLevel) and RLineCount == 20 then ResistanceLevel else if !IsNaN(RLine20[1]) and max >= RLine20[1] then Double.NaN else RLine20[1];
plot RLineP20 = if RLine20 > 0 then RLine20 else Double.NaN;
RLineP20.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RLineP20.SetDefaultColor(Color.LIGHT_RED);
RLineP20.SetHiding(Hide_Lines);
RLineP20.HideBubble();
I appreciate the help! This looks fantastic. But is there a way to make it look cleaner? I'd like an arrow at the highest high and lowest low.

Something like this [screenshot]

Red arrows show a candle that has a lower high to the left and right and green arrows show a candle that has a higher low to the left and right.

The white arrow [manually drawn] is the code I'm looking for.
 

Attachments

  • Example.png
    Example.png
    45.4 KB · Views: 88
7N32Z0T.png

Ruby:
def Highest = if high[-1] is less than high && high[1] is less than high then high else Double.NaN;
def Lowest = if low[-1] is greater than low && low[1] is greater than low then low else Double.NaN;

def HighestBN = CompoundValue(1, if !IsNaN(Highest) then BarNumber() else HighestBN[1], 1);
def LowestBN = CompoundValue(1, if !IsNaN(Lowest) then BarNumber() else LowestBN[1], 1);

script WhiteBackCheck {
    input est = 0;
    input estBN = 0;
    input HL = 0;
    input value = 0;

def WBC = if !IsNaN(est)
        then fold bh = 1 to estBN
        with intbh = 0
        while IsNaN(GetValue(est, bh))
        do if HL then
            if GetValue(est, bh + 1) < value
            then 1
            else 0
           else       
             if GetValue(est, bh + 1) > value
            then 1   
            else 0
        else 0;
    plot WhiteBackCheck = WBC;
}

script WhiteForwardCheck {
    input est = 0;
    input estBN = 0;
    input HL = 0;
    input value = 0;

def WFC = if !IsNaN(est)
        then fold fh = 1 to estBN
        with intfh = 0
        while IsNaN(GetValue(est, -fh))
         do if HL then
            if GetValue(est, -fh - 1) < value
            then 1
            else 0
           else       
             if GetValue(est, -fh - 1) > value
            then 1   
            else 0
        else 0;
    plot WhiteForwardCheck = WFC;
}

def WHFC = WhiteForwardCheck(Highest,HighestBN,1,high);
def WHBC = WhiteBackCheck(Highest,HighestBN,1,high);

def WLFC = WhiteForwardCheck(Lowest,LowestBN,0,low);
def WLBC = WhiteBackCheck(Lowest,LowestBN,0,low);

plot HH = Highest;
HH.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
HH.SetLineWeight(1);
HH.AssignValueColor(if IsNaN(WHFC) then Color.DOWNTICK else if WHBC and WHFC then Color.WHITE else Color.DOWNTICK);

plot LL = Lowest;
LL.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
LL.SetLineWeight(1);
LL.AssignValueColor(if IsNaN(WLFC) then Color.UPTICK else if WLBC and WLFC then Color.WHITE else Color.UPTICK);

AssignPriceColor(if (WHBC and WHFC) then Color.WHITE else Color.CURRENT);
AssignPriceColor(if (WLBC and WLFC) then Color.WHITE else Color.CURRENT);
 
7N32Z0T.png

Ruby:
def Highest = if high[-1] is less than high && high[1] is less than high then high else Double.NaN;
def Lowest = if low[-1] is greater than low && low[1] is greater than low then low else Double.NaN;

def HighestBN = CompoundValue(1, if !IsNaN(Highest) then BarNumber() else HighestBN[1], 1);
def LowestBN = CompoundValue(1, if !IsNaN(Lowest) then BarNumber() else LowestBN[1], 1);

script WhiteBackCheck {
    input est = 0;
    input estBN = 0;
    input HL = 0;
    input value = 0;

def WBC = if !IsNaN(est)
        then fold bh = 1 to estBN
        with intbh = 0
        while IsNaN(GetValue(est, bh))
        do if HL then
            if GetValue(est, bh + 1) < value
            then 1
            else 0
           else      
             if GetValue(est, bh + 1) > value
            then 1  
            else 0
        else 0;
    plot WhiteBackCheck = WBC;
}

script WhiteForwardCheck {
    input est = 0;
    input estBN = 0;
    input HL = 0;
    input value = 0;

def WFC = if !IsNaN(est)
        then fold fh = 1 to estBN
        with intfh = 0
        while IsNaN(GetValue(est, -fh))
         do if HL then
            if GetValue(est, -fh - 1) < value
            then 1
            else 0
           else      
             if GetValue(est, -fh - 1) > value
            then 1  
            else 0
        else 0;
    plot WhiteForwardCheck = WFC;
}

def WHFC = WhiteForwardCheck(Highest,HighestBN,1,high);
def WHBC = WhiteBackCheck(Highest,HighestBN,1,high);

def WLFC = WhiteForwardCheck(Lowest,LowestBN,0,low);
def WLBC = WhiteBackCheck(Lowest,LowestBN,0,low);

plot HH = Highest;
HH.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
HH.SetLineWeight(1);
HH.AssignValueColor(if IsNaN(WHFC) then Color.DOWNTICK else if WHBC and WHFC then Color.WHITE else Color.DOWNTICK);

plot LL = Lowest;
LL.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
LL.SetLineWeight(1);
LL.AssignValueColor(if IsNaN(WLFC) then Color.UPTICK else if WLBC and WLFC then Color.WHITE else Color.UPTICK);

AssignPriceColor(if (WHBC and WHFC) then Color.WHITE else Color.CURRENT);
AssignPriceColor(if (WLBC and WLFC) then Color.WHITE else Color.CURRENT);
Can any one help me see why this isn't plotting anything on a time frame less than 15mins?

def open_Fifteen_min;
def high_Fifteen_min;
def low_Fifteen_min;
def close_Fifteen_min;
def Volume_Fifteen_min;

if GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN{
open_Fifteen_min = open(period = AggregationPeriod.FIFTEEN_MIN);
high_Fifteen_min = high(period = AggregationPeriod.FIFTEEN_MIN);
low_Fifteen_min = low(period = AggregationPeriod.FIFTEEN_MIN);
close_Fifteen_min = close(period = AggregationPeriod.FIFTEEN_MIN);
Volume_Fifteen_min = volume(period = AggregationPeriod.FIFTEEN_MIN);
} else {
open_Fifteen_min = Double.NaN;
high_Fifteen_min = Double.NaN;
low_Fifteen_min = Double.NaN;
close_Fifteen_min = Double.NaN;
Volume_Fifteen_min = Double.NaN;
}


def Highest = if high_Fifteen_min[-1] is less than high_Fifteen_min && high_Fifteen_min[1] is less than high_Fifteen_min then high_Fifteen_min else Double.NaN;
def Lowest = if low_Fifteen_min[-1] is greater than low_Fifteen_min && low_Fifteen_min[1] is greater than low_Fifteen_min then low_Fifteen_min else Double.NaN;

def HighestBN = CompoundValue(1, if !IsNaN(Highest) then BarNumber() else HighestBN[1], 1);
def LowestBN = CompoundValue(1, if !IsNaN(Lowest) then BarNumber() else LowestBN[1], 1);

script WhiteBackCheck {
input est = 0;
input estBN = 0;
input HL = 0;
input value = 0;

def WBC = if !IsNaN(est)
then fold bh = 1 to estBN
with intbh = 0
while IsNaN(GetValue(est, bh))
do if HL then
if GetValue(est, bh + 1) < value
then 1
else 0
else
if GetValue(est, bh + 1) > value
then 1
else 0
else 0;
plot WhiteBackCheck = WBC;
}

script WhiteForwardCheck {
input est = 0;
input estBN = 0;
input HL = 0;
input value = 0;

def WFC = if !IsNaN(est)
then fold fh = 1 to estBN
with intfh = 0
while IsNaN(GetValue(est, -fh))
do if HL then
if GetValue(est, -fh - 1) < value
then 1
else 0
else
if GetValue(est, -fh - 1) > value
then 1
else 0
else 0;
plot WhiteForwardCheck = WFC;
}

def WHFC = WhiteForwardCheck(Highest,HighestBN,1,high_Fifteen_min);
def WHBC = WhiteBackCheck(Highest,HighestBN,1,high_Fifteen_min);

Plot HH_Swing = WHFC && WHBC;
HH_Swing.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
HH_Swing.SetLineWeight(1);
HH_Swing.SetDefaultColor(color.White);


def WLFC = WhiteForwardCheck(Lowest,LowestBN,0,low_Fifteen_min);
def WLBC = WhiteBackCheck(Lowest,LowestBN,0,low_Fifteen_min);
Plot LL_Swing = WLFC && WLBC;
LL_Swing.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
LL_Swing.SetLineWeight(1);
LL_Swing.SetDefaultColor(color.White);
 
You didn't account for the lower aggregation in the definition of 'Highest and Lowest'.
This modification will work, but only on timeframes that are multiples of the aggregation used in the script. (in this case a 15 min aggregation is specified, so it will work on 1, 3, and 5 min charts)

Ruby:
def time_interval = (GetAggregationPeriod()/60000);
def zerotime = CompoundValue(1,if SecondsTillTime(0930) == 0 then 0 else zerotime[1] + GetAggregationPeriod()/60000,0);
def Fifteen_bar = (zerotime/time_interval)/((AggregationPeriod.FIFTEEN_MIN/60000)/time_interval) == Round((zerotime/time_interval)/((AggregationPeriod.FIFTEEN_MIN/60000)/time_interval),0);

def open_Fifteen_min;
def high_Fifteen_min;
def low_Fifteen_min;
def close_Fifteen_min;
def Volume_Fifteen_min;

if GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN{
open_Fifteen_min = open(period = AggregationPeriod.FIFTEEN_MIN);
high_Fifteen_min = high(period = AggregationPeriod.FIFTEEN_MIN);
low_Fifteen_min = low(period = AggregationPeriod.FIFTEEN_MIN);
close_Fifteen_min = close(period = AggregationPeriod.FIFTEEN_MIN);
Volume_Fifteen_min = volume(period = AggregationPeriod.FIFTEEN_MIN);
} else {
open_Fifteen_min = Double.NaN;
high_Fifteen_min = Double.NaN;
low_Fifteen_min = Double.NaN;
close_Fifteen_min = Double.NaN;
Volume_Fifteen_min = Double.NaN;
}

def Highest = if Fifteen_bar && high_Fifteen_min[-(AggregationPeriod.FIFTEEN_MIN/60000)/time_interval] is less than high_Fifteen_min && high_Fifteen_min[(AggregationPeriod.FIFTEEN_MIN/60000)/time_interval] is less than high_Fifteen_min then high_Fifteen_min else Double.NaN;
def Lowest = if Fifteen_bar && low_Fifteen_min[-(AggregationPeriod.FIFTEEN_MIN/60000)/time_interval] is greater than low_Fifteen_min && low_Fifteen_min[(AggregationPeriod.FIFTEEN_MIN/60000)/time_interval] is greater than low_Fifteen_min then low_Fifteen_min else Double.NaN;

def BN = AbsValue(if BarNumber()==0 then 1 else BarNumber());

script WhiteBackCheck {
input est = 0;
input estBN = 0;
input HL = 0;
input value = 0;

def WBC = if !IsNaN(est)
then fold bh = 1 to estBN
with intbh = 0
while IsNaN(GetValue(est, bh))
do if HL then
if GetValue(est, bh + 1) < value
then 1
else 0
else
if GetValue(est, bh + 1) > value
then 1
else 0
else 0;
plot WhiteBackCheck = WBC;
}

script WhiteForwardCheck {
input est = 0;
input estBN = 0;
input HL = 0;
input value = 0;

def WFC = if !IsNaN(est)
then fold fh = 1 to estBN
with intfh = 0
while IsNaN(GetValue(est, -fh))
do if HL then
if GetValue(est, -fh - 1) < value
then 1
else 0
else
if GetValue(est, -fh - 1) > value
then 1
else 0
else 0;
plot WhiteForwardCheck = WFC;
}

def WHFC = WhiteForwardCheck(Highest,BN,1,high_Fifteen_min);
def WHBC = WhiteBackCheck(Highest,BN,1,high_Fifteen_min);

Plot HH_Swing = WHFC && WHBC;
HH_Swing.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
HH_Swing.SetLineWeight(1);
HH_Swing.SetDefaultColor(color.White);


def WLFC = WhiteForwardCheck(Lowest,BN,0,low_Fifteen_min);
def WLBC = WhiteBackCheck(Lowest,BN,0,low_Fifteen_min);
Plot LL_Swing = WLFC && WLBC;
LL_Swing.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
LL_Swing.SetLineWeight(1);
LL_Swing.SetDefaultColor(color.White);
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
443 Online
Create Post

Similar threads

Similar threads

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