Advertisement
Maurizio-Ciullo

Bot Utente QTA VIX-Mean-Reversion-4H

Jun 13th, 2023 (edited)
1,013
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //@version=5
  2. strategy("Bot Utente QTA VIX-Mean-Reversion-RSI-BB-ATR-4H", overlay=true, currency = currency.USD)
  3.  
  4.  
  5. //Inputs
  6.  
  7. periodiBB = input.int(30, "Periodi Bollinger Bands")
  8.  
  9. StdFactor = input.int(2,"Standard Deviation")
  10.  
  11. RSI_Length = input.int(13, "Periodi RSI")
  12.  
  13. RSI_Threshold = input.int(20, "Threshold RSI Long")
  14.  
  15. RSI_ThresholdShort = input.int(70, "Threshold RSI Short")
  16.  
  17. ATRLenght = input.int(7,"Periodi ATR")
  18.  
  19. AllowShortSelling = input.bool(false, "Allow Short Side")
  20.  
  21. ATR_Multiplier_TP = input.float(2.0, "ATR Multiplier TP", step = 0.5)
  22.  
  23. ATR_Multiplier_SL = input.float(2.0, "ATR Multiplier SL", step = 0.5)
  24.  
  25. //Variabili
  26.  
  27. [bbMiddle, bbUpper, bbLower] = ta.bb(close, periodiBB, StdFactor)
  28.  
  29. RSI_Value = ta.rsi(close ,RSI_Length)
  30.  
  31. con1 = 0
  32.  
  33. con2 = 0
  34.  
  35. ATR = ta.atr(ATRLenght)
  36.  
  37.  if ta.crossunder(close, bbLower) and RSI_Value <= RSI_Threshold //and strategy.opentrades == 0
  38.  
  39. con1 := 1
  40.  
  41.  if con1 == 1 and close[1] < open[1] //and close > high[1]
  42.  
  43. Limit_Price = high[strategy.opentrades] + (ATR_Multiplier_TP * ATR)
  44.  
  45. Stop_Price = low[strategy.opentrades] - (ATR_Multiplier_SL * ATR)
  46.  
  47. strategy.entry("Long", strategy.long)
  48.  
  49. strategy.exit("Long", comment = "Close Long", limit = Limit_Price, stop = Stop_Price)
  50.  
  51. con1 := 0
  52.  
  53. //Short Side
  54.  
  55. if AllowShortSelling
  56.  
  57. if ta.crossover(close, bbUpper) and RSI_Value >= RSI_ThresholdShort //and strategy.opentrades == 0
  58.  
  59.     con2 := 1
  60.  
  61. if con2 == 1 and close[1] > open[1]
  62.  
  63.     TP_Short = low[strategy.opentrades] - ATR
  64.  
  65.     SL_Short = high[strategy.opentrades] + ATR
  66.  
  67.     strategy.entry("Short", strategy.short)
  68.  
  69.     strategy.exit("Short", comment = "Close Short", stop = SL_Short, limit = TP_Short)
  70.  
  71.     con2 := 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement