Advertisement
dravitch

ChatGPT Strategy by Kralow (Youtube) - No Shorts -4H - 440%

Jul 27th, 2023
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. //@version=5
  2. strategy(shorttitle='ChatGPT Strategy by Kralow', title='Bollinger Bands', overlay=true, currency=currency.NONE, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value = 100)
  3.  
  4. // Bollinger Bands
  5. src = input(close)
  6. length = input.int(12, minval=1)
  7. mult = input.float(2.0, minval=0.001, maxval=50)
  8.  
  9. basis = ta.sma(src, length)
  10. dev = ta.stdev(src, length)
  11. dev2 = mult * dev
  12.  
  13. upper1 = basis + dev
  14. lower1 = basis - dev
  15. upper2 = basis + dev2
  16. lower2 = basis - dev2
  17.  
  18. colorBasis = src >= basis ? color.blue : color.orange
  19.  
  20. pBasis = plot(basis, linewidth=2, color=colorBasis)
  21. pUpper1 = plot(upper1, color=color.new(color.blue, 0), style=plot.style_circles)
  22. pUpper2 = plot(upper2, color=color.new(color.blue, 0))
  23. pLower1 = plot(lower1, color=color.new(color.orange, 0), style=plot.style_circles)
  24. pLower2 = plot(lower2, color=color.new(color.orange, 0))
  25.  
  26. fill(pBasis, pUpper2, color=color.new(color.blue, 80))
  27. fill(pUpper1, pUpper2, color=color.new(color.blue, 80))
  28. fill(pBasis, pLower2, color=color.new(color.orange, 80))
  29. fill(pLower1, pLower2, color=color.new(color.orange, 80))
  30.  
  31. // RSI
  32. rsiLength = input(14, title="RSI Length")
  33. rsiThreshold = input(30, title="RSI Threshold")
  34.  
  35. rsiValue = ta.rsi(src, rsiLength)
  36.  
  37. // Strategy Entry and Exit Conditions
  38. longCondition = close > upper2 and rsiValue > rsiThreshold
  39.  
  40. if longCondition
  41. strategy.entry("Long", strategy.long)
  42.  
  43. shortCondition = close < lower2 or rsiValue <= rsiThreshold
  44.  
  45. if shortCondition
  46. strategy.close("Long")
  47.  
  48. // Trailing Stop
  49. trailing_offset = input.float(0.01, "Trailing Stop Offset")
  50. trailing_stop_loss = strategy.position_avg_price * (1 - trailing_offset)
  51.  
  52. strategy.exit("Long", "Close Long", stop = trailing_stop_loss)
  53.  
Tags: trading
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement