# Add this into the condition?

#### Trigun1127

##### Member
This isnt plotting right. Im trying to a get a dot to plot when 3 bull bars or 3 bears bars occur and there is a gap (bull open>close[1]) or (bear open<close[1] anywhere in those 3 bars.
Code:
``````def legup    = Sum(open < close, 3) == 3 and open [0] > close[1] and close > open and close[1] > open[1];
def legdn    = Sum(open > close, 3) == 3 and open [0] < close[1] and close < open and close[1] < open[1];

plot LegupStart = if !legup and !legup[-1] and legup[-2] then low else Double.NaN;
LegupStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegupStart.SetLineWeight(5);
LegupStart .SetDefaultColor(Color.WHITE);

plot LegdnStart = if !legdn and !legdn[-1] and legdn[-2] then high else Double.NaN;
LegdnStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegdnStart.SetLineWeight(5);
LegdnStart .SetDefaultColor(Color.YELLOW);``````

Solution
You've got the >'s and <'s flipped, try this:

def legup = Sum(Close > Open,3) == 3 and Sum(Open > Close[1],2);
def legdn = Sum(Close < Open,3) == 3 and Sum(Open < Close[1],2);

plot LegupStart = if !legup and !legup[-1] and legup[-2] then low else Double.NaN;
LegupStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegupStart.SetLineWeight(5);
LegupStart .SetDefaultColor(Color.WHITE);

plot LegdnStart = if !legdn and !legdn[-1] and legdn[-2] then high else Double.NaN;
LegdnStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegdnStart.SetLineWeight(5);
LegdnStart .SetDefaultColor(Color.YELLOW);

Sum(Close > Open,3) == 3 and Sum(Open > Close[1],2)

This seemed to fix some of the issues. This one isnt plotting however. Also Is it possible to have the dot always plot at the first bar of the series it seems to only plot on the Sum(Open < Close[1],2); or Sum(Open > Close[1],2);

Date/Time/5m Top Left corner of screenshot

Last edited:
That one shouldn't plot if I am understanding your question correctly, there are no gaps between the green bars in that series.

This will mark the beginning of the series.

plot x = GetValue(Sum(Close > Open,3) == 3 and Sum(Open > Close[1],2),-2);
x.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);

This will mark the first bar in the series without repeating in the same series.

def x = GetValue(Sum(Close > Open,3) == 3 and Sum(Open > Close[1],2),-2);
plot y = x and !x[1];
y.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);

Here you can see that the open of the second bar was greater then the open of the first.

I'll check it out in TOS when I get home, I'm posting from my phone. This should be very easy to resolve.

This is odd, it seems to be working fine on my end. Green is the standard version, yellow looks forward to mark the beginning of the series.

Could you post the exact code that you're using?

Code:
``````def Cond = Sum(Close > Open,3) == 3 and Sum(Open > Close[1],2);
plot x = Cond;
plot y = getvalue(Cond,-2);

x.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
x.setDefaultColor(color.green);

y.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
y.setDefaultColor(color.yellow);``````

Edit:

If you're using PaintingStrategy.POINTS, then the value you're plotting is just a string of 1's and 0's along the very bottom of your chart. You would have to actually give the plot a practical value based on the condition:

plot x = if Cond then Low else Double.NaN;

If all else fails you can code it long hand, its just a lot harder to connect it to inputs or make easy adjustments.

(Close > Open and Close[1] > Open[1] and Close[2] > Open[2]) and (Open > Close[1] or Open[1] > Close[2])

Last edited:
This is odd, it seems to be working fine on my end. Green is the standard version, yellow looks forward to mark the beginning of the series.

Could you post the exact code that you're using?

Code:
``````def Cond = Sum(Close > Open,3) == 3 and Sum(Open > Close[1],2);
plot x = Cond;
plot y = getvalue(Cond,-2);

x.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
x.setDefaultColor(color.green);

y.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
y.setDefaultColor(color.yellow);``````

Edit:

If you're using PaintingStrategy.POINTS, then the value you're plotting is just a string of 1's and 0's along the very bottom of your chart. You would have to actually give the plot a practical value based on the condition:

