Preferred or Most Effective Trailing Stops – Suggestions Please

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

    Loads of Trailing Stop codes are linked here …

    Snippet Link Library

    Would anyone like to share (could be from Library above) a Trailing Stop (TS) Code they have found to be effective (could be Gain increase or Drawdown reduction?) when added to their AutoTrading System(s)?

    A TS code that allows different settings when Long or Short should be very interesting?

    Thank You

    #236646 quote
    SnorreDK
    Participant
    Junior

    My favorite is still:

    //VARIABLES STOP SUIVEUR
    ONCE trailingStopType     = 1    // Trailing Stop - 0 OFF, 1 ON
    ONCE trailingstoplong     = 7.5    // Trailing Stop Atr Relative Distance
    ONCE trailingstopshort    = 4    // Trailing Stop Atr Relative Distance
     
    ONCE atrtrailingperiod    = 25  // Atr parameter Value
    ONCE minstop              = 0    // Minimum Trailing Stop Distance
     
     
    // TRAILINGSTOP
    //----------------------------------------------
    atrtrail = AverageTrueRange[atrtrailingperiod]((close/10)*pipsize)/1000
    trailingstartl = round(atrtrail*trailingstoplong)
    trailingstartS = round(atrtrail*trailingstopshort)
    if trailingStopType = 1 THEN
    TGL =trailingstartl
    TGS=trailingstarts
    if not onmarket then
     
    MAXPRICE = 0
    MINPRICE = close
    PREZZOUSCITA = 0
    ENDIF
    if longonmarket then
    MAXPRICE = MAX(MAXPRICE,close)
    if MAXPRICE-tradeprice(1)>=TGL*pointsize then
    if MAXPRICE-tradeprice(1)>=MINSTOP then
    PREZZOUSCITA = MAXPRICE-TGL*pointsize
    ELSE
    PREZZOUSCITA = MAXPRICE - MINSTOP*pointsize
    ENDIF
    ENDIF
    ENDIF
    if shortonmarket then
    MINPRICE = MIN(MINPRICE,close)
    if tradeprice(1)-MINPRICE>=TGS*pointsize then
    if tradeprice(1)-MINPRICE>=MINSTOP then
    PREZZOUSCITA = MINPRICE+TGS*pointsize
    ELSE
    PREZZOUSCITA = MINPRICE + MINSTOP*pointsize
    ENDIF
    ENDIF
    ENDIF
    if onmarket and PREZZOUSCITA>0 then
    EXITSHORT AT PREZZOUSCITA STOP
    SELL AT PREZZOUSCITA STOP
    ENDIF
    ENDIF
    Snålänningen and GraHal thanked this post
    #236801 quote
    SnorreDK
    Participant
    Junior

    Whats your favorite GraHal?

    #236804 quote
    GraHal
    Participant
    Master

    I haven’t got a favourite (yet! 🙂 ) … apart from you kindly posting your fav TS, it doesn’t look like others have a favourite either as no more posts since yours.

    I have tried TS’s in the past, but most barely improved overall performance and several reduced performance.  I guess it depends on the strategy and exit conditions etc.

    I have an Algo working on 1 hour TF, Exit is a switch of direction, but after seeing Gain increase then fall back again, I thought .. maybe a TS might help here.

    I tried Exit when Close < MA and Close Crosses under MA etc, but that didn’t help much overall either.

    I have about 20 versions of the Algo currently on Demo Live test … some without TS, some with various TS’s and some with MA’s etc … I have these working 1 min TF, one is on 1 sec TF (main strategy is on 1 hour TF).

    I’ll let you know the outcome.

    SnorreDK thanked this post
    #236820 quote
    JS
    Participant
    Senior
    #236831 quote
    GraHal
    Participant
    Master

    Thank you JS, forgive the daft question, but what does x represent from your code?

    If xLongOnMarket then
    #236834 quote
    JS
    Participant
    Senior

    Hi GraHal,

    Sometimes the official instructions/commands of PRT do not work as expected, for example if you use “StrategyProfit” and your system goes directly from “Long” to “Short” or vice versa, then the “StrategyProfit” will not work properly (too late)…
    In such cases, I create my own variable by putting an “x” in front of it (xStrategyProfit) so that I know that this is my own variable…

    GraHal thanked this post
    #236837 quote
    JS
    Participant
    Senior

    In this case, it would be something like this:

    If BuyCondition then
    Buy 1 contract at Market
    xLongOnMarket=1
    xShortOnMarket=0
    EndIf

    If ShortCondition then
    SellShort 1 contract at Market
    xLongOnMarket=0
    xShortOnMarket=1
    EndIf

    GraHal thanked this post
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.

Preferred or Most Effective Trailing Stops – Suggestions Please


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 7 replies,
has 3 voices, and was last updated by JS
1 year, 5 months ago.

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