Breakout next 5 Bars
Forums › ProRealTime English forum › ProOrder support › Breakout next 5 Bars
- This topic has 46 replies, 5 voices, and was last updated 1 year ago by Chrisinobi.
-
-
01/15/2023 at 2:33 PM #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]
01/15/2023 at 5:24 PM #207468Try this one…
PopGun System12345678910111213DefParam CumulateOrders=False//PopGunIf High[7]>High[6] and Low[7]<Low[6] and High[5]>High[6] and Low[5]<Low[6] thenIf Low[4]<Low[5] or Low[3]<Low[5] or Low[2]<Low[5] or Low[1]<Low[5] or Low<Low[5] thenSellShort 1 contract at MarketSet Stop Price Low[5]+5EndIfIf High[4]>High[5] or High[3]>High[5] or High[2]>High[5] or High[1]>High[5] or High>High[5] thenBuy 1 contract at MarketSet Stop Price High[5]-5EndIfEndIf1 user thanked author for this post.
01/15/2023 at 6:52 PM #207473This 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.
12345678910111213DefParam CumulateOrders=FalsePG = High[2]>High[1] and Low[2]<Low[1] and High>High[1] and Low<Low[1]TP = AverageTrueRange[1]//PopGunIf PG thenIf High[3] OR High[4] OR High[5] OR High[6] OR High[7] thenBuy 1 contract at MarketSet Stop Price Low[2]-5Set Target Profit TPEndIfEndif01/15/2023 at 8:03 PM #207476You 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.
01/15/2023 at 8:45 PM #207477Thx, 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.
01/15/2023 at 9:03 PM #207479Unfortunately it doesn’t work that way, the order is…
- B[5] is the trigger bar
- B[4] is the breakout bar, here is the condition true and then the next bar…
- Buy when B[3] opens…
This is the order in which PRT processes the market orders…
01/15/2023 at 9:13 PM #207481Alternatively, 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.
01/15/2023 at 9:41 PM #207482This Order must be canceled if no bar gets a trigger, how can in do this?
01/15/2023 at 10:06 PM #207483These 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.
01/15/2023 at 10:49 PM #207485I think you can reduce the code to this…
PopGun v2123456789DefParam CumulateOrders=False//PopGunIf High[7]>High[6] and Low[7]<Low[6] and High[5]>High[6] and Low[5]<Low[6] thenBuy 1 contract at High[5] STOPSellShort 1 contract at Low[5] STOPSet Stop Price Low[5]+5Set Stop Price High[5]-5EndIf01/15/2023 at 11:16 PM #207487I 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.
01/16/2023 at 8:33 AM #207490Something is wrong, the trade starts much too late
01/16/2023 at 9:13 AM #20749501/16/2023 at 9:30 AM #20750212345678910111213DefParam CumulateOrders=False//PopGunIf High[7]>High[6] and Low[7]<Low[6] and High[5]>High[6] and Low[5]<Low[6] thenIf Low[4]<Low[5] or Low[3]<Low[5] or Low[2]<Low[5] or Low[1]<Low[5] or Low<Low[5] thensellShort 1 contract at Low[5] STOPSet Stop Price Low[5]+5EndIfIf High[4]>High[5] or High[3]>High[5] or High[2]>High[5] or High[1]>High[5] or High>High[5] thenBuy 1 contract at High[5] STOPSet Stop Price High[5]-5EndIfEndIfThis is the code, same result. Trade starts much too late. Its crazy.
01/16/2023 at 6:51 PM #207516Hi,
You can try this one…
The problem is that your PopGun in its current form does not indicate a direction (Long or Short)…
PopGun v312345678DefParam CumulateOrders=False//PopGunIf High[2]>High[1] and Low[2]<Low[1] and High>High[1] and Low<Low[1] thenBuy 1 contract at High STOPSet Stop Price High-50SellShort 1 contract at Low STOPSet Stop Price Low+50EndIf1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on