Breakout next 5 Bars

Viewing 15 posts - 16 through 30 (of 47 total)
  • Author
    Posts
  • #207726 quote
    killerplatuze
    Participant
    New

    This don’t work. It seems so that there isn’t any solution for this problem. I can’t beleave it, it is only a market order.

    #207727 quote
    GraHal
    Participant
    Master

    Buy 1 contract at High STOP

    I might be missing something, but how can we buy at High?

    High does not allow for spread?

    Surely it needs to be something like … Buy 1 contract at (High-x) STOP?

    Or better still …

    If Close > High - x Then
    Buy at Market
    Endif

    same goes for SellShort …

    If Close < Low +x Then
    SellShort at Market
    Endif
    #207728 quote
    killerplatuze
    Participant
    New

    Thank you, but im afraid this wont work. Maybe you can take a look at attaced picture?

    PG4.jpg PG4.jpg
    #207730 quote
    GraHal
    Participant
    Master

    how can we buy at High STOP? (for example, at bar 100)

    During the next bar (or next few bars) we may hit the value that High was on bar 100 (allowing for spread of course).

    Is this what is happening killerplatuze

    #207731 quote
    killerplatuze
    Participant
    New

    yes, it seems so.

    #207732 quote
    GraHal
    Participant
    Master

    I like this PopGun, it’s simple and < 10 lines of code … makes it easy to work on! 😉

    Try below with values A4 to A7 optimised to whatever you think suits your chosen TF and Instrument.

    Below fits what you state in the box on your screenshot?

    DefParam CumulateOrders=False
    //PopGun
    If High[2]>High[1] and Low[2]<Low[1] and High>High[1] and Low<Low[1] then
    Buy 1 contract at High+A4 STOP
    Set Stop Price High-A5
    SellShort 1 contract at Low-A6 STOP
    Set Stop Price Low+A7
    EndIf
    
    killerplatuze thanked this post
    #207748 quote
    GraHal
    Participant
    Master

    Is above code opening trades > 5 bars after trigger bar?

    If Yes, that is the next thing to fix.

    killerplatuze thanked this post
    #207765 quote
    killerplatuze
    Participant
    New

    Many thanks for your help. It seems to be the right way.

    The fifth bar should be filled with a short, but isn’t. If the fourth bar breaks out it will be filled with a trade

    PG5.png PG5.png
    #207768 quote
    GraHal
    Participant
    Master

    So 3 was the trigger bar?

    What value are you using for A4 and A6 in the code I posted?

    killerplatuze thanked this post
    #207778 quote
    killerplatuze
    Participant
    New

    Just 5, just wanna see what happened with the bux trigger. The third candle is the buy trigger, One of the next 5 bars must break out, otherwise the popgun will be deleted.

     

    I take 5 for all.

    #207825 quote
    GraHal
    Participant
    Master

    Try this …

    DefParam CumulateOrders=False
    
    PopGun = High[2]>High[1] and Low[2]<Low[1] and High>High[1] and Low<Low[1]
    If PopGun Then
    Trigger = barindex
    TrigHigh = High
    TrigLow = Low
    TradeOn = barindex < Trigger + 5
    Endif
    
    If PopGun and TradeOn then
    Buy 1 contract at TrigHigh+A4 STOP
    Set Stop Price High-A5
    SellShort 1 contract at TrigLow-A6 STOP
    Set Stop Price Low+A7
    EndIf
    killerplatuze thanked this post
    #207833 quote
    GraHal
    Participant
    Master

    Above code with small improvement …

    DefParam CumulateOrders=False
     
    PopGun = High[2]>High[1] and Low[2]<Low[1] and High>High[1] and Low<Low[1]
    If PopGun Then
    Trigger = barindex
    TrigHigh = High
    TrigLow = Low
    TradeOn = barindex < Trigger + 5
    Endif
     
    If PopGun and TradeOn then
    Buy 1 contract at TrigHigh+A4 STOP
    Set Stop Price TrigHigh-A5
    SellShort 1 contract at TrigLow-A6 STOP
    Set Stop Price TrigLow+A7
    EndIf
    killerplatuze thanked this post
    #207834 quote
    killerplatuze
    Participant
    New

    Hi, there ist no trade.

    #207835 quote
    killerplatuze
    Participant
    New

    Without A4 and A6 it works, but there is only a trade if the first bar behind the triggerbar breaks out.
    There is no trade if the first bar behind the popgung dont breaks out.
    It seems to be more difficuilt than expected. Thanks for your help.

    #207841 quote
    GraHal
    Participant
    Master

    Works fine for me … see attached.

    with values A4 to A7 optimised to whatever you think suits your chosen TF and Instrument.

    Please confirm that you are doing above and not trying to run the code with the text – A4, A5, A6 and A7 – in the code??

    killerplatuze thanked this post
    Kill.jpg Kill.jpg
Viewing 15 posts - 16 through 30 (of 47 total)
  • You must be logged in to reply to this topic.

Breakout next 5 Bars


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 46 replies,
has 5 voices, and was last updated by Chrisinobi
3 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/15/2023
Status: Active
Attachments: 11 files
Logo Logo
Loading...