Maurizio-Ciullo

Esercitazione tp e sl

Jul 3rd, 2021 (edited)
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //@version=4                                              (Esercitazione tp e sl low-atr)
  2. strategy(title="Esercitazione tp e sl",
  3.      shorttitle="Prova",
  4.      overlay=true,
  5.      pyramiding=0,
  6.      default_qty_type=strategy.cash,
  7.      default_qty_value=100,
  8.      initial_capital=1000,
  9.      currency=currency.USD,
  10.      commission_type=strategy.commission.cash_per_order,
  11.      commission_value=1)
  12.  
  13. smaV=sma(close, 20)
  14. smaL=sma(close, 30)
  15.  
  16. plot(smaV)
  17. plot(smaL)
  18.  
  19. sl = low - atr(14)
  20. plot(sl, color=red)
  21.  
  22.  
  23. cond_entry_long=crossover(smaV, smaL)
  24. //cond_exit_long=crossunder(smaV, smaL)
  25.  
  26.  
  27. strategy.entry("Long", true, when=cond_entry_long)
  28. strategy.exit ("Long", loss=sl)
Add Comment
Please, Sign In to add comment