Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=3
- study(title = "HH LH & HL LL", shorttitle = "HH & HL", overlay = true)
- // === INPUTS ===
- ShowHHLL = input(true)
- filterBW = input(false)
- ShowFractals= input(true)
- // ||--- Fractal Recognition Functions: ---------------------------------------------------------------||
- isRegularFractal(mode) =>
- ret = mode == 1 ? high[4] < high[3] and high[3] < high[2] and high[2] > high[1] and high[1] > high[0] : mode == -1 ? low[4] > low[3] and low[3] > low[2] and low[2] < low[1] and low[1] < low[0] : false
- isBWFractal(mode) =>
- ret = mode == 1 ? high[4] < high[2] and high[3] <= high[2] and high[2] >= high[1] and high[2] > high[0] : mode == -1 ? low[4] > low[2] and low[3] >= low[2] and low[2] <= low[1] and low[2] < low[0] : false
- // ||--- Fractal Recognition:
- // ||-----------------------------------------------------------------------------------------------------||
- filteredtopf = filterBW ? isRegularFractal(1) : isBWFractal(1)
- filteredbotf = filterBW ? isRegularFractal(-1) : isBWFractal(-1)
- plotchar(ShowFractals? filteredtopf :na, char='⮝', location=location.abovebar, offset=-2, color=green, transp=75, title='Filtered Top Fractals')
- plotchar(ShowFractals? filteredbotf :na, char='⮟', location=location.belowbar, offset=-2, color=red, transp=75, title='Filtered Bottom Fractals')
- // ||--- Higher Highs, Lower Highs, Higher Lows, Lower Lows -------------------------------------------||
- higherhigh = filteredtopf == false ? false : ( valuewhen(filteredtopf == true, high[2], 1) < valuewhen(filteredtopf == true, high[2], 0) and valuewhen(filteredtopf == true, high[2], 2) < valuewhen(filteredtopf == true, high[2], 0))
- lowerhigh = filteredtopf == false ? false : ( valuewhen(filteredtopf == true, high[2], 1) > valuewhen(filteredtopf == true, high[2], 0) and valuewhen(filteredtopf == true, high[2], 2) > valuewhen(filteredtopf == true, high[2], 0))
- higherlow = filteredbotf == false ? false : ( valuewhen(filteredbotf == true, low[2], 1) < valuewhen(filteredbotf == true, low[2], 0) and valuewhen(filteredbotf == true, low[2], 2) < valuewhen(filteredbotf == true, low[2], 0))
- lowerlow = filteredbotf == false ? false : ( valuewhen(filteredbotf == true, low[2], 1) > valuewhen(filteredbotf == true, low[2], 0) and valuewhen(filteredbotf == true, low[2], 2) > valuewhen(filteredbotf == true, low[2], 0))
- plotchar(ShowHHLL ? higherhigh : na, title='Higher High', char='_', location=location.abovebar, color=red, text="[HH]", offset=-2)
- plotchar(ShowHHLL ? lowerhigh : na, title='Lower High', char='_', location=location.abovebar, color=red, text="[LH]", offset=-2)
- plotchar(ShowHHLL ? higherlow : na, title='High Low', char='_', location=location.belowbar, color=lime, text="[HL]", offset=-2)
- plotchar(ShowHHLL ? lowerlow : na, title='Lower Low', char='_', location=location.belowbar, color=lime, text="[LL]", offset=-2)
- // Volume Bars //
- length1=input(30, "Volume Bars Length", minval=1)
- avrg=sma(volume,length1)
- vold1 = volume > avrg*1.5 and close<open
- vold2 = volume >= avrg*0.5 and volume<=avrg*1.5 and close<open
- vold3 = volume < avrg *0.5 and close<open
- volu1 = volume > avrg*1.5 and close>open
- volu2 = volume >= avrg*0.5 and volume<=avrg*1.5 and close>open
- volu3 = volume< avrg*0.5 and close>open
- cold1=#800000
- cold2=#FF0000
- cold3=orange
- colu1=#006400
- colu2=lime
- colu3=#7FFFD4
- color = vold1 ? cold1 : vold2 ? cold2 : vold3 ? cold3 : volu1 ? colu1 : volu2 ? colu2 : volu3 ? colu3 : na
- barcolor(color)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement