Buongiorno, questa modifica di trailing stop può fare in modo che un ts progettato per il long, faccia reverse sullo short nel caso in cui il prezzo finisca ad un valore inferiore alla variabile TGS? Come completarlo? L’ho testato e va short, ma occorre dare un target di guadagno o di trailing anche allo short
TGL =28//28
TGS= 40 //40
if not onmarket then
MAXPRICE = 0
MINPRICE = close
PREZZOUSCITA = 0
ENDIF
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close)
if MAXPRICE-tradeprice(1)>=TGL*pointsize then
PREZZOUSCITA = MAXPRICE-TGL*pointsize
ENDIF
ENDIF
if longonmarket then
MINPRICE = MIN(MINPRICE,close)
if tradeprice(1)-MINPRICE>=TGS*pointsize then
PREZZOSHORT = MINPRICE+TGS*pointsize
ENDIF
ENDIF
if onmarket and PREZZOUSCITA>0 then
SELLSHORT AT PREZZOSHORT STOP
SELL AT PREZZOUSCITA STOP
ENDIF
se non sei mai stato in grado di guadagnare più di TGL o TGS, non c’è modo di uscire in profitto in questo codice.