Strategia trailing stop
- This topic has 4 replies, 2 voices, and was last updated 7 years ago by .
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
Similar topics:
Forums › ProRealTime forum Italiano › Supporto ProOrder › Strategia trailing stop
Tagged: trailing stop
Prova questa (io l’ho testata solo sommariamente):
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
DEFPARAM CumulateOrders = FALSE Media = average[63,0](close) Sopra = close > Media Sotto = close < Media IF Sopra AND Not OnMarket THEN BUY 1 CONTRACT AT MARKET ENDIF IF Sotto AND Not OnMarket THEN SELLSHORT 1 CONTRACT AT MARKET ENDIF //************************************************************************ // trailing stop function TrailingStart = 30 * pipsize //20 trailing will start @trailinstart points profit TrailingStep = 10 * pipsize //10 trailing step to move the "stoploss" MainSL = 10 * pipsize //10 initial SL // //reset the stoploss value IF NOT ONMARKET THEN newSL = 0 InitialSL = 0 ENDIF // IF LongOnMarket THEN IF NewSL = 0 THEN MyProfit = close - TradePrice IF MyProfit >= TrailingStart THEN SLunits = max(1,round(((MyProfit - TrailingStart) / TrailingStep) - 0.5) + 1) NewSL = TradePrice + (SLunits * TrailingStep) - MainSL ENDIF ELSE MyProfit = close - NewSL IF MyProfit >= TrailingStart THEN SLunits = round(((MyProfit - TrailingStart) / TrailingStep) - 0.5) NewSL = NewSL + (SLunits * TrailingStep) ENDIF ENDIF ELSIF ShortOnMarket THEN IF NewSL = 0 THEN MyProfit = TradePrice - close IF MyProfit >= TrailingStart THEN SLunits = max(1,round(((MyProfit - TrailingStart) / TrailingStep) - 0.5) + 1) NewSL = (SLunits * TrailingStep) + MainSL - TradePrice ENDIF ELSE MyProfit = NewSL - close IF MyProfit >= TrailingStart THEN SLunits = round(((MyProfit - TrailingStart) / TrailingStep) - 0.5) NewSL = NewSL - (SLunits * TrailingStep) ENDIF ENDIF ENDIF // //stop order to exit the positions IF newSL>0 THEN SELL AT newSL STOP EXITSHORT AT newSL STOP ENDIF |
Devi eliminarla, si.
Su quale strumento, TF e candela l’hai provata e non funziona?
Se il profitto raggiunge 30+ viene spostato lo stop di 10 pips, quindi la prima volta va in pareggio. Se il profitto raggiunge 40+ (sempre la prima volta), vuoi che lo strop si sposti di soli 10 o di 20 (in modo da tenere sempre una distanza di 30 pips di differenza)?
Ricordi qual’era? Forse quella di Nicolas https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/?
Find exclusive trading pro-tools on 