Trailing Stop Codes – Preferred & Least

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #113477 quote
    GraHal
    Participant
    Master

    Out of the many Trailing Stop Snippets on this website which do you …

    1.   Most Prefer and have had best success with?
    2.   Least prefer and have had least success with?

    Say why if you want, but it’s not essential.

    Please might you provide a link to the TS code or copy and paste the code on here?

    Thank You

    #113483 quote
    bullbear
    Participant
    Senior

     

    I like this trailing SL most.

    Have tested many different trailing SL but this one usually works best, many others I get “tick mode” with high digits but rarely with this stop, so I like it best 🙂

     

    //trailing stop function
    trailingstart = 17// 20trailing will start @trailinstart points profit
    trailingstep = 5// 5trailing step to move the "stoploss"
     
    //reset the stoploss value
    IF NOT ONMARKET THEN
    newSL=0
    ENDIF
     
    //manage long positions
    IF LONGONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
    newSL = tradeprice(1)+trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
    newSL = newSL+trailingstep*pipsize
    ENDIF
    ENDIF
     
    //manage short positions
    IF SHORTONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
    newSL = tradeprice(1)-trailingstep*pipsize
    ENDIF
    //next moves
    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
    ENDIF
     
    set stop ploss 40
    
    GraHal thanked this post
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Trailing Stop Codes – Preferred & Least


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by bullbear
6 years, 3 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 11/23/2019
Status: Active
Attachments: No files
Logo Logo
Loading...