81 1 10
4 of 5 candles bearish -> buy, bullish ->sell
Remove from Favorite Scripts Add to Favorite Scripts
study("5 candles")
sma5=sma(close,5)
sma200=sma(close,200)
bCase1=close<close[1] and close[1]<close[2] and close[2]<close[3] and close[1]<open[1] and close[2]<open[2] and close[3]<open[3] and close<sma5 and close[1]<sma5[1] and close[2]<sma5[2] and close[3]<sma5[3] and open[3]<sma5[3]
bCase2=close<close[1] and close[1]<close[2] and close[2]<close[3] and close[4]<close[5] and close[1]<open[1] and close[2]<open[2] and close[4]<open[4] and close[5]<open[5] and close<sma5 and close[1]<sma5[1] and close[2]<sma5[2] and close[3]<sma5[3] and close[4]<sma5[4] and close[5]<sma5[5] and open[5]<sma5[5]
bCase3=close<close[1] and close[1]<close[2] and close[3]<close[4] and close[4]<close[5] and close<open  and close[1]<open[1] and close[3]<open[3]  and close[4]<open[4] and close[5]<open[5] and close<sma5 and close[1]<sma5[1] and close[2]<sma5[2] and close[3]<sma5[3] and close[4]<sma5[4] and close[5]<sma5[5] and open[5]<sma5[5]
bCase4=close<close[1] and close[2]<close[3] and close[3]<close[4] and close[4]<close[5] and close[2]<open[2] and close[3]<open[3]  and close[4]<open[4] and close[5]<open[5] and close<sma5 and close[1]<sma5[1] and close[2]<sma5[2] and close[3]<sma5[3] and close[4]<sma5[4] and close[5]<sma5[5] and open[5]<sma5[5]

sCase1=close>close[1] and close[1]>close[2] and close[2]>close[3] and close[1]>open[1] and close[2]>open[2] and close[3]>open[3] and close>sma5 and close[1]>sma5[1] and close[2]>sma5[2] and close[3]>sma5[3] and open[3]>sma5[3]
sCase2=close>close[1] and close[1]>close[2] and close[2]>close[3] and close[4]>close[5] and close[1]>open[1] and close[2]>open[2] and close[4]>open[4] and close[5]>open[5] and close>sma5 and close[1]>sma5[1] and close[2]>sma5[2] and close[3]>sma5[3] and close[4]>sma5[4] and close[5]>sma5[5] and open[5]>sma5[5]
sCase3=close>close[1] and close[1]>close[2] and close[3]>close[4] and close[4]>close[5] and close>open  and close[1]>open[1] and close[3]>open[3]  and close[4]>open[4] and close[5]>open[5] and close>sma5 and close[1]>sma5[1] and close[2]>sma5[2] and close[3]>sma5[3] and close[4]>sma5[4] and close[5]>sma5[5] and open[5]>sma5[5]
sCase4=close>close[1] and close[2]>close[3] and close[3]>close[4] and close[4]>close[5] and close[2]>open[2] and close[3]>open[3]  and close[4]>open[4] and close[5]>open[5] and close>sma5 and close[1]>sma5[1] and close[2]>sma5[2] and close[3]>sma5[3] and close[4]>sma5[4] and close[5]>sma5[5] and open[5]>sma5[5]


buy=close>sma200+(0.05*close) and close<open and (bCase1 or bCase2 or bCase3 or bCase4)
sell=close<sma200-(0.05*close) and close>open and (sCase1 or sCase2 or sCase3 or sCase4)

hColor=buy?green:sell?red:na
signal=buy?1:sell?1:0

plot(signal, style=histogram, color=hColor, linewidth=3)
TonyCampbell
2 years ago
What defines a bullish or bearish candle? Thanks.
Reply
Ideas Scripts Chart
United States
United Kingdom
India
España
Italia
Brasil
Россия
Türkiye
日本
한국
Home Stock Screener 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
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Billing Sign Out