Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © MBCryptocurrency
- //@version=5
- indicator("Supply and Demand Zone", overlay=true, timeframe="", timeframe_gaps=false)
- //CCI
- ma = ta.sma(hlc3, 14)
- cci = (hlc3 - ma) / (0.015 * ta.dev(hlc3, 20))
- timeframe1= input.timeframe('60','First CCI timeframe')
- timeframe2= input.timeframe('120','second CCI timeframe')
- CCI15= request.security(syminfo.tickerid, timeframe1 ,cci,gaps = barmerge.gaps_off)
- CCI60= request.security(syminfo.tickerid, timeframe2,cci,gaps = barmerge.gaps_off)
- ///RSI
- up = ta.rma(math.max(ta.change(close), 0), 14)
- down = ta.rma(-math.min(ta.change(close), 0), 14)
- rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
- rsiMA = ta.sma(rsi, 14)
- isBB = "SMA" == "Bollinger Bands"
- timeframe=input.timeframe('60', " RSI timeframe")
- rsi15= request.security(syminfo.tickerid,timeframe ,rsi,gaps = barmerge.gaps_off)
- cross= ta.cross(cci,-100)
- cross2=ta.cross(cci,100)
- //condition
- signal_buy = false
- signal_sell = false
- if CCI15 < -100 and CCI60 < -150 and rsiMA < 35 and rsi15 < 50 //buy when long time is above zero and short time is below zero
- signal_buy := true
- if CCI15 > 100 and CCI60 > 150 and rsiMA > 65 and rsi15 > 50 //sell when long time is below zero and short time is above zero
- signal_sell := true
- //only first signal to show
- Buy = false
- Sell = false
- Buy := signal_buy ? true : signal_sell ? false : cross ? false :cross2 ? false : Buy[1]
- Sell := signal_sell ? true : signal_buy ? false : cross ? false :cross2 ? false : Sell[1]
- Final_buy = signal_buy and not (Buy[1])
- Final_sell = signal_sell and not (Sell[1])
- // alerts
- alertcondition(Final_buy, "Buy", "Time to Buy")
- alertcondition(Final_sell , "Sell", "Time to Sell")
- //plotshapes
- plotshape(Final_sell, title="Sell", style = shape.triangledown, color=color.rgb(255, 0, 0, 50) , size = size.small, location = location.abovebar, text = "Sell Zone", textcolor= color.yellow)
- plotshape(Final_buy, title="Buy", style = shape.triangleup, color=color.rgb(0, 255, 0, 50) , size = size.small, location = location.belowbar, text = "Buy Zone", textcolor= color.blue)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement