Avrei una richiesta, ma non so se è fattibile , comunque la scrivo; Vorrei sapere se è possibile avere uno Stop lose che scatti al raggiungimento del valore più una conferma di un indicatore . E cioè al raggiungimento del valore fissato scatta solo dopo conferma di un indicatore.
Grazie
Si, certo.
Innanzitutto devi disabilitare lo Stop Loss con
Set Stop Loss 0
oppure usare uno Stop Loss più alto di quello desiderato.
Dopodiché quando il prezzo passa lo Stop Loss reale esci appena l’indicatore ti da la conferma.
Ovviamente senza uno Stop Loss o con uno Stop Loss elevato rischi di perdere molto di più.
Non ho capito bene, devo mettere anche uno stop loss reale? E l’indicatore dove lo metto?
Eccolo (non l’ho provato):
Once SL = 100 * PipSize
Set Stop Loss 0
If not OnMarket then
Uscita = 0
Endif
Cond = rsi[14](close) crosses under 30
If LongOnMarket then
If (PositionPrice - low) >= SL then
Uscita = 1
Endif
If Uscita and Cond then
Sell at Market
Endif
Endif
esce quando il prezzo (caso Long) scende e tocca lo SL, ma successivamente, o contemporaneamente, RSI entra in ipervenduto.
Non da nessun risultato, almeno così sembra.
Dovrebbe uscire quando ci sono le condizioni richieste.
Ho provato a cambiare 100*pipsize , che credo sia il livello SL, e ci sono risultati diversi. Per lo short, basta cambiare cross under in cross over e 30 con un valore sopra 50?
Grazie
Occorre il codice per poterlo analizzare.
Le tue istruzioni con delle modifiche, l’ho inserito nel codice che allego.
Grazie
Ho corretto il codice, in quanto c’era un errore logico:
// Definizione dei parametri del codice
DEFPARAM CumulateOrders = False // Posizioni cumulate disattivate
// Condizioni per entrare su posizioni long
indicator1, indicator2, ignored, ignored = CALL "rsi e regressione lineare"
c1 = (indicator1 CROSSES OVER indicator2)
IF c1 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Condizioni per uscire da posizioni long
indicator3, ignored, ignored, indicator4 = CALL "rsi e regressione lineare"
c2 = (indicator3 CROSSES OVER indicator4)
indicator5, ignored, indicator6, ignored = CALL "rsi e regressione lineare"
c3 = (indicator5 CROSSES UNDER indicator6)
IF c2 OR c3 THEN
SELL AT MARKET
ENDIF
//SET STOP $LOSS l
Once SL = 30 * PipSize
Set Stop Loss 0
If not OnMarket then
Uscita = 0
Endif
Cond = rsi[14](close) crosses under 40
If LongOnMarket then
Profitto = PositionPerf * PositionPrice / PipSize
If abs(PositionPrice - low) >= SL AND (PositionPerf < 0) then
Uscita = 1
Endif
If Uscita and Cond then
Sell at Market
Endif
Endif
//************************************************************************
//trailing stop
trailingstop = tra
//resetting variables when no trades are on market
if not onmarket then
MAXPRICE = 0
MINPRICE = close
priceexit = 0
endif
//case SHORT order
if shortonmarket then
MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
endif
endif
//case LONG order
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price level
endif
endif
//exit on trailing stop price levels
if onmarket and priceexit>0 then
//EXITSHORT AT priceexit STOP
SELL AT priceexit STOP
endif
//
//graph Uscita AND Cond AND LongOnMarket
//graph Profitto coloured("Red")
Sembra che non funzioni, non c’è nessuna differenza tra le due versioni e comunque vanno peggio di uno normale stop loss.
Grazie