SHARE
TWEET

Untitled

a guest Oct 12th, 2017 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //@version=2
  2. strategy(title="Jeroen Cross", overlay=true)
  3.  
  4. // Bollinger bands
  5. lengthbb = input(20, minval=1)
  6. srcbb = input(close, title="Sourcebb")
  7. multbb = input(2.0, minval=0.001, maxval=50)
  8. basisbb = sma(srcbb, lengthbb)
  9. devbb = multbb * stdev(srcbb, lengthbb)
  10. upperbb = basisbb + devbb
  11. lowerbb = basisbb - devbb
  12. bbr = (srcbb - lowerbb)/(upperbb - lowerbb)
  13.  
  14. //stochcastics
  15. stochlength = input(14, minval=1), smoothK = input(3, minval=1), smoothD = input(3, minval=1)
  16. k = sma(stoch(close, high, low, stochlength), smoothK)
  17. d = sma(k, smoothD)
  18.  
  19. //rvgi
  20. RVGIlen = input(10, title="Length", minval=1)
  21. rvi = sum(swma(close-open), RVGIlen)/sum(swma(high-low),RVGIlen)
  22. rvisig = swma(rvi)
  23. rvibuy = rvi
  24.  
  25. //ema short
  26. short = ema(close, 10)
  27. long = ema(close, 30)
  28.  
  29. //ema long
  30. shortday = ema(close, 240)
  31. longday = ema(close, 720)
  32.  
  33. //plot
  34. plot(short, color = red)
  35. plot(long, color = green)
  36. plot(shortday, color = blue)
  37. plot(longday, color=yellow)
  38.  
  39. //buy
  40. strategy.entry("BuyLE", strategy.long, oca_name="JeroenCross", oca_type=strategy.oca.cancel, when= (short > long) and (rvibuy > rvisig) and (k > d), comment="Cross over")
  41. //else
  42. //   strategy.cancel("BuyLE")
  43.  
  44. //sell for profit
  45. if (strategy.position_avg_price < close)
  46.     strategy.close("BuyLE", when= crossunder(rvi , rvisig) or (k < d) )
  47.  
  48. //security
  49. if (strategy.position_avg_price > upperbb)
  50.     strategy.close("BuyLE", when= crossunder(rvi , rvisig) or crossunder(short , long) )
RAW Paste Data
Top