BreakEven & Trailing Profit: complete function

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

Viewing 15 posts - 1 through 15 (of 120 total)
  • #93959

    The purpose of this code is to:

    • set BreakEven after TRAILSTART profit (in Pips)
    • add a Percentage (BASEPERCENT) to lock in some profits
    • increase that Percentage each STEPSIZE chunk of pips (20% will increase BASEPERCENT by a factor of 0.20, thus, say 30%, would become 36% after the first step, then 43.2 on the second step and so on…) to lock in more profits as they move towards TP
    • make sure the exit price meets the broker’s minimun distance requirements to avoid unpredictable exits

     

    10 users thanked author for this post.
    #130423

    Ciao Roberto, thanks for linking to this – looks really interesting, wish I’d seen it months ago.

    If I wanted to convert both the trailing start and step to %, does this look right? not sure if it should be done onmarket or not onmarket?

     

    #130442

    No, it changes the logic, other lines need to be changed.

    I will try to do it asss asap.

    #130605

    it changes the logic

    yes, I see that now – both TrailStart and Stepsize are used in the calculation. I didn’t look at it that closely. Never mind, I can use it as is with fixed values. Thanks again.

    #130664

    Astonishing result – is this even possible? to change one component and double the profit? Kills the %win but who cares. Left is with Nicolas’s %TS, right is yours with these settings:

    Scarcely believable. Unfortunately I’ve not seen this kind of improvement on other algos, but there is always an improvement (and always at the cost of reduced %win).

    Sei un genio, grazie mille!

    #130668

    Did you change the logic?

    Because the logic I used when I wrote it was such that

    assigns BasePerCent a percentage of 1000%, which means that any trade will be exited as soon as it reaches 24 pips.

    10%, as I wrote it, should be 0.1.

    But this may be positive if it yields more profits, provided drawdown doesn’t increase much.

     

    #130671

    Ah, that would explain a few things. I saw the 20% rem’d out and overlooked that you had already calculated the % as a decimal. Same with PerCentInc. Strange though, that the optimiser was happy to work with integer values for both of those. I’ll run it again with decimal values.

    #130672

    Ok, sanity is restored, all’s right with the world. A modest improvement of every metric – this is much better.

     

    3 users thanked author for this post.
    #132382

    Hello Roberto,

    trying your code, I have found that in the following case, the code is bugging.

    Case: if you have one big candle where your profit jump in one shot, and you use a small Stepsize parameter, then ProfitPerCent becomes huge and so does the sellprice/exitprice vs latest price

    #132388

    That’s what I intended to do, just increase the percentage as chunks (lines 20-23 and 32-35) of StepSize profits show.

    I understand what you mean, you can address it by decreasing PerCentInc or  increasing StepSize or, say, halving chunks (adding a line between 21 and 22):

    the same between lines 33-34 with Chunks2.

     

    #132389

    You could also add a check that this adjustment be done only when chunks are more than N or when a candle’s body is, say, twice its 20-period average.

    There’s no limit to further development and customization.

     

    1 user thanked author for this post.
    #141006

    Hi,

    Will this code overwrite a stop loss sett at opening of a position?

    Or is it possible to modify this so a stop loss is created at opening and then starts trailing if the position is plus?

     

    Best,

    Christoffer

    #141010

    You should also use SET STOP LOSS, since they are different and can be used together.

    This code deals only with trailing stop, not the stop itself.

    #151457

    Hello Roberto,

    Thank you for this very nice piece of code! I’m very new into this and have used this code in one of my first algos that I’m testing in Demo with good results. I’m very happy with the entry criterias for my algo but I find it to be in the market for too long to “keep the edge” of the entry and would therefore like to try a thought that I have to add a function so that the Trailing Stop slowly increases (for a long order) even if the market lose momentum and the close price is not moving.

    For example by counting bars since starting the trailing and increase the Breakeven x% per bar that pass.

    I have not managed to solve this in a good way on my own, so I’m now turning to you. Any thoughts of a good way to add such a feature to this code?

    THX!

    #151589

    I added a number of bars to add an additional percentage, so that the trade will exit shorter:

     

Viewing 15 posts - 1 through 15 (of 120 total)

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