BreakEven & Trailing Profit: complete function

Forums ProRealTime English forum ProOrder support BreakEven & Trailing Profit: complete function

Viewing 15 posts - 31 through 45 (of 120 total)
  • #158837

    Yes, you have to.

    1 user thanked author for this post.
    #158841

    One more thing: to use high/low instead of close, is this right?

     

    #158844

    Yes, that’s correct, but you’ll have to replace CLOSE also at lines 44 (X1) and 56 (X2).

    You have to keep CLOSE, instead, after line 68 when it deals with minimum distance required by the broker, which must ALWAYS be computed from current price (CLOSE).

    1 user thanked author for this post.
    #158848

    To make it available to anyone, I am posting the code updated with the choice of using either CLOSE or HIGH/LOW (line 1):

     

    6 users thanked author for this post.
    #158898

    Sorry guys, I had to change the above code:

    • I had forgotten to replace TradePrice with PositionPrice in some lines
    • I commented out line 34 and all references to PositionCount and added line 35 to use PositionPrice, instead, because it is most reliable in telling us there’s been a change.

    I am also attaching the ITF file.

     

    3 users thanked author for this post.
    #158909

    @Paul

    it would be great if you could develop a new modified version of my last posted code, with your interesting additions, if possible, so that it be used with position accumulation.

     

     

    #159153

    @Roberto, Thnx for your interest about the additions, a few are covered like sensitivity. The way implemented for me is sufficient. I always prefer % from the latest close instead of a fixed number of points. The Donchian channels I don’t use. Nice to see you included the directionswitch. For now I looking at the % aspects of the code. Looks simple but is it?

    If using percentage, it runs into trouble sometimes. You shouldn’t use tradeprice or positionprice but “close” from the moment condtions are true to enter and a new position is opened at the next bar.

    But not onmarket or directionswitch does not cover each scenario, because if long & adding long it doesn’t take the correct close.

    Anyway i’am suggestion something like this below. What do you think?

    Besides this above, while I ‘ve seen working it correctly, also i’ve seen sellprice & exitprice at 0/999999. pffff

    Here’s the relevant part.

     

    1 user thanked author for this post.
    #159156

    Thank you Paul for your useful suggestions.

     

    #159246

    Having looked at it again I found an other reason for the differences I was experiencing. The format above works with close or positionprice and it can also be placed outside that area to calculate the trailstart and just use position price without additional lines of code. Always more ways then one to achieve the same thing…

     

     

    1 user thanked author for this post.
    #163804
    BarNumber     = 10          //10     Add further % so that trades don’t keep running too long
    BarPerCent    = 0.100       //10%    Add this additional percentage every BarNumber bars
    Lets say I run a system on 5 minutes WIHTOUT a target profit (this trailing should work anyway right?). This means every 50 min the trailing will move up another 10% right (That is not how it works now).
    Can someone explain this?
    #163814

    It will add 10% to the current percentage every 50 minutes.

    So if your base percentage was 10%, PerCentInc may have raised that to, say 11% or 12%, BarPerCent will add a further 10% for a total of 21% or 22%.

    If you set up percentages like that:

    • 10% BsaePerCent
    • 10% PerCentInc
    • 10% BarPerCent

    when PerCentInc INCREASES  BasePerCent the first time, BasePerCent will become 11% (itself + 10% of itself), while BarPerCent will ADD 10% so that 11% becomes 21%.

     

    #163847

    hi Roberto, isn’t stepsize having the same problem as spread if calculated over longer time periods. A stepsize of 10 on the dow might be quite big 5-10 years back?

    Second question is that stepsize is depended on which market it is applied to. On the dow it’s different then on forex. On forex (eurusd mini) it was guessing how small it should be. I settled on 0.0001. Does that make sense?

    Is there some way to have a method that give it a value automatically?

     

     

    #163852

    Maybe the atr is something which will work and covers both questions. If changing over time is usefull or not it’s something to test, but atleast stepsize adjust itself to each market (atr/10)

     

    #163866

    Whenever you launch you strategy in autotrading you know:

    • are launching it now, so it’s the current market, not years ago
    • what the chosen TF is
    • what is the instrument to be traded

    so you can change STEP accordingly.

    Of course using ATR makes it more portable (but you will still have to change other settings, such as Distance from current price, Start).

    Actually there’s no perfect Trailing Stop (and no perfect strategy, indicator, ……), so everyone has to stick to the code he prefers, making custom changes, like you did, to suit best your needs (which may change across different strategies).

    #163906

    “isn’t stepsize having the same problem as spread if calculated over longer time periods. A stepsize of 10 on the dow might be quite big 5-10 years back?” That is 100% true. I also have been focusing on optimizing on 1million bars which means it is a big difference from 2011 and 2021. The backtest shows much better closes if looking at MFE from earlier on the backtest. I like the concept of this code and do you guys have any suggestion how I could work arround this?

Viewing 15 posts - 31 through 45 (of 120 total)

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