RicardoSantos

[RS][GLAZ]chrislig 5day4 V2

42 0 7
request for chrislig: fixed a issue with condition3 were it was counting only highs on a row.
Remove from Favorite Scripts Add to Favorite Scripts
study(title="[RS][GLAZ]chrislig 5day4 V2", shorttitle="[RS][GLAZ]chrislig.5d4.V2", overlay=true)
//  ||---   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)
//bgcolor(condition1 == -1 ? maroon : na)
//  ||---   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
topcounter = diference >= difmax ? 1 : 0
botcounter = diference <= difmin ? 1 : 0
//bgcolor(counter >= 4 ? maroon : counter <= -4 ? green : na)
condition3 = sum(topcounter, 5) >= 4 ? 1 : sum(botcounter, 5) >= 4 ? -1 : 0
//  ||---   Outputs
out1 = condition1 == 1 and condition2 == 1 ? true : false
out2 = condition1 == -1 and condition2 == -1 ? true : false
out3 = condition3 == -1 ? true : false
out4 = condition3 == 1 ? true : false
plotshape(out1, style=shape.triangledown, location=location.abovebar, color=maroon, text="SELL")
plotshape(out2, style=shape.triangleup, location=location.belowbar, color=green, text="BUY")
plotshape(out3, style=shape.triangleup, location=location.belowbar, color=blue, text="\n C3 BUY")
plotshape(out4, style=shape.triangledown, location=location.abovebar, color=blue, text="\n C3 SELL")
United States
United Kingdom
India
Deutschland
España
France
Việt Nam
Italia
Polska
Brasil
Россия
Türkiye
Indonesia
Malaysia
日本
한국
简体
繁體
Home Stock Screener Forex Signal Finder Cryptocurrency Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Feature Request Blog & News FAQ Help & Wiki Twitter
Profile Profile Settings Account and Billing Support Priority Support Report Issue Ideas Published Followers Following Private Messages Chat Sign Out