Advertisement
JustUncleL

MovingAvg2Line

Feb 9th, 2017
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. //@version=2
  2.  
  3. strategy("MovingAvg2Line Cross", overlay=true)
  4.  
  5. fastLength = input(9)
  6. slowLength = input(18)
  7. momLength = input(14)
  8.  
  9. price = close
  10.  
  11. m = hl2+mom(price,1)
  12. e = sma(m,momLength)
  13.  
  14. mafast = sma(price, fastLength)
  15. maslow = sma(price, slowLength)
  16.  
  17. plot(mafast,color=red)
  18. plot(maslow,color=green)
  19. plot(e,color=black)
  20.  
  21. if (crossover(e, maslow))
  22. strategy.entry("MA2CrossLE", strategy.long, comment="MA2CrossLE")
  23.  
  24. if (crossunder(e, maslow))
  25. strategy.entry("MA2CrossSE", strategy.short, comment="MA2CrossSE")
  26.  
  27. //plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)
  28.  
  29. //eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement