Breakout next 5 Bars

Forums ProRealTime English forum ProOrder support Breakout next 5 Bars

Viewing 15 posts - 1 through 15 (of 47 total)
  • #207461

    Hi,

    if i have a popgun i wanna go short if one of the next 5 bars is lower than the last bar of the popgun is, the opposite for long. SL under the last bar of the popgung -5 points, long the opposite.

    I this dont happend the order should be cancel.

    How can i code this?

    PG = High[2]>High[1] and Low[2]<Low[1] and High>High[1] and Low<Low[1]

    #207468
    JS

    Hi @killerplatuze

    Try this one…

    1 user thanked author for this post.
    #207473

    This doesn’t work. The first 3 bars are the Popgun, if the conditions are true. The 3th bar is the the triggerbar, the next 5 bars are the bars which can break out.

    But it works with OR.

    But i have a problem with TP and SL. The SL should be 5 points below the triggerbar if long.

    The TP should be one ATR of the triggerbar.

    So i need help again with TP and SL, thx a lot.

     

     

     

     

    #207476
    JS

    You have 3 bars for the PopGun and 5 bars for the breakout, a total of 8 bars…

    From right to left B[0] B[1] B[2] B[3] B[4] B[5] B[6] and B[7] (total 8 bars)

    “If High[3] or High[4]” and so on is not a valid condition because they are all true…

    There is a High[3] (true) or there is a High[4] (true) and so on…

    The conditions in the code match your story…

    You can put the Stop wherever you want but your trigger bar is B[5] and not B[2]

    If you want to use the ATR for your TP, this ATR will have to be calculated over a certain (lookback) period…

    1 user thanked author for this post.
    #207477

    Thx, i have seen my mistake.

     

    But if i use your code the result is wrong, as you can see it at the attached picture

    The buy for the first PG is on Bar too late, the buy for the second bar ist 2 bars too late.

     

    #207479
    JS

    Unfortunately it doesn’t work that way, the order is…

    1. B[5] is the trigger bar
    2. B[4] is the breakout bar, here is the condition true and then the next bar…
    3. Buy when B[3] opens…

    This is the order in which PRT processes the market orders…

    #207481
    JS

    Alternatively, you can use Stop orders instead of market orders…

    Buy 1 contract at High[5] STOP

    These orders are executed immediately…

    1 user thanked author for this post.
    #207482

    This Order must be canceled if no bar gets a trigger, how can in do this?

    #207483
    JS

    These STOP orders are “pending” orders and they start at the beginning of the new bar and are valid until the end of that bar…

    So, when the condition (PopGun) is true then these pending orders are started /placed and when not hit in the next five bars (under a certain conditions) then this “pending STOP order” will not be placed afterwards …

    So, you don’t have to cancel anything…

    For example:

    PopGun is true  extra condition is true  place the pending stop orders  pending stop order is hit  extra condition is no longer true  no more placement of the pending STOP orders…

    1 user thanked author for this post.
    #207485
    JS

    I think you can reduce the code to this…

    #207487
    JS

    I think you’ve found a nice pattern…

    Excellent Risk/Reward ratio

    Excellent Profit/Loss ratio

    %profit trades is bad but that’s because there are a lot of small losses that are offset by relatively large profits…

    This can probably be improved…

    1 user thanked author for this post.
    #207490

    Something is wrong, the trade starts much too late

    #207495
    JS

    You must go back to the first code and replace the market orders with STOP orders…

    (The last code only looks at the PopGun)

    #207502

    This is the code, same result. Trade starts much too late. Its crazy.

    #207516
    JS

    Hi,

    You can try this one…

    The problem is that your PopGun in its current form does not indicate a direction (Long or Short)…

    1 user thanked author for this post.
Viewing 15 posts - 1 through 15 (of 47 total)

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