Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. strategy("EMA+SAR", shorttitle='EMA+SAR', overlay=true, pyramiding=0, default_qty_type=strategy.percent_of_equity, default_qty_value=100, currency=currency.USD, initial_capital=1500, commission_type= strategy.commission.percent, commission_value= 0.1)
  2.  
  3.  
  4. start = (0.02)
  5. increment = (0.02)
  6. maximum = (0.2)
  7.  
  8. psar = sar(start, increment, maximum)
  9.  
  10. ema_0 = input(11, minval=1, title="EMA 0")
  11. ema_1 = input(60, minval=1, title="EMA 1")
  12. ema_2 = input(203, minval=1, title="EMA 2")
  13. //vwma_0 = input(113, minval=1, title="VWMA")
  14.  
  15. src = close
  16.  
  17. ema0 = ema(src, ema_0)
  18. ema1 = ema(src, ema_1)
  19. ema2 = ema(src, ema_2)
  20. //vwma0 = vwma(src, vwma_0)
  21.  
  22. plot(ema0, color=red, title="EMA 0", style=line)
  23. plot(ema1, color=orange, title="EMA 1", style=line)
  24. plot(ema2, color=yellow, title="EMA 2", style=line)
  25. //plot(vwma0, color=green, title="VWMA", style=line)
  26.  
  27. startingPeriod = n<500
  28. longCondition= ((ema0 > ema1) and (ema0 > ema2) and (ema1 > ema2) and (psar >= high)) and not startingPeriod
  29. //longCondition= (crossover(ema0, ema1) and (ema0 > ema2) and (ema1 > ema2)) or (crossover(ema1,ema2) and (ema0>ema2)) and not startingPeriod
  30. //shortCondition=
  31.  
  32. strategy.entry("Long", strategy.long, when=longCondition)
  33. //strategy.entry("Short", strategy.short, when=shortCondition)
  34.  
  35. //longClose= (low<vwma0) or ((close < ema0) and (vwma0 < ema1))
  36. longClose= (psar <= low)
  37. //shortClose=
  38.  
  39. strategy.close("Long", when=longClose)
  40. //strategy.close("Short", when=shortClose)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement