Advertisement
andypartridge47

101 Michaels Bands Back to Basics

Dec 8th, 2024
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. //@version=5
  2. strategy("101 Michaels Bands Back to Basics", overlay=true)
  3.  
  4. sma12 = ta.sma(close, 12)
  5. sma22 = ta.sma(close, 22)
  6. sma50 = ta.sma(close, 50)
  7.  
  8. // Declare bandColor variable
  9. var color bandColor = na
  10.  
  11. // Entry conditions
  12. longCondition = sma12 > sma22 and sma50 < sma22
  13. shortCondition = sma12 < sma22 and sma50 > sma22
  14.  
  15. // Entry
  16. if (longCondition)
  17. bandColor := color.green
  18. strategy.entry("Long", strategy.long)
  19.  
  20. if (shortCondition)
  21. bandColor := color.red
  22. strategy.entry("Short", strategy.short)
  23.  
  24. // Plots
  25. plot(sma12, color=bandColor, linewidth=1)
  26. plot(sma22, color=bandColor, linewidth=3)
  27. plot(sma50, color=color.blue, linewidth=3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement