ravi.narkilla
New member
Thanks DeusMecanicus, Would it be possible to add HH HL LL LH for this,
I have a portion of script from the old funwiththinkscript forum that might be what you are looking for. It just calculates the peaks and valleys slightly different than the programmatic support/resistance indicator.
Code:##Robert_Payne # define a peak as having a high greater than the two previous candles AND the two following candles def peak = high > highest(high[1], 2) and high > highest(high[-2], 2); # use a recursive variable to remember the peak value. # if peak conditions are met, then set the value to the current high # otherwise set the value to what it was before def PeakValue = if peak then high else PeakValue[1]; # ----- define a valley as any point which is lower than the three preceding lows and the three following lows def Valley = low < Lowest(low[1], 2) and low < Lowest(low[-2], 2); def ValleyValue = if Valley then low else ValleyValue[1]; ###Modified DeusMecanicus plot Resistance1 = PeakValue; plot Support1 = ValleyValue; def lowerresist = Resistance1 < Resistance1[1]; def highersupport = Support1 > Support1[1]; def recresist = if Resistance1 > Resistance1[1] then 0 else if lowerresist then 1 else recresist[1]; def recsupport = if Support1 < Support1[1] then 0 else if highersupport then 1 else recsupport[1]; plot insideresistance = if recresist and recsupport then Resistance1 else Double.NaN; plot insidesupport = if recsupport and recresist then Support1 else Double.NaN; #-------------------------------------------------------------- insideresistance.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); insideresistance.SetDefaultColor(Color.MAGENTA); insideresistance.SetLineWeight(5); #-------------------------------------------------------------- insidesupport.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); insidesupport.SetDefaultColor(Color.CYAN); insidesupport.SetLineWeight(5); #-------------------------------------------------------------- #-------------------------------------------------------------- Resistance1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); Resistance1.SetDefaultColor(Color.MAGENTA); #-------------------------------------------------------------- Support1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); Support1.SetDefaultColor(Color.CYAN);