How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Feature Request FAQ Help & Wiki Twitter

# [RS][GLAZ]chrislig 5day4 Oscillator V2

113 0
Request for chrislig: added 4 out of 5 extreme condition, but added it as a separate plot (blue) as it does trigger much less, let me know if you want it as a filter.
study(title="[RS][GLAZ]chrislig 5day4 Oscillator V2", shorttitle="[RS][GLAZ]chrislig 5d4O.V2",overlay=false)
//  ||---   Condition 1 : stock goes up or down 5x in a row
isup(lookback) => close[0+lookback] >= close[1+lookback] ? true : false
isdown(lookback) => close[0+lookback] <= close[1+lookback] ? true : false
condition1 = isup(0) and isup(1) and isup(2) and isup(3) and isup(4) ? 1 :
isdown(0) and isdown(1) and isdown(2) and isdown(3) and isdown(4) ? -1 : 0
bgcolor(condition1 == 1 ? green : na, transp=70)
bgcolor(condition1 == -1 ? maroon : na, transp=70)
//  ||---   Condition 2 : high of the diference of MA(200) and close
ma1 = sma(close, 200)
diference = close-ma1
difmax = highest(diference, 200)
difmin = lowest(diference, 200)
condition2 = diference >= difmax ? 1 : diference <= difmin ? -1 : 0
//  ||---   Condition 3 : 4 out of 5 extremes in a row
precounter = nz(counter[1], 0)
counter = diference >= difmax and precounter > 0 ? precounter + 1 :
diference <= difmin and precounter < 0 ? precounter - 1 :
diference >= difmax and precounter <= 0 ? 1 :
diference <= difmin and precounter >= 0 ? -1 : 0
bgcolor(counter >= 4 ? navy : counter <= -4 ? teal : na, transp=70)
//condition3 = counter >= 4 ? 1 : counter <= -4 ? -1 : 0
//  ||---   Outputs
out1 = condition1 == 1 and condition2 == 1 ? true : false
out2 = condition1 == -1 and condition2 == -1 ? true : false
plotshape(out1, style=shape.triangledown, location=location.top, color=maroon, text="SELL")
plot(diference, color=black)
plot(difmax, color=gray, style=circles, linewidth=2)
plot(difmin, color=gray, style=circles, linewidth=2)
hline(0, color=black)
United States
United Kingdom
India
España
France
Italia
Polska
Brasil
Россия
Türkiye
Indonesia

한국
Home Stock Screener Forex Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter