Breakeven- en trailingstop on different securities & indexes & forex

Viewing 15 posts - 31 through 45 (of 80 total)
  • Author
    Posts
  • #126439 quote
    Paul
    Participant
    Master

    I understand your interest in other markets. You will have to start excluding parameters to the point where it starts taking trades. But it breaks the coherence of the parameters. Not sure it’s worth the effort though.

    #126454 quote
    Dr Manhattan
    Participant
    Senior

    >> meant to quote GraHal here but something happened…

    1st is for set up of what to use, the 2nd is the bread and butter if you dont make the home run, the third is the execution of it all if I can understand it correctly. I will try to apply this when standard deviation of range goes outside of a regular day. Usually there is a small profit to be collected there on both sides, but it is usually a quick one and needs a really good trailing to make it before a reversal. Maybe this can do it. 🙂

    #129380 quote
    GraHal
    Participant
    Master

    I am clearing the decks of loads of Systems … off PRT and onto my PC.

    I came across attached … good results so I thought I’d add to this Topic!  I did not optimise at all, just backtested today!

    Paul you put so much hard work … I hope this Topic might be revived.

    I will put on Forward Test on Monday and report back … and if I forget to report back, please remind me at some stage anybody!? 🙂

    bertrandpinoy, swedshare and Paul thanked this post
    #131367 quote
    deleted23092025
    Participant
    New

    @grahal im just here to remind you hehe 😀

    #131385 quote
    GraHal
    Participant
    Master

    Ha and I needed reminding  too … I had put it in my ‘4Test folder’ and then forgot to put it on test!

    I’ve been doing very well this week on manual trades and it’s taken my eye off the Auto-Systems!

    I’ve just set it going on Forward Test.

    Thanks

    #131573 quote
    nonetheless
    Participant
    Master

    Hi @Paul, I’ve been playing with the ATR TS code you used on the new Vectorial DAX and the results are fantastic – just wanted to say a big thanks for that!

    Looking at this section of it,

    once tsincrements = 0.5          // set to 0 to ignore tsincrements
    once tsminatrdist = 4.0
    
    once tsatrperiod    = 14         // ts atr parameter
    once tsminstop      = 10         // ts minimum stop distance
    
    once tssensitivity        = 0    // [0]close;[1]high/low
    
    if trailingstoptype then
    if barindex=tradeindex then
    trailingstoplong     = 8   // ts atr distance
    trailingstopshort    = 8   // ts atr distance

    I tend to leave tsatrperiod  and tsminstop as they are, as those values seem to work on any instrument and TF. But changes to ts atr distance, tsminatrdist, and tsincrements all have a huge effect. I’m still a bit unclear as to how these 3 work together. A lower ts atr distance, 3 to 6 for example, def gives a higher win % and seems better for scalping.

    Do you have any basic rule of thumb as to how you select values for those on different instruments or TFs?

    At the moment I’m working on a 2m TF with atr distance =5, tsminatrdist=2 and increments=0, seems to get good results overall.

    bertrandpinoy, swedshare, keewee, Moda and Balmora74 thanked this post
    #131601 quote
    bertrandpinoy
    Participant
    Veteran

    what do you mean by ATR = 5
    I put the screen copy for more understanding

    #131614 quote
    nonetheless
    Participant
    Master

    i mean trailingstoplong / short = 5

    ts atr distance is rem’d out

    bertrandpinoy thanked this post
    #131671 quote
    Paul
    Participant
    Master

    Hi Nonetheless. Thanks for your comment!

    I do the same with the tsatrperiod, leaving it at 14 regardless instrument.

    the tsminstop is different. For this it’s best to have the correct value from IG. 

    It means if the current price is too close to the ts exit stop price, it will reject the exit when using the wrong value. (not visible in a backtest)

    Because of this I added an extra exit criteria, if index crosses over/under the tsnewsl it still exits next bar at open on market. My purpose was for fast timeframes, because if the stop is rejected, the next bar will be fast. On a hourly timeframe it doesn’t bring much.

    Then there’s tssensitivity. If you have often a spike and a close considerably away from the new high/low, the system originally only use the close. With some algo’s I thought might be interesting to calculate from the real high/low instead of close.

    The trailingstop long/short is used to set the atr distance when the gains are sufficient. I do not have a basic rule on this, but when the trailing stop starts working, it has to have gains which makes sense compared to a loss on stoploss or average losses.

    In the old situation, with tsincrements at 0 and tssensitivity at 0, it means a fixed (besides the round difference) number of points for the trailing stop. Those points are calculated from the highest/lowest close.

    In the other situation, it starts working when the atr distance trailingstoplong/short is reached.

    From that moment on it starts reducing the atr distance to the tsminatrdist with he increments set. Values which make sense normally are 0-0.25 with increments of 0.05. At the vectorial dax I’ve put them even higher.

    In other words, if the trailing stop value in points was originally +/- 80, it starts reducing it to +/- 40 points quickly once it kicks in (using values in vectorial dax)

     

    To have a better visual, try to use graph tgl/tgs and graphonprice tsnewsl and see the difference using increments at zero and higher.

    The trailingstop doesn’t do completely what I had in mind though, but for me it’s good.

    nonetheless, keewee, AlgoAlex and Balmora74 thanked this post
    #131681 quote
    nonetheless
    Participant
    Master

    Thanks very much for the explanation, that makes a lot of things clearer. ATR TS is so much more sophisticated than the standard version where all you really have is the start and the step. Yours does a much better job of catching a bigger piece of the MFE for trades that don’t ever get to the TP.

    It’s a brilliant contribution, consider me a convert. 👍

    Paul and AlgoAlex thanked this post
    #131809 quote
    swedshare
    Participant
    Senior

    I have a “trailing challenge” for anyone up to it. I would guess that @Paul and @nonetheless might like this.

    Attached is the Kama Sma strategy originally posted by robertogozzi. It includes his sophisticated trail. However the gain/loss ratio is about the same (2.6-2.7) with and without the trail. The win-rate is better with trail. But the interesting part is the MFE/MAE ratio at 3.7 (!) meaning there is way more candy to steal. I have tried a lot of trails and breakevens from this forum but can’t find a good one boosting the G/L above 3. Any suggestions on a suitable trail? A side note is that the equity curve will never be straight so don’t get hung up on that.

    DEFPARAM CumulateOrders = false
    DEFPARAM PreLoadBars    = 2000
    
    //code re-invest
    Capital = 1000 // initial capital
    Equity = Capital + StrategyProfit
    Position = Max(1, Equity * (1/Capital))
    Position = Round(Position*100)
    Position = Position/100
    //********************
    
    ONCE TP            = 4.5
    ONCE SL            = 0.3
    
    //code quit strategy
    maxequity = max(equity,maxequity)
    DrawdownNeededToQuit = 40   // percent drawdown from max equity to stop strategy
    if equity < maxequity * (1 - (DrawdownNeededToQuit/100)) then
    quit
    endif
    //*****************
    
    ////////////////////////////////////////////////////////////////////////
    TIMEFRAME (default)
    //ONCE nLots         = 1
    ONCE LongTrading   = 1                                //1=allowed   0=banned
    ONCE ShortTrading  = 1                                //1=allowed   0=banned
    
    TIMEFRAME (1 hour, updateonclose)                                             //h1
    IF Not OnMarket THEN
    BarCount = 0
    ELSE
    BarCount = BarCount + 1
    ENDIF
    //------------------------------------------------------------------------------------
    //                         Kama & Sma Strategy
    //
    //https://www.forexstrategiesresources.com/trend-following-forex-strategies/111-kama-strategy/
    //
    Period     = 2                                              //2        (standard 10)
    FastPeriod = 2                                              //standard
    SlowPeriod = 30                                             //standard
    //
    Fastest  = 2 / (FastPeriod + 1)
    Slowest  = 2 / (SlowPeriod + 1)
    if barindex >= (Period + 1) then
    Num   = abs(close-close[Period])
    Den   = summation[Period](abs(close-close[1]))
    ER    = Num / Den
    Alpha = SQUARE(ER *(Fastest - Slowest )+ Slowest)
    Kama  = (Alpha * Close) + ((1 -Alpha)* Kama[1])
    else
    Kama  = close
    endif
    //------------------------------------------------------------------------------------
    Sma        = average[22,0](close)                           //22
    //------------------------------------------------------------------------------------
    a1 = Kama CROSSES OVER  Sma
    // --- SHORT
    b1 = Kama CROSSES UNDER Sma
    ////////////////////////////////////////////////////////////////////////
    TIMEFRAME (default)                                                           //1 min
    ONCE TradeON = 1
    IF IntraDayBarIndex = 0 THEN
    TradeON = 1
    ENDIF
    TradeBar = BarCount
    IF Not OnMarket AND TradeBar <> TradeBar[1] THEN
    TradeON = 1
    ENDIF
    //************************************************************************
    //                           LONG  trades
    //************************************************************************
    IF a1 AND TradeON AND LongTrading and TradeOK THEN
    BUY 1 CONTRACT AT MARKET
    TradeON = 0
    ENDIF
    //************************************************************************
    //                           SHORT trades
    //************************************************************************
    IF b1 AND TradeON AND ShortTrading and TradeOK THEN
    SELLSHORT 1 CONTRACT AT MARKET
    TradeON = 0
    ENDIF
    //
    SET TARGET %PROFIT TP
    SET STOP   %LOSS   SL
    //////////////////////////////////////////////////////////////////////////////////////////////////////////
    //                                Trailing Stop
    //------------------------------------------------------------------------------------
    IF Not OnMarket THEN
    TrailStart    = 50          //50     Start trailing profits from this point
    BasePerCent   = 0.07 //0.07       //10.0%  Profit to keep
    StepSize      = 6           //6      Pips chunks to increase Percentage
    PerCentInc    = 0.1       //10.0%  PerCent increment after each StepSize chunk
    RoundTO       = -0.5        //-0.5   rounds to Lower integer,  +0.4 rounds to Higher integer
    PriceDistance = 7 * pipsize//8.9    minimun distance from current price
    y1            = 0
    y2            = 0
    ProfitPerCent = BasePerCent
    ELSIF LongOnMarket AND close > (TradePrice + (y1 * pipsize)) THEN //LONG
    x1 = (close - tradeprice) / pipsize                            //convert price to pips
    IF x1 >= TrailStart THEN                                       //go ahead only if N+ pips
    Diff1         = abs(TrailStart - x1)
    Chunks1       = max(0,round((Diff1 / StepSize) + RoundTO))
    ProfitPerCent = BasePerCent + (BasePerCent * (Chunks1 * PerCentInc))
    ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent))
    y1 = max(x1 * ProfitPerCent, y1)                            //y = % of max profit
    ENDIF
    ELSIF ShortOnMarket AND close < (TradePrice - (y2 * pipsize)) THEN//SHORT
    x2 = (tradeprice - close) / pipsize                            //convert price to pips
    IF x2 >= TrailStart THEN                                       //go ahead only if N+ pips
    Diff2         = abs(TrailStart - x2)
    Chunks2       = max(0,round((Diff2 / StepSize) + RoundTO))
    ProfitPerCent = BasePerCent + (BasePerCent * (Chunks2 * PerCentInc))
    ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent))
    y2 = max(x2 * ProfitPerCent, y2)                           //y = % of max profit
    ENDIF
    ENDIF
    IF y1 THEN                                        //Place pending STOP order when y>0
    SellPrice = Tradeprice + (y1 * pipsize)        //convert pips to price
    IF abs(close - SellPrice) > PriceDistance THEN
    IF close >= SellPrice THEN
    SELL AT SellPrice STOP
    ELSE
    SELL AT SellPrice LIMIT
    ENDIF
    ELSE
    SELL AT Market
    ENDIF
    ENDIF
    IF y2 THEN                                        //Place pending STOP order when y>0
    ExitPrice = Tradeprice - (y2 * pipsize)        //convert pips to price
    IF abs(close - ExitPrice) > PriceDistance THEN
    IF close <= ExitPrice THEN
    EXITSHORT AT ExitPrice STOP
    ELSE
    EXITSHORT AT ExitPrice LIMIT
    ENDIF
    ELSE
    EXITSHORT AT Market
    ENDIF
    ENDIF
    
    // (GER) No trade after friday 16:00:00 (UTC+2 Europe/Berlin) or on holidays
    If dayofweek = 5 AND Time > 160000 then
    TradeOK = 0
    elsif dayofweek = 0 then
    TradeOK = 0
    elsif dayofweek = 1 AND Time < 000100 then
    TradeOK = 0
    elsif year = 2019 and month = 12 and day = 24 then //
    TradeOK = 0
    elsif year = 2019 and month = 12 and day = 25 then //
    TradeOK = 0
    elsif year = 2019 and month = 12 and day = 26 then //
    TradeOK = 0
    elsif year = 2019 and month = 12 and day = 31 then //
    TradeOK = 0
    elsif year = 2020 and month = 1 and day = 1 then // New Year's Day
    TradeOK = 0
    elsif year = 2020 and month = 4 and day = 9 then // Easter
    TradeOK = 0
    elsif year = 2020 and month = 4 and day = 10 then // Easter
    TradeOK = 0
    elsif year = 2020 and month = 4 and day = 13 then // Easter
    TradeOK = 0
    elsif year = 2020 and month = 5 and day = 1 then //
    TradeOK = 0
    elsif year = 2020 and month = 6 and day = 1 then //
    TradeOK = 0
    elsif year = 2020 and month = 12 and day = 24 then //
    TradeOK = 0
    elsif year = 2020 and month = 12 and day = 25 then //
    TradeOK = 0
    elsif year = 2020 and month = 12 and day = 26 then //
    TradeOK = 0
    elsif year = 2020 and month = 12 and day = 31 then //
    TradeOK = 0
    else
    TradeOK = 1
    endif
    // Add TradeOK to buy condition
    //*************
    
    // (GER) Close positions before weekend or day before holiday at 17:15:00 (UTC+2 Europe/Berlin)
    if dayofweek = 5 and time = 171500 THEN
    Endbeforeholiday = 1
    elsif year = 2019 and month = 12 and day = 23 and time = 171500 then
    Endbeforeholiday = 1
    elsif year = 2019 and month = 12 and day = 30 and time = 171500 then
    Endbeforeholiday = 1
    elsif year = 2020 and month = 4 and day = 8 and time = 171500 then
    Endbeforeholiday = 1
    elsif year = 2020 and month = 4 and day = 30 and time = 171500 then
    Endbeforeholiday = 1
    elsif year = 2020 and month = 12 and day = 23 and time = 171500 then
    Endbeforeholiday = 1
    elsif year = 2020 and month = 12 and day = 30 and time = 171500 then
    Endbeforeholiday = 1
    else
    Endbeforeholiday = 0
    endif
    IF Endbeforeholiday THEN
    SELL AT MARKET
    EXITSHORT AT MARKET
    ENDIF
    //*************
    
    Florian and Paul thanked this post
    #131816 quote
    swedshare
    Participant
    Senior

    And of course thank you @robertogozzi for converting the strategy to PRT. It’s still awesome!

    robertogozzi thanked this post
    #131827 quote
    nonetheless
    Participant
    Master

    I doubt that Roberto’s version can be bettered … if it could he would have done it!

    #131832 quote
    robertogozzi
    Moderator
    Master

    There’s never an end to new ideas to improve things.

    I made it, but then I never updated it.

    #131875 quote
    Paul
    Participant
    Master

    here’s a version with atr ts/be

Viewing 15 posts - 31 through 45 (of 80 total)
  • You must be logged in to reply to this topic.

Breakeven- en trailingstop on different securities & indexes & forex


ProOrder support

New Reply
Author
author-avatar
Paul @micky75d Participant
Summary

This topic contains 79 replies,
has 15 voices, and was last updated by Paul
5 years, 6 months ago.

Topic Details
Forum: ProOrder support
Language: English
Started: 02/05/2019
Status: Active
Attachments: 34 files
Logo Logo
Loading...