ciao non è un problema ma ti ripeto non funziona per i trailing stop, è quello il problema se non ti ferma le operazioni quando deve farlo (IG Markets) lo usi anche tu?
Sul trailing stop e sullo stop ci posso lavorare, il problema al momento è che non mi apre le posizioni mentre dal back test risulta eseere entrato, e non so il perchè.
è normale nei backtest ti fa sempre entrare, ma in reale applicano delle restrizioni meschine e scorrette, è una vergogna! se loro hanno un accordo commerciale con Prorealtime dovrebbero rispettare i prodotti di Prorealtime e seppure voler porre delle distanze minime a cui posizionare gli ordini di vendita stop dirlo anticipatamente e dire come fare affinchè l’ordine entri in questo modo i trailing non si possono utilizzare perchè puoi capirlo quando IG rifiuta l’ordine l’algo continua a girare.
lo hai messo in reale? se non è entrato è perchè non c’erano le condizioni per entrare seconda la tecnica su cui è impostato.
Si l’ho messo in reale, dal back test risulta che da giovedi a ieri avrbbe dovuto aprire due posizioni, ma in real non è entrato. Per questo ti ho chiesto se hai fatto qualche modifica rispetto all algo che hai postato.
a me è entrato 1 volte su GBPYEN e 2 su USDYEN, adesso ti posto il codice. Fai copia e incolla.
Defparam cumulateorders = false
// TAILLE DES POSITIONS
n = 1
// PARAMETRES
// high ratio = few positions
// AUD/JPY : ratio = 0.5 / SL = 0.8 / TP = 1.2 / Period = 12
// EUR/JPY : ratio = 0.6 / SL = 1 / TP = 0.8 / Period = 8
// GBP/JPY : ratio = 0.5 / SL = 0.6 / TP = 1 / Period = 8
// USD/JPY : ratio = 0.5 / SL = 1 / TP = 0.8 / Period = 12
ratio = 0.5
// HORAIRES
startTime = 210000
endTime = 231500
exitLongTime = 210000
exitShortTime = 80000
// STOP LOSS & TAKE PROFIT (%)
SL = 0.4
TP = 0.7
Period = 3
// BOUGIE REFERENCE à StartTime
if time = startTime THEN
amplitude = highest[Period](high) - lowest[Period](low)
ouverture = close
endif
// LONGS & SHORTS : every day except Fridays
// entre StartTime et EndTime
if time >= startTime and time <= endTime and dayOfWeek <> 5 then
buy n shares at ouverture - amplitude*ratio limit
sellshort n shares at ouverture + amplitude*ratio limit
endif
// Stop Loss & Take Profit
set stop %loss SL
set target %profit TP
// Exit Time
if time = exitLongTime then
sell at market
endif
if time = exitShortTime then
exitshort at market
endif
ok grazie , lo proverò e ti farò sapere.
quello modificato è questo ma per i problemi di cui ti parlavo non prende i trailing con IG Markets
questo
Defparam cumulateorders = false
// TAILLE DES POSITIONS
n = 1
// PARAMETRES
// high ratio = few positions
// AUD/JPY : ratio = 0.5 / SL = 0.8 / TP = 1.2 / Period = 12
// EUR/JPY : ratio = 0.6 / SL = 1 / TP = 0.8 / Period = 8
// GBP/JPY : ratio = 0.5 / SL = 0.6 / TP = 1 / Period = 8
// USD/JPY : ratio = 0.5 / SL = 1 / TP = 0.8 / Period = 12
ratio = 0.6
period = 8
// HORAIRES
startTime = 210000
endTime = 231500
exitLongTime = 210000
exitShortTime = 80000
// BOUGIE REFERENCE à StartTime
if time = startTime THEN
amplitude = highest[Period](high) - lowest[Period](low)
ouverture = close
endif
// LONGS & SHORTS : every day except Fridays
// entre StartTime et EndTime
if time >= startTime and time <= endTime and dayOfWeek <> 5 then
buy n shares at ouverture - amplitude*ratio limit
sellshort n shares at ouverture + amplitude*ratio limit
endif
// Stop Loss & Take Profit
// Stop e target
SET STOP PLOSS 25
SET TARGET PPROFIT 13 //395
//
//trailing stop function
//************************************************************************
// trailing stop function
trailingstart = 19 //10 trailing will start @trailinstart points profit
trailingstep = 24 //5 trailing step to move the "stoploss"
//
//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND HIGH-tradeprice(1)>=trailingstart*pipsize THEN //close --> HIGH
newSL = tradeprice(1)+trailingstep*pipsize
// new coding
IF newSL > close THEN //if current closing price is < new SL then exit IMMEDIATELY!
SELL AT newSL LIMIT
ENDIF
// end new coding
ENDIF
//next moves
IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
newSL = newSL+trailingstep*pipsize
// new coding
IF newSL > close THEN //if current closing price is < new SL then exit IMMEDIATELY!
SELL AT newSL LIMIT
ENDIF
// end new coding
ENDIF
ENDIF
//manage short positions
IF SHORTONMARKET THEN
//first move (breakeven)
IF newSL=0 AND tradeprice(1)-LOW>=trailingstart*pipsize THEN //close --> LOW
newSL = tradeprice(1)-trailingstep*pipsize
// new coding
IF newSL < close THEN //if current closing price is > new SL then exit IMMEDIATELY!
EXITSHORT AT newSL LIMIT
ENDIF
// end new coding
ENDIF
//next moves
IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
newSL = newSL-trailingstep*pipsize
// new coding
IF newSL < close THEN //if current closing price is > new SL then exit IMMEDIATELY
EXITSHORT AT MARKET
ENDIF
// end new coding
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT MARKET
ENDIF
// Exit Time
if time = exitLongTime then
sell at market
endif
if time = exitShortTime then
exitshort at market
endif
alla voce ratio metti 0.3 mentre a quella period metti 3 periodi
Ciao Roberto, scusa il disturbo, ma perchè la strategia in questione , quello senza trailing stop, a me sui cross monetari non mi apre le posizioni ? Ho messo in demo la strategia sugli indici e funziona perfettamente mentre sul forex non mi apre posizione ( il back test dice il contrario) , come mai? Cosa c’è di sbagliato? Devo fare qualche settaggio particolare ?
Grazie.
BUONASERA,
POTRESTE AIUTARMI A LEGGERE IL CODICE POSTATO DAL SIG.STEVEN11?
ARRIVO A COMPRENDERE POCHE RIGHE POI MI PERDO 😉
GRAZIE
@Hary Trading
Per favore non scrivere tutto maiuscolo, se non in rare occasioni e per poche parole da enfatizzare.
È equiparato ad URLARE in una discussione ed è poco educato.
Grazie.
Quanto al codice, dopo esserti letto bene il manuale ed avere visto qualche video, qui sul forum o sul canale YouTube di ProRealTime Italia, dovrai porre una domanda specifica su qualche riga che non riesci a comprendere.
Non è possibile spiegarti tutto un codice, occorrerebbe un corso!