Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=4 (Esercitazione tp e sl low-atr)
- strategy(title="Esercitazione tp e sl",
- shorttitle="Prova",
- overlay=true,
- pyramiding=0,
- default_qty_type=strategy.cash,
- default_qty_value=100,
- initial_capital=1000,
- currency=currency.USD,
- commission_type=strategy.commission.cash_per_order,
- commission_value=1)
- smaV=sma(close, 20)
- smaL=sma(close, 30)
- plot(smaV)
- plot(smaL)
- sl = low - atr(14)
- plot(sl, color=red)
- cond_entry_long=crossover(smaV, smaL)
- //cond_exit_long=crossunder(smaV, smaL)
- strategy.entry("Long", true, when=cond_entry_long)
- strategy.exit ("Long", loss=sl)
Add Comment
Please, Sign In to add comment