Advertisement
Maurizio-Ciullo

26 Orario Ingresso Posizione E Orario Barre

May 2nd, 2022
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -------------------------------------------------*(26 Orario Ingresso Posizione E Orario Barre)*-------------------------------------------------
  2.  
  3. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  4. // © Maurizio-Ciullo
  5.  
  6. // Le funzioni strategy.opentrades.entry_time(0) e time_close servono principalmente per il trailing stop che si innescherà con gli high
  7. // o i low delle barre solo dopo che è entrato in posizione, dato che con strategy.opentrades == 1 mi va a contare anche gli high e i low
  8. //delle candele precedenti di quando non sono in posizione, in questo modo me li conta solo quando sono in posizione.
  9.  
  10. //@version=5
  11.  
  12. strategy(title='15 Orario Ingresso Posizione E Orario Barre', overlay=true,
  13.      pyramiding=0,
  14.      initial_capital=150,
  15.      commission_type=strategy.commission.percent,
  16.      commission_value=0.1,
  17.      slippage=3,
  18.      default_qty_type=strategy.percent_of_equity,
  19.      default_qty_value=8.8)
  20.  
  21.  
  22. maInputSlow = input.int(title="MA Slow", defval=81, minval=0, maxval=500)
  23. maInputFast = input.int(title="MA Fast", defval=15, minval=0, maxval=500)
  24. maMinDiff = input.float(title="Distanza min medie", defval=15)
  25.  
  26.  
  27. // strategy.opentrades.entry_time(0) restituisce l'orario dell'ingresso in posizione
  28. strategy.opentrades.entry_time(0)
  29. plot(strategy.opentrades.entry_time(0), title="entry_time")
  30.  
  31.  
  32. // time_close restituisce l'orario di ogni barra
  33. time_barra = time_close[2]
  34. plot(time_barra, title="time_barra")
  35.  
  36.  
  37. maSlow = ta.ema(close, maInputSlow)
  38. maFast = ta.ema(close, maInputFast)
  39. plot(maFast, title="maFast")
  40.  
  41.  
  42. // In questo caso non si genereranno mai posizioni perchè il tempo della barra potrà creare un ingresso in posizione.
  43. condEntryLong = close > maSlow and time_barra > strategy.opentrades.entry_time(0)
  44. condExitLong = ta.crossunder(maFast, maSlow)
  45.  
  46. //entrata e uscita Long
  47. if condEntryLong // strategy.opentrades == 0
  48.     strategy.entry('operazioneLong', strategy.long, alert_message = "Open Long Position")
  49.  
  50. if condExitLong and strategy.opentrades ==1
  51.     strategy.close('operazioneLong', alert_message = "Your Long SL-TP Has Been Triggered.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement