Need a trailing stop loss that moves more dynamic

Forums ProRealTime English forum ProOrder support Need a trailing stop loss that moves more dynamic

Viewing 4 posts - 16 through 19 (of 19 total)
  • #63514

    When i place the usual SL instruction at the end of the code, it does not get any funktion.

    What am i doing wrong?

     

     
    <pre class=”lang:probuilder decode:true “>// trailing stop function
    trailingstep = 6 //5 trailing step to move the “stoploss” after BreakEven
    startBreakeven = 2 //5 pips in gain to activate the breakeven function
    PointsToKeep = 2 //3 pips to keep in profit above/below entry price when the breakeven is activated
    //
    //reset the stoploss value
    IF NOT ONMARKET THEN
    newSL = 0
    breakevenLevel = 0
    ENDIF
    //******************************************************************************************************
    // —– BREAKEVEN code
    //
    //reset the breakevenLevel when no trade are on market
    // — LONG side
    IF LONGONMARKET AND (close – tradeprice(1)) >= (startBreakeven * pipsize) AND breakevenlevel = 0 THEN
    breakevenLevel = tradeprice(1) + (PointsToKeep * pipsize) //calculate the breakevenLevel
    ENDIF
    // — SHORT side
    IF SHORTONMARKET AND (tradeprice(1) – close) >= (startBreakeven * pipsize) AND breakevenlevel = 0 THEN
    breakevenLevel = tradeprice(1) + (PointsToKeep * pipsize) //calculate the breakevenLevel
    ENDIF
    //Set new Stop Loss
    IF breakevenLevel > 0 THEN
    newSL = BreakEvenLevel
    ENDIF
    //******************************************************************************************************
    // —– TRAILING STOP code
    //
    //manage long positions
    IF LONGONMARKET AND BreakEvenLevel THEN
    //next moves after BreakEven
    IF newSL > 0 AND ((close – newSL) >= (trailingstep * pipsize)) THEN
    newSL = newSL + (trailingstep * pipsize)
    ENDIF
    ENDIF
    //manage short positions
    IF SHORTONMARKET AND BreakEvenLevel THEN
    //next moves after BreakEven
    IF newSL > 0 AND ((newSL – close) >= (trailingstep * pipsize)) THEN
    newSL = newSL – (trailingstep * pipsize)
    ENDIF
    ENDIF
    //stop order to exit the positions
    IF newSL > 0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP

    SET STOP LOSS 32
    ENDIF
     

    #63540

    To write code, please use the <> “insert PRT code” button.

    Thank you.

     

    #63543

    You shouldn’t place your SL there!  That code is made to handle customized trailing stops/breakeven and is ready-to-use, so you’d better not change it unless you are aware of what you are doing.

    Put where else you want, usually at the end of your strategy.

    Just search any strategy in the library and study where other members place their code, you’ll learn how it is structured.

     

     

    #63582

    Hi,

    Just a quick visit now, so I haven’t read the entire thread. But I wrote this a while ago, I hope it might help:

    I hope it might help you!

Viewing 4 posts - 16 through 19 (of 19 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login