plot x = if Cond then Low else Double.NaN;

If all else fails you can code it long hand, its just a lot harder to connect it to inputs or make easy adjustments.

(Close > Open and Close[1] > Open[1] and Close[2] > Open[2]) and (Open > Close[1] or Open[1] > Close[2])
Hey Joshua this is the code I'm using

def legup = Sum(Close > Open,3) == 3 and Sum(Open < Close[1],2);
def legdn = Sum(Close < Open,3) == 3 and Sum(Open > Close[1],2);

plot LegupStart = if !legup and !legup[-1] and legup[-2] then low else Double.NaN;
LegupStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegupStart.SetLineWeight(5);
LegupStart .SetDefaultColor(Color.WHITE);

plot LegdnStart = if !legdn and !legdn[-1] and legdn[-2] then high else Double.NaN;
LegdnStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegdnStart.SetLineWeight(5);
LegdnStart .SetDefaultColor(Color.YELLOW);

You've got the >'s and <'s flipped, try this:

def legup = Sum(Close > Open,3) == 3 and Sum(Open > Close[1],2);
def legdn = Sum(Close < Open,3) == 3 and Sum(Open < Close[1],2);

plot LegupStart = if !legup and !legup[-1] and legup[-2] then low else Double.NaN;
LegupStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegupStart.SetLineWeight(5);
LegupStart .SetDefaultColor(Color.WHITE);

plot LegdnStart = if !legdn and !legdn[-1] and legdn[-2] then high else Double.NaN;
LegdnStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegdnStart.SetLineWeight(5);
LegdnStart .SetDefaultColor(Color.YELLOW);

I think this works! I'll keep checking throughout the day.

You've got the >'s and <'s flipped, try this:

def legup = Sum(Close > Open,3) == 3 and Sum(Open > Close[1],2);
def legdn = Sum(Close < Open,3) == 3 and Sum(Open < Close[1],2);

plot LegupStart = if !legup and !legup[-1] and legup[-2] then low else Double.NaN;
LegupStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegupStart.SetLineWeight(5);
LegupStart .SetDefaultColor(Color.WHITE);

plot LegdnStart = if !legdn and !legdn[-1] and legdn[-2] then high else Double.NaN;
LegdnStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegdnStart.SetLineWeight(5);
LegdnStart .SetDefaultColor(Color.YELLOW);

Hey Joshua Id like to add more conditions to this code but I'd like to make it where when more conditions are added to the code and each one gets fulfilled the dot color changes. Can you provide a template on how to do this? Maby even a colored dot isnt the best way to do this. I have 10 conditions that I want to add into this where each condition strengthens the context. Do you have a suggestion? I was wondering about printing instead of a dot on the first bar a Number probability based on how many conditions are met.

Im trying to add this condition in. I thought I understood the Sum function through your code but apparently not
Def CloseAboveHighs = sum(close[0]>high[1],3);
Def CloseBelowLows = sum(close[0]<low[1],3);

Trying to have the 3 bars in the series look to the prior bar make sure that the close is higher and vise versa for red bars close lower the prior low.

The code I provided is taking advantage of native data conversion, which is perhaps a more advanced topic.

It might make more sense if I had written the original like this:

def legup = Sum(Close > Open,3) == 3 and Sum(Open > Close[1],2) >= 1;
def legdn = Sum(Close < Open,3) == 3 and Sum(Open < Close[1],2) >= 1;

This time around, you would need to do this:

Def CloseAboveHighs = sum(close[0]>high[1],3) == 3;
Def CloseBelowLows = sum(close[0]<low[1],3) == 3;

As per your previous question; if all of your variables contain Yes/No answers, then they're all really just 1's or 0's.
You can very easily add them up:

Def ConditionsMet = CloseAboveHighs + LegUp + Condition3;

The code I provided is taking advantage of native data conversion, which is perhaps a more advanced topic.

It might make more sense if I had written the original like this:

def legup = Sum(Close > Open,3) == 3 and Sum(Open > Close[1],2) >= 1;
def legdn = Sum(Close < Open,3) == 3 and Sum(Open < Close[1],2) >= 1;

This time around, you would need to do this:

Def CloseAboveHighs = sum(close[0]>high[1],3) == 3;
Def CloseBelowLows = sum(close[0]<low[1],3) == 3;

As per your previous question; if all of your variables contain Yes/No answers, then they're all really just 1's or 0's.
You can very easily add them up:

Def ConditionsMet = CloseAboveHighs + LegUp + Condition3;
I apologize but really struggling. I dont know anything about coding and trying with what little I know so far. I had thought == means "not"? maby im wrong.
Heres what i have you might be able to understand what im trying to go for.
Id like for the indicator to trigger on a minimum amount of conditions fullfilled and then on top of that every condition that is met adds to the strength. I think it would be nice to have it add text maby below the dot with what i consider the probability.

Def CloseAboveHighs = sum(close[0]>high[1],3) == 3;
Def CloseBelowLows = sum(close[0]<low[1],3) == 3;
Def Mgapup = sum(close>open,3) and low>high[2]-1;
Def Mgapdn = sum(close<open,3) and high<low[2]-1;
def TGapup= Sum(Open > Close[1],2)>=1;
def Tgapdn= Sum(Open < Close[1],2)>=1;
def legup = Sum(Close > Open,3) == 3 and TGapup and CloseAboveHighs;
def legdn = Sum(Close < Open,3) == 3 and Tgapdn and CloseBelowLows;
def ConditionsMetLong = Legup + TGapup + CloseaboveHighs + Mgapup;
#Def uniform Bar Size
#Def CoH
#Def CoL
#Def BullCloseTail
#Def BearCloseTail
#Def BullOpen Tail
#Def BearOpen Tail
#Def 3BarMChannelUp
#Def 3BarMchannelDn
plot LegupStart = if !legup and !legup[-1] and legup[-2] then low else Double.NaN;
LegupStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegupStart.SetLineWeight(5);
LegupStart .SetDefaultColor(Color.WHITE);

plot LegdnStart = if !legdn and !legdn[-1] and legdn[-2] then high else Double.NaN;
LegdnStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegdnStart.SetLineWeight(5);
LegdnStart .SetDefaultColor(Color.YELLOW);

You can plot the count, and use values above for the painting strategy.
For use values below when you paint the dot at the high.
This assumes the rest of it is correct.

Code:
``````Def CloseAboveHighs = sum(close > high[1], 3) == 3;
Def CloseBelowLows = sum(close < low[1], 3) == 3;
Def Mgapup = sum(close > open, 3) == 3 and low > high[2] - 1;
Def Mgapdn = sum(close < open, 3) == 3 and high < low[2] - 1;
def TGapup= Sum(Open > Close[1],2) >= 1;
def Tgapdn= Sum(Open < Close[1],2) >= 1;
def legup = Sum(Close > Open,3) == 3 and TGapup and CloseAboveHighs;
def legdn = Sum(Close < Open,3) == 3 and Tgapdn and CloseBelowLows;
def ConditionsMetLong = Legup + TGapup + CloseaboveHighs + Mgapup;
#Def uniform Bar Size
#Def CoH
#Def CoL
#Def BullCloseTail
#Def BearCloseTail
#Def BullOpen Tail
#Def BearOpen Tail
#Def 3BarMChannelUp
#Def 3BarMchannelDn

plot CondCount = if !legup and !legup[-1] and legup[-2] then ConditionsMetLong[-2] else Double.NaN;
CondCount.setpaintingStrategy(paintingStrategy.VALUES_ABOVE);

plot LegupStart = if !legup and !legup[-1] and legup[-2] then low else Double.NaN;
LegupStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegupStart.SetLineWeight(5);
LegupStart .SetDefaultColor(Color.WHITE);

plot LegdnStart = if !legdn and !legdn[-1] and legdn[-2] then high else Double.NaN;
LegdnStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegdnStart.SetLineWeight(5);
LegdnStart .SetDefaultColor(Color.YELLOW);``````

I'm beginning to understand bit by bit.
1. can you explain to me the difference between the underlined code. What do they mean. I only have guesses.
==3;-1;=1
2. Does the code for CloseAbovehighs only make a comparison between 3 bars or does the first bar look at prior bar that is not in the sequence?
3. I'm trying to add the condition that I want certain bars to close on their high within a certain percentage. The first minimum condition I need just 1 of the 3 bars to close on their high within a given %. Then I I will add a separate condition if at least 2 bars Close on their high. this second condition just adds to probability so not a necessary condition. At least 1 bar closing on high is a a necessary condition.

Def ReqStrngCloLong = sum(close > open, 3)== 3 and close > low + (.85 * (high-low))-1;
Def CloseAboveHighs = sum(close > high[1], 3) == 3;
Def CloseBelowLows = sum(close < low[1], 3) == 3;
Def ReqMgapup = sum(close > open, 3) == 3 and low > high[2] - 1;
Def ReqMgapdn = sum(close < open, 3) == 3 and high < low[2] - 1;
def TGapup = Sum(Open > Close[1],2) >= 1;
def Tgapdn = Sum(Open < Close[1],2) >= 1;
def legup = Sum(Close > Open,3) == 3 and ReqMgapup ;
def legdn = Sum(Close < Open,3) == 3 and ReqMgapdn ;
def ConditionsMetLong = TGapup + CloseAboveHighs + ReqStrngCloLong;
def ConditionsmetShort= TGapdn + CloseBelowLows ;
#Def uniform Bar Size
#Def CoH
#Def CoL
#Def BullCloseTail
#Def BearCloseTail
#Def BullOpen Tail
#Def BearOpen Tail
#Def 3BarMChannelUp
#Def 3BarMchannelDn

plot CondCountLong = if !legup and !legup[-1] and legup[-2] then ConditionsMetLong[-2] else Double.NaN;
CondCountLong.setpaintingStrategy(paintingStrategy.VALUES_ABOVE);

plot CondCountShort = if !legdn and !legdn[-1] and legdn[-2] then ConditionsMetshort[-2] else Double.NaN;
CondCountShort.setpaintingStrategy(paintingStrategy.VALUES_BELOW);

plot LegupStart = if !legup and !legup[-1] and legup[-2] then low else Double.NaN;
LegupStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegupStart.SetLineWeight(5);
LegupStart .SetDefaultColor(Color.WHITE);

plot LegdnStart = if !legdn and !legdn[-1] and legdn[-2] then high else Double.NaN;
LegdnStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegdnStart.SetLineWeight(5);
LegdnStart .SetDefaultColor(Color.YELLOW);

Another issue I'm running into is for this code I'm making sure if there is a leg up all the the lows in that 3 bar sequences are above the prior low. I that discounts the first bar of the sequence. I don't want the first bar to compare itself outside the 3 bars. So technically its checking the second and third bar to make sure their lows are consecutively higher. Vice Versa for MchanelDn.
Heres an example

Def ReqStrngCloLong = sum(close > open, 3)== 3 and close > low + (.85 * (high-low))-1;
Def CloseAboveHighs = sum(close > high[1], 3) == 3;
Def CloseBelowLows = sum(close < low[1], 3) == 3;
Def Mchannelup = sum(low > low[1],3)>=1;
Def Mchanneldn = sum (High < high[1],3)>=1;

Def ReqMgapup = sum(close > open, 3) == 3 and low > high[2] - 1;
Def ReqMgapdn = sum(close < open, 3) == 3 and high < low[2] - 1;
def TGapup = Sum(Open > Close[1],2) >= 1;
def Tgapdn = Sum(Open < Close[1],2) >= 1;
def legup = Sum(Close > Open,3) == 3 and ReqMgapup and Mchannelup;
def legdn = Sum(Close < Open,3) == 3 and ReqMgapdn and Mchanneldn;
def ConditionsMetLong = TGapup + CloseAboveHighs ;
def ConditionsmetShort= TGapdn + CloseBelowLows ;
#Def uniform Bar Size
#Def CoH
#Def CoL
#Def BullCloseTail
#Def BearCloseTail
#Def BullOpen Tail
#Def BearOpen Tail
#Def 3BarMChannelUp
#Def 3BarMchannelDn

plot CondCountLong = if !legup and !legup[-1] and legup[-2] then ConditionsMetLong[-2] else Double.NaN;
CondCountLong.setpaintingStrategy(paintingStrategy.VALUES_ABOVE);

plot CondCountShort = if !legdn and !legdn[-1] and legdn[-2] then ConditionsMetshort[-2] else Double.NaN;
CondCountShort.setpaintingStrategy(paintingStrategy.VALUES_BELOW);

plot LegupStart = if !legup and !legup[-1] and legup[-2] then low else Double.NaN;
LegupStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegupStart.SetLineWeight(5);
LegupStart .SetDefaultColor(Color.WHITE);

plot LegdnStart = if !legdn and !legdn[-1] and legdn[-2] then high else Double.NaN;
LegdnStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegdnStart.SetLineWeight(5);
LegdnStart .SetDefaultColor(Color.YELLOW);

Any expression that contains a comparison operator will resolve to a boolean YES or NO value. YES and NO are basically just placeholders for 1 and 0 respectively. Sum(), the way we're using it here, is adding up all the 1's and 0's over a length of bars. Its just counting the number of times that the condition is true.

This means that the number of times X is greater than Y, over three bars, is equal to 3.
Sum( X>Y, 3) == 3;
It could also be written as:
X > Y and X[1] > Y[1] and X[2] > Y[2]

If you only need the condition to met at least once, you would want the total to be greater than or equal to 1.
Sum(X>Y,3) >= 1;
This could also be written as:
X > Y OR X[1] > Y[1] OR X[2] > Y[2]

Def ReqMgapup = sum(close > open, 3) == 3 and low > high[2] - 1;
I don't actually know why you put the -1 there, I was going to ask you the same thing.

Once you introduce an offset to the condition, you may or may not want to reduce the length.
It depends on your preference or intention.

Sum(X>Y[1], 3) == 3;
X > Y[1] and X[1] > Y[2] and X[2] > Y[3]

Sum(X>Y[1], 2) == 2;
X > Y[1] and X[1] > Y[2]

The top version incorporates bars 0, 1, 2, and 3, which is four bars, but only sort of.
The bottom version incorporates only bars 0, 1, and 2.

I'm heading out now though, I'll take another look later tonight.

Thank you so so much for the explanation your a very good communicator! I will play around with this info now and still love to see how you resolve things. Ill attempt to do them in the meantime.

* edit*
So far it looks like its working with the info you gave me
Def ReqStrngCloLong = sum(close > open, 3)== 3 and close > low + (.85 * (high-low))-1;
Def CloseAboveHighs = sum(close > high[1], 3) == 3;
Def CloseBelowLows = sum(close < low[1], 3) == 3;
Def Mchannelup = sum(low > low[1],3)==3;
Def Mchanneldn = sum (High < high[1],3)==3;
Def ReqMgapup = sum(close > open, 3) == 3 and low > high[2]>=1;
Def ReqMgapdn = sum(close < open, 3) == 3 and high < low[2]>=1;
def TGapup = Sum(Open > Close[1],2) >= 1;
def Tgapdn = Sum(Open < Close[1],2) >= 1;
def legup = Sum(Close > Open,3) == 3 and ReqMgapup and Mchannelup;
def legdn = Sum(Close < Open,3) == 3 and ReqMgapdn and Mchanneldn;
def ConditionsMetLong = TGapup + CloseAboveHighs + ReqMgapup + Mchannelup ;
def ConditionsmetShort= TGapdn + CloseBelowLows + ReqMgapdn + Mchanneldn;
#Def uniform Bar Size
#Def CoH
#Def CoL
#Def BullCloseTail
#Def BearCloseTail
#Def BullOpen Tail
#Def BearOpen Tail
#Def 3BarMChannelUp
#Def 3BarMchannelDn

plot CondCountLong = if !legup and !legup[-1] and legup[-2] then ConditionsMetLong[-2] else Double.NaN;
CondCountLong.setpaintingStrategy(paintingStrategy.VALUES_ABOVE);

plot CondCountShort = if !legdn and !legdn[-1] and legdn[-2] then ConditionsMetshort[-2] else Double.NaN;
CondCountShort.setpaintingStrategy(paintingStrategy.VALUES_BELOW);

plot LegupStart = if !legup and !legup[-1] and legup[-2] then low else Double.NaN;
LegupStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegupStart.SetLineWeight(5);
LegupStart .SetDefaultColor(Color.WHITE);

plot LegdnStart = if !legdn and !legdn[-1] and legdn[-2] then high else Double.NaN;
LegdnStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegdnStart.SetLineWeight(5);
LegdnStart .SetDefaultColor(Color.YELLOW);
Interesting thing ive noticed is when the conditions are True miltiple times consecutively.
such as the below example

Here 3 of the 4 conditions were met on the first bar. When a new bar is added a new string is assessed that had 4 of the conditions met and it printed 4 on the second bar. Is it possible to include the earliest conditions as well so that point is plotted there as well with 3 above it? If more conditions are added then having 4 on the next bar when its true is completely fine.

Last edited:
Here's a weird one. This one didn't plot at all and I don't see a reason for it not to.
Updated code
Def ReqStrngCloLong = sum(close > open, 3)>=1 and sum(close > low + (.85 * (high-low)),3)>=1;
Def ReqStrngCloShort = sum(close < open, 3)>=1 and sum(close < low + (.85 * (high-low)),3)>=1;
Def MostCloHigh = sum(close > open, 3)>=2 and sum(close > low + (.85 * (high-low)),3)>=2;
Def MostCloLow = sum(close < open, 3)>=2 and sum(close < low + (.85 * (high-low)),3)>=2;
Def CloseAboveHighs = sum(close > high[1], 3) == 3;
Def CloseBelowLows = sum(close < low[1], 3) == 3;
Def Mchannelup = sum(low > low[1],3)==3;
Def Mchanneldn = sum (High < high[1],3)==3;
Def ReqMgapup = sum(close > open, 3) == 3 and low > high[2]>=1;
Def ReqMgapdn = sum(close < open, 3) == 3 and high < low[2]>=1;
def TGapup = Sum(Open > Close[1],2) >= 1;
def Tgapdn = Sum(Open < Close[1],2) >= 1;
def legup = Sum(Close > Open,3) == 3 and ReqMgapup and Mchannelup;
def legdn = Sum(Close < Open,3) == 3 and ReqMgapdn and Mchanneldn;
def ConditionsMetLong = TGapup + CloseAboveHighs + ReqMgapup + Mchannelup + ReqStrngCloLong + MostCloHigh;
def ConditionsmetShort= TGapdn + CloseBelowLows + ReqMgapdn + Mchanneldn + ReqStrngCloShort + MostCloLow;

#Def uniform Bar Size
#Def BullCloseTail
#Def BearCloseTail
#Def BullOpen Tail
#Def BearOpen Tail

plot CondCountLong = if !legup and !legup[-1] and legup[-2] then ConditionsMetLong[-2] else Double.NaN;
CondCountLong.setpaintingStrategy(paintingStrategy.VALUES_ABOVE);

plot CondCountShort = if !legdn and !legdn[-1] and legdn[-2] then ConditionsMetshort[-2] else Double.NaN;
CondCountShort.setpaintingStrategy(paintingStrategy.VALUES_BELOW);

plot LegupStart = if !legup and !legup[-1] and legup[-2] then low else Double.NaN;
LegupStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegupStart.SetLineWeight(5);
LegupStart .SetDefaultColor(Color.WHITE);

plot LegdnStart = if !legdn and !legdn[-1] and legdn[-2] then high else Double.NaN;
LegdnStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegdnStart.SetLineWeight(5);
LegdnStart .SetDefaultColor(Color.YELLOW);

heres another

Last edited:

87k+ Posts
314 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?