Ciao, stavo valutando di mettere due strategie in un solo codice, una strategia di tipo trend following e una mean reversing, è possibile mettere 2 stop loss e due target profit? uno per strategia e se possibile come devo fare? oppure devo far funzionare due strategie separate?
Potrei sapere anche se è possibile modificare lo stop loss in trailing stop oppure modificarne il valore se la posizione va in profitto in modo da proteggere i profitti?
Grazie Mille
Matteo
DEFPARAM CUMULATEORDERS = FALSE
// MEAN REVERSING
c01 = close < average [200]
c1 = close crosses under average [41]
c2 = close crosses over average[49]
//ATRREV = AVERAGETRUERANGE[M]>AVERAGETRUERANGE[N][O]
//TREND FOLLOWING
c0 = close > average [200]
c3 = close crosses over average [20]
c4 = close crosses under average[50]
//ATRFOL = AVERAGETRUERANGE[20]>AVERAGETRUERANGE[2][8]
//c4 = averagetruerange[1]>averagetruerange[1][5]
//____________________MEAN REVERSING______________________________
if c1 and c01 and not onmarket then
buy 1000 CASH at market
endif
if c2 then
sell at market
endif
set stop %loss (200)
set target %profit (100)
//___________________TREND FOLLOWING_____________________________
if c3 and c0 and not onmarket then
buy 1000 cash at market
endif
if c4 then
sell at market
endif
set stop $loss (100)
set target %profit (100)
In questo caso, inserisci le istruzioni stoploss e takeprofit subito dopo aver inviato un ordine per ciascuna strategia specifica:
//____________________MEAN REVERSING______________________________
if c1 and c01 and not onmarket then
buy 1000 CASH at market
set stop %loss (200)
set target %profit (100)
endif
if c2 then
sell at market
endif
//___________________TREND FOLLOWING_____________________________
if c3 and c0 and not onmarket then
buy 1000 cash at market
set stop $loss (100)
set target %profit (100)
endif
if c4 then
sell at market
endif
In questo caso, lo stoploss è impostato una volta per tutti e per ciascuna strategia.