Advertisement
Guest User

CHATGPT RSI DD Strategy

a guest
Apr 29th, 2023
1,773
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | Cryptocurrency | 1 0
  1. //@version=4
  2. strategy("RSI Strategy", overlay=true)
  3.  
  4. // Input for RSI periods
  5. rsiLongPeriod = input(14, title="RSI Long Period", minval=1)
  6. rsiShortPeriod = input(5, title="RSI Short Period", minval=1)
  7.  
  8. // Calculate RSI values
  9. rsiLong = rsi(close, rsiLongPeriod)
  10. rsiShort = rsi(close, rsiShortPeriod)
  11.  
  12. // Long Entry Condition
  13. longEntry = crossover(rsiLong, 50) and crossover(rsiShort, 70)
  14.  
  15. // Long Exit Condition
  16. longExit = crossunder(rsiShort, 55)
  17.  
  18. // Short Entry Condition
  19. shortEntry = crossunder(rsiLong, 50) and crossunder(rsiShort, 30)
  20.  
  21. // Short Exit Condition
  22. shortExit = crossover(rsiShort, 35)
  23.  
  24. // Execute trades
  25. strategy.entry("Long", strategy.long, when=longEntry)
  26. strategy.close("Long", when=longExit)
  27. strategy.entry("Short", strategy.short, when=shortEntry)
  28. strategy.close("Short", when=shortExit)
  29.  
  30. // Plot RSI values and levels - Comment below code if you want to hide the RSI Plotting in Tradingview
  31. plot(rsiLong, title="RSI Long", color=color.blue)
  32. hline(50, "Long Level", color=color.green)
  33. plot(rsiShort, title="RSI Short", color=color.red)
  34. hline(70, "Long Entry", color=color.green)
  35. hline(55, "Long Exit", color=color.red)
  36. hline(30, "Short Entry", color=color.red)
  37. hline(35, "Short Exit", color=color.green)
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement