Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- strategy("Bot Utente QTA VIX-Mean-Reversion-RSI-BB-ATR-4H", overlay=true, currency = currency.USD)
- //Inputs
- periodiBB = input.int(30, "Periodi Bollinger Bands")
- StdFactor = input.int(2,"Standard Deviation")
- RSI_Length = input.int(13, "Periodi RSI")
- RSI_Threshold = input.int(20, "Threshold RSI Long")
- RSI_ThresholdShort = input.int(70, "Threshold RSI Short")
- ATRLenght = input.int(7,"Periodi ATR")
- AllowShortSelling = input.bool(false, "Allow Short Side")
- ATR_Multiplier_TP = input.float(2.0, "ATR Multiplier TP", step = 0.5)
- ATR_Multiplier_SL = input.float(2.0, "ATR Multiplier SL", step = 0.5)
- //Variabili
- [bbMiddle, bbUpper, bbLower] = ta.bb(close, periodiBB, StdFactor)
- RSI_Value = ta.rsi(close ,RSI_Length)
- con1 = 0
- con2 = 0
- ATR = ta.atr(ATRLenght)
- if ta.crossunder(close, bbLower) and RSI_Value <= RSI_Threshold //and strategy.opentrades == 0
- con1 := 1
- if con1 == 1 and close[1] < open[1] //and close > high[1]
- Limit_Price = high[strategy.opentrades] + (ATR_Multiplier_TP * ATR)
- Stop_Price = low[strategy.opentrades] - (ATR_Multiplier_SL * ATR)
- strategy.entry("Long", strategy.long)
- strategy.exit("Long", comment = "Close Long", limit = Limit_Price, stop = Stop_Price)
- con1 := 0
- //Short Side
- if AllowShortSelling
- if ta.crossover(close, bbUpper) and RSI_Value >= RSI_ThresholdShort //and strategy.opentrades == 0
- con2 := 1
- if con2 == 1 and close[1] > open[1]
- TP_Short = low[strategy.opentrades] - ATR
- SL_Short = high[strategy.opentrades] + ATR
- strategy.entry("Short", strategy.short)
- strategy.exit("Short", comment = "Close Short", stop = SL_Short, limit = TP_Short)
- con2 := 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement