Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -------------------------------------------------*(26 Orario Ingresso Posizione E Orario Barre)*-------------------------------------------------
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © Maurizio-Ciullo
- // Le funzioni strategy.opentrades.entry_time(0) e time_close servono principalmente per il trailing stop che si innescherà con gli high
- // 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
- //delle candele precedenti di quando non sono in posizione, in questo modo me li conta solo quando sono in posizione.
- //@version=5
- strategy(title='15 Orario Ingresso Posizione E Orario Barre', overlay=true,
- pyramiding=0,
- initial_capital=150,
- commission_type=strategy.commission.percent,
- commission_value=0.1,
- slippage=3,
- default_qty_type=strategy.percent_of_equity,
- default_qty_value=8.8)
- maInputSlow = input.int(title="MA Slow", defval=81, minval=0, maxval=500)
- maInputFast = input.int(title="MA Fast", defval=15, minval=0, maxval=500)
- maMinDiff = input.float(title="Distanza min medie", defval=15)
- // strategy.opentrades.entry_time(0) restituisce l'orario dell'ingresso in posizione
- strategy.opentrades.entry_time(0)
- plot(strategy.opentrades.entry_time(0), title="entry_time")
- // time_close restituisce l'orario di ogni barra
- time_barra = time_close[2]
- plot(time_barra, title="time_barra")
- maSlow = ta.ema(close, maInputSlow)
- maFast = ta.ema(close, maInputFast)
- plot(maFast, title="maFast")
- // In questo caso non si genereranno mai posizioni perchè il tempo della barra potrà creare un ingresso in posizione.
- condEntryLong = close > maSlow and time_barra > strategy.opentrades.entry_time(0)
- condExitLong = ta.crossunder(maFast, maSlow)
- //entrata e uscita Long
- if condEntryLong // strategy.opentrades == 0
- strategy.entry('operazioneLong', strategy.long, alert_message = "Open Long Position")
- if condExitLong and strategy.opentrades ==1
- strategy.close('operazioneLong', alert_message = "Your Long SL-TP Has Been Triggered.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement