Cribbage
Member
I made the script below using the TOS candle pattern tool to paint swing highs and lows. That is a low with two higher candles on either side of it (inverse is true for highs), forming a short-term low (STL). I'm trying to add intermediate term swing high/lows. That would be a STL with a STH on either side of it. I tried to build this by referencing the last 3 candles (down at line 50 and beyond), but it does not appear to be working, frankly, I'm not sure what its painting (all the cyan wedges). I've circled where I would like it to paint the cyan wedge based on the logic described.
Any help is appreciated!
Any help is appreciated!
Code:
#Cribbage ICT Swing Highs and Lows: 3 candle pattern 5/26/22#
#input displace = 1;
#SleepyZ Fix 5/28/22 1 of 2
input wedgemover = -1;#Hint wedgemover: increase/decrease arrowmover to move arrowmover right/left
def n = wedgemover;
def n1 = n + 1;
#SleepyZ Fix 5/28/22 1 of 2 end
#plot AvgExp = ExpAverage(price[-displace], length);
def IsUp = close > open;
def IsDown = close < open;
def IsDoji = IsDoji();
def avgRange = 0.05 * Average(high - low, 20);
#Swing Low
def SL =
(IsUp[2] or IsDown[2] or IsDoji[2]) and
(IsDown[1] or IsUp[1] or IsDoji[1]) and
(IsUp[0] or IsDown[0] or IsDoji[0]) and
low[1] < low[0] and
low[1] is equal to Lowest(low[1], 2);
#Swing High
plot SH =
(IsUp[2] or IsDown[2] or IsDoji[2]) and
(IsDown[1] or IsUp[1] or IsDoji[1]) and
(IsUp[0] or IsDown[0] or IsDoji[0]) and
high[1] > high[0] and
high[1] is equal to Highest(high[1], 2);
#SleepyZ Fix 5/28/22 2 of 2, adjusted by Cribbage to fit code
plot SHH = SH[n];
SHH.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
SHH.SetDefaultColor(Color.UPTICK);
plot SLL = SL[n];
SLL.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
SLL.SetDefaultColor(Color.DOWNTICK);
#SleepyZ Fix 5/28/22 2 of 2 end
def study = SHH;
plot ITH = Study[2] < study[1] and study[1] > study;
ITH.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
ITH.SetDefaultColor(Color.cyan);
ITH.setlineWeight(3);