How to create a breakout box between 2 hours, Code please?
Forums › ProRealTime English forum › ProOrder support › How to create a breakout box between 2 hours, Code please?
- This topic has 56 replies, 5 voices, and was last updated 6 years ago by robertogozzi.
Tagged: BreakOut
-
-
10/18/2018 at 3:04 PM #83115
This version waits for the breakout to occur, then places pending LIMIT orders to enter at a better price when it retraces to the range border (but you can enter AT MARKET if you prefer):
123456789101112131415161718192021222324252627282930313233defparam flatafter = 210000if longonmarket thenalreadybuy=1endifif shortonmarket thenalreadysell=1endifif intradaybarindex=0 thenalreadybuy=0alreadysell=0myprofit=strategyprofitendifif time = 060500 thenyh = highest[85](high)yL = lowest[85](low)endiftcondition = time>074500 and time<205000if tcondition and strategyprofit<=myprofit and yh>0 and yl>0 thenif close>yh and not alreadybuy thenbuy 1 contract at yh limitendifif close<yl and not alreadysell thensellshort 1 contract at yl limitendifendifset stop ploss 15set target pprofit 151 user thanked author for this post.
10/18/2018 at 3:45 PM #8312010/24/2018 at 4:18 PM #83446Roberto, Many thanks for all your help. 😉
5mins, Wall Street.
Using today as an example, a LIMIT order would have entered at 12:00, after the re-test.
AT MARKET would have entered at 07:45, after the close under the yl.
Is it not possible to enter during the 07:40 candle, as it crosses the yl line, using any code?
I have changed the settings, crossover yl, low of yl, but the code seems to require a close below the yl, to setup the trades.
I have attached a chart to show examples, I would like to buy on the cross (not necessarily the close) of the yl or yh?
I can set a deal to open / limit order, through IG and they will buy/sell whenever.
I think I am going to have to give up shortly, but being so close and after all the help you have given me, it seems a shame. ;(
10/25/2018 at 1:21 AM #83482Replace LIMIT with STOP at lines 25 and 28, since you are willing to enter a new trade at a worse price, while LIMIT should be uses to enter at a better price, instead.
If the entry price is not exactly the one you wanted (which I experienced backtesting the trade you pointed out in your screenshot), I guess it’s due to the current price (last pending order placed at the closing of the bar preceding the entry one) being too close to your desired entry price.
1 user thanked author for this post.
10/25/2018 at 2:20 PM #83517Roberto,
Many thanks for looking into it again. 😉
I have changed it to STOP, but as you experienced in the backtest, it still doesn’t work all the time.
I’ll have to monitor it.
Thanks for all your help, it is much appreciated. 🙂
10/25/2018 at 2:45 PM #83525You can use IF…ENDIF to make it work at all times:
1234567IF close > yH THEN //if current price is higher than YH then...buy 1 contract at yH limit //... buy at a most favourable priceELSIF close < yH THEN //if it lower, then...buy 1 contract at yH stop //... buy at a worse priceELSE //should it be the same price...buy 1 contract at market //... buy immediatelyENDIF1 user thanked author for this post.
10/25/2018 at 4:12 PM #83533More than 1 buy / sell12345678910111213141516if tcondition and strategyprofit<=myprofit and yh>0 and yl>0 thenIF close > yH and not alreadybuy THEN//if current price is higher than YH then...buy 1 contract at yH limit //... buy at a most favourable priceELSIF close < yH THEN //if it lower, then...buy 1 contract at yH stop //... buy at a worse priceELSE //should it be the same price...buy 1 contract at market //... buy immediatelyENDIFIF close < yl and not alreadysell THEN//if current price is higher than YH then...sellshort 1 contract at yl limit //... buy at a most favourable priceELSIF close > yl THEN //if it lower, then...sellshort 1 contract at yl stop //... buy at a worse priceELSE //should it be the same price...sellshort 1 contract at market //... buy immediatelyENDIFENDIFThis is picking up trades I was expecting, but it is also taking more trades.
I have added AND NOT ALREADY BUY / SELL to the above code, but it still produces 7 trades today, I was after 1 long / 1 short per day. (which is coded)
It should have entered at 08:25 only today. (Screenshot attached) For some reason it also entered at 08:30,13:45,13:50 etc.
The other point is that on the 24/10/18, even after your amended code, the short trade at 07:40 does still not occur. (Screen shot attached.)
Is it to do with the candle close and it going straight through the yl / yh.
10/25/2018 at 4:27 PM #83537The problem with ALREADYBUY/ALREADYSELL is that at lines 3 and 6 ProOrder takes 1 bar to become aware of being OnMarket. In case (as it happens) the pending orders is entered and exited within the same bar ProOrder will never be aware of them, thus leaving those variables unset.
That’s why so many trades are entered!
There’s no work around, unless you use MTF to launch your strategy from a lower TF (say 1 minute), but this won’t grant you that a single 1-minute bar cannot have a range of 15+ pips! For sure this solution will work in most cases, though not always. MTF is still being beta tested and not recommended for real trading.
10/25/2018 at 4:50 PM #83538Roberto,
Many thanks again. 🙂
I will have to keep monitoring the trades for the anomalies that are deleted by prorealtime.
Last question, (I sound like Columbo, 😉 ) Is there anyway prorealtime will alert me, SMS, when a trade is deleted?
I know they can SMS, when a trade is: opened/closed / edited.
10/25/2018 at 5:34 PM #83542What do you mean by DELETED?
Anyway, I think I cannot help you because I’ve never used that kind of alert.
10/26/2018 at 2:21 PM #83567I trade through IG and the trades get set up through the pro-order automatic trading system.
On the 24/10/18, Wall Street, 5m, using the system I had running, I had orders in the system at 25303.1 BUY & 25165.1 SELL.
At 7:40, Instead of selling short at 25165.1 the order got deleted (by ProOrder)
This happens every now and again, I don’t know why the trades get deleted?
(I did amend the time to 0730-2050 so it isn’t a time issue)
Thanks for your reply anyway. 🙂
10/26/2018 at 4:53 PM #83569All pending oreders are DELETED at every bar’s closure.
You need to place then again and again, bar after bar, if you wish to keep them pending.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on