Buongiorno Roberto vorrei trasformare il tuo indicatore, magic trend in una strategia per ingressi long e short, mi puoi aiutare a fare questa cosa, sempre se possibile.
Grazie
Ti ho fatto questa semplice strategia che entra Long quando c’è un incrocio rialzista del prezzo con l’indicatore, ed entra Short quando c’è un incrocio ribassista.In Entrambi i casi NON fa lo Stop & Reverse, ma attende di non essere a mercato per entrare.
Ho messo uno SL fisso in pips ed un moltiplicatore per il TP.
DEFPARAM CumulateOrders = False
ONCE SL = 200 * PipSize
ONCE TP = SL * 3.0
MT = CALL "Magic Trend custom"[20, 14, 1, 5]
L1 = close CROSSES OVER MT
S1 = close CROSSES UNDER MT
IF L1 AND Not OnMarket THEN
BUY 1 CONTRACT AT MARKET
ELSIF S1 AND Not OnMarket THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
SET TARGET pPROFIT TP
SET STOP pLOSS SL
Per rendere la strategia migliore dovrebbe qntrare long solo quando la media mobile 200 è in rialzo
e short al contrario, come posso scrivere l codice per farle fare questa cosa?
Eccolo:
DEFPARAM CumulateOrders = False
ONCE SL = 200 * PipSize
ONCE TP = SL * 3.0
MT = CALL "Magic Trend custom"[20, 14, 1, 5]
Sma200 = average]200,0](close)
Rialzo = Sma200 > Sma200[1]
Ribasso = Sma200 < Sma200[1]
L1 = (close CROSSES OVER MT) and Rialzo
S1 = (close CROSSES UNDER MT) and Ribasso
IF L1 AND Not OnMarket THEN
BUY 1 CONTRACT AT MARKET
ELSIF S1 AND Not OnMarket THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
SET TARGET pPROFIT TP
SET STOP pLOSS SL