change points to trailing stop percentages

Forums ProRealTime English forum ProOrder support change points to trailing stop percentages

Viewing 6 posts - 1 through 6 (of 6 total)
  • #205163

    Hi, I can’t seem to change the code to work in percent, and I don’t know how to change the variables. thank you

     

    once trailinstop= ActiveTs
    trailingstart = TS
    trailingstep = TsStep
    once breakeaven = ActiveBE
    startBreakeven = StartBe
    PointsToKeep = PointBe
    if trailinstop>0 then
    IF NOT ONMARKET THEN
    newSL=0
    ENDIF
    IF LONGONMARKET THEN
    IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
    newSL = tradeprice(1)+trailingstep*pipsize
    ENDIF
    IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
    newSL = newSL+trailingstep*pipsize
    ENDIF
    ENDIF
    IF SHORTONMARKET THEN
    IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
    newSL = tradeprice(1)-trailingstep*pipsize
    ENDIF
    IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
    newSL = newSL-trailingstep*pipsize
    ENDIF
    ENDIF
    IF newSL>0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
    endif
    if breakeaven>0 then
    IF NOT ONMARKET THEN
    breakevenLevel=0
    ENDIF
    IF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN
    breakevenLevel = tradeprice(1)+PointsToKeep*pipsize
    ENDIF
    IF breakevenLevel>0 THEN
    SELL AT breakevenLevel STOP
    ENDIF
    IF SHORTONMARKET AND tradeprice(1)-close>startBreakeven*pipsize THEN
    breakevenLevel = tradeprice(1)-PointsToKeep*pipsize
    ENDIF
    IF breakevenLevel>0 THEN
    EXITSHORT AT breakevenLevel STOP
    ENDIF
    ENDIF

    #205166

    Use the default instruction for trailing stop in percent: https://www.prorealcode.com/documentation/percenttrailing/

    or look in this thread, there are many version of trailing stop: https://www.prorealcode.com/topic/trailing-stop-and-breakeven-codes/

     

    #205168

    thank you, I had already seen, but the problem I can not change in the variables of the file, and I deleted them, if someone could do it. Thanks

    #205173

    This a modified version of Nicolas’ code to use percentages:

     

    #205174

    thanks, Roberto, my concern is to modify in the variables. Even the file I couldn’t attach it so bad I suck. i found here thank.

     

    #205187

    Don’t fool us, telling you are not the author of that file! 😆

    It’s a pity for you to waste our time, just to disguise your advertising, and by using mutliple profiles on the website to hide yourself not being sufficiently good at math to convert points distance in percent. It is a shame.

Viewing 6 posts - 1 through 6 (of 6 total)

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