Code Snippet – Recover to Break-even

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #60331 quote
    GraHalGraHal
    Participant
    Master

    Anybody please have / could code a code snippet to achieve the following in an Auto-Trade.
    Please feel free to add / amend / improve the spec …

    • Loss > X points
    • Recover back to Y% of Loss?
    • Exit trade if momentum < Z at Y% of Loss.

    The logic in my mind / experience is that if the loss > x points and there is then a good run up / down (back to breakeven / near) then the trade is likely to retrace again so I exit, breathe a sigh of relief and go make a coffee! 🙂

    Above logic is more suited to short term trades / intraday.

    I recall this being discussed and have searched on here with no success.

    Thank You
    GraHal
    PS I am working on a solution myself, but any suggestions would be appreciated and would then be here for the benefit of others … until we get the ‘snippet repository’?? 🙂

    #60347 quote
    AutoStrategistAutoStrategist
    Participant
    Veteran

    Hi Grahal, how you doing?  Have been taking a break from the site but couldn’t resist having a go at this.  I haven’t tested it but it should be there or thereabouts, any questions give me a shout.

    ONCE PercentofMAE = 0.8 // 80% as decimal
    ONCE MinimumMomentum = 10
    ONCE MaxAEPermitted = 50 // Max loss to reach to trigger conditions
    
    // MaxAE needs to be set to 0 when opening a position
    
    if longonmarket then
    if close < positionprice then
    LossNow = abs(close - positionprice)
    MaxAE = MAX(MaxAE,LossNow)
    if MaxAE > MaxAEPermitted then
    c1 = LossNow < MaxAE*PercentofMAE
    c2 = Momentum[12](close) < MinimumMomentum
    if  c1 and c2  then
    sell at market
    endif
    endif
    endif
    elsif shortonmarket then
    if close > positionprice then
    // ...
    endif
    endif
    GraHal, Juan Salas and Nicolas thanked this post
    #60353 quote
    GraHalGraHal
    Participant
    Master

    Hi AS, nice one! great to see you back!

    Many thanks, looks good!

    I’ll let you know how it goes.

    Cheers
    GraHal

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Code Snippet – Recover to Break-even


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by GraHalGraHal
8 years, 8 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/23/2018
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...