Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)
- start = (0.02)
- increment = (0.02)
- maximum = (0.2)
- psar = sar(start, increment, maximum)
- ema_0 = input(11, minval=1, title="EMA 0")
- ema_1 = input(60, minval=1, title="EMA 1")
- ema_2 = input(203, minval=1, title="EMA 2")
- //vwma_0 = input(113, minval=1, title="VWMA")
- src = close
- ema0 = ema(src, ema_0)
- ema1 = ema(src, ema_1)
- ema2 = ema(src, ema_2)
- //vwma0 = vwma(src, vwma_0)
- plot(ema0, color=red, title="EMA 0", style=line)
- plot(ema1, color=orange, title="EMA 1", style=line)
- plot(ema2, color=yellow, title="EMA 2", style=line)
- //plot(vwma0, color=green, title="VWMA", style=line)
- startingPeriod = n<500
- longCondition= ((ema0 > ema1) and (ema0 > ema2) and (ema1 > ema2) and (psar >= high)) and not startingPeriod
- //longCondition= (crossover(ema0, ema1) and (ema0 > ema2) and (ema1 > ema2)) or (crossover(ema1,ema2) and (ema0>ema2)) and not startingPeriod
- //shortCondition=
- strategy.entry("Long", strategy.long, when=longCondition)
- //strategy.entry("Short", strategy.short, when=shortCondition)
- //longClose= (low<vwma0) or ((close < ema0) and (vwma0 < ema1))
- longClose= (psar <= low)
- //shortClose=
- strategy.close("Long", when=longClose)
- //strategy.close("Short", when=shortClose)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement