Buying in the middle of the candle
Forums › ProRealTime English forum › ProOrder support › Buying in the middle of the candle
- This topic has 10 replies, 6 voices, and was last updated 7 years ago by Despair.
-
-
07/03/2017 at 6:17 PM #3971512345678910111213141516171819202122232425262728293031323334353637383940// FOREX BREAKOUT// 15 MIN// One order per day, from 09:00h. The system shuts-down at 14:00h// Everyday Channel formation from 0800 to 0900 (Highest-Lowest)DEFPARAM CUMULATEORDERS = false// OPERATIONAL TIMEDEFPARAM FLATBEFORE = 090000DEFPARAM FLATAFTER = 140000Operationaltime = TIME > 090000 AND TIME < 140000// ONE TRADE PER DAY. It resets the variable each new dayIF INTRADAYBARINDEX = 0 THENalreadytraded = 0ENDIF// RANGE between 0800h to 0900hIF TIME=090000 THENresistance = Highest[4](high)support = Lowest[4](low)ENDIF// LONG Positions-OpeningIF Operationaltime AND alreadytraded = 0 THENBUY 1 CONTRACT AT resistance STOPalreadytraded = 1ENDIF// SHORT Positions-OpeningIF Operationaltime AND alreadytraded = 0 THENSELLSHORT 1 CONTRACT AT support STOPalreadytraded = 1ENDIF// STOP & PROFITSET STOP LOSS 8*pipsizeSET TARGET PROFIT 8*pipsize
Hi everyone,
I am sending attached a very simple breakout strategy that I have been on and off for a week. I have one problem with the coding.
Every time the price breakouts the highest or lowest from the 4 previous candles, I would like to buy exactly at the point where the price breaks the ceiling of floor, not at the beginning of next candle. I have removed MARKET from the equation and created an STOP order, but still not working.
I am attaching a pdf drawing of an example of what I am intending to do, for a better understanding.
Thanks to everyone,
Juan
07/03/2017 at 7:49 PM #3972007/03/2017 at 9:22 PM #39726You can’t!
Strategies, at least until the Multitimeframe feature is provided, are only executed at each new candle, not in the middle or elsewere.
You may try to switch to 1 minute TF and adjust computations so that it “looks like” (not exactly, especially if you want to deal with Moving Averages) being executed in a 15min TF.
Examnple with your code (15 1-minute bars for each 15-minute bar):
12345// RANGE between 0800h to 0900hIF TIME=090000 THENresistance = Highest[60](high) //4 * 15support = Lowest[60](low) //4 * 15ENDIFHope you can manage to run your strategy as expected.
07/03/2017 at 10:00 PM #39731Hi Roberto,
Thanks for your answer!!! It seems a good idea to convert the one 15′ candle into 15/one minute candles, so the breakout moment can be pinpoint with more precision than before.
Nevertheless, I thought that putting a limit or stop order at an specific point would spark the order in the middle of the candle. I have struggling with this for a week.
Thanks so much for your help!!!
Juan
07/04/2017 at 9:35 AM #39759you can also use intradaybarindex to count the bars
(indicator)
x = bars from start of the day
y = range (4 if you want 1 hour of 15-min bars)
BO Indicator High123456IF IntradayBarIndex = x THENHi = HIGHEST[y](HIGH)ENDIFRETURN Hiand then use stoporder
but i wonder if the 1 trade per day will work with stoporders?
1 user thanked author for this post.
07/04/2017 at 10:15 AM #39769Thanks Eric. Yes the “1 trade per day” should work if the variable is incremented like the way Juan did in his first post. But the STOP order will only be set during 1 bar (stop orders expire each new bar). To count pending orders, there is no other way I’m afraid.
07/04/2017 at 1:45 PM #39791Hi Eric,
Thanks for your contribution. I will study your option. Right not, I am applying what Roberto said and it seems a good idea since I can’t buy right at the break-out at the same candle. So, I am breaking the 15′ candle in 15 small ones.
I thought that placing an stop order at that point will work (BUY 1 CONTRACT AT resistance STOP), but it doesn’t work.
Thanks,
Juan
07/06/2017 at 9:00 AM #39930I have the same problem as Juan. In the Assisted ProBacktest Creation window, there is a drop-down box under the ‘Buy’ section at the bottom with one item in it – ‘next bar open’.
Presumably, since this is a drop-down box, it would be expected that there would be a range of options there (eg ‘on next tick’ and/or ‘x pips higher’). Is that correct? Presumably, Roberto, that’s what you meant when you referred to the Multitimeframe feature being provided? When will this upgrade be available, does anyone know?
Also, Roberto, you referred to converting a 15-minute candle into 15 one-minute candles, but I don’t understand your code (I’m a complete beginner). How do I make that conversion?
07/06/2017 at 3:22 PM #39957To switch from a 15-min TF to a 1-min TF all you have to do is multiply bar references by 15 (there are 15 1-minute bars in a single 15-min bar).
This is pretty simple in the above case (the example with HIGHEST/LOWEST), but it is not as easy if you are within minute 20 bar (say 102000) and want to know the closing price of the previous 15-minute candle, because if you write
1close[15]you get the closing price at 10:05:00 which is NOT the closing price of the previous 15-minute bar (that was at 10:15:00), just the closing price 15 bars ago.
As you can see there are cases in which you can find a solution using such conversions/adjustments, but in many other cases you can’t make it work as expected.
The final solution is….. we all have to wait for the MultiTimeFrame feature in a (hopefully near) future release of ProOrder!
07/10/2017 at 6:56 AM #40187Yes, noted, thanks.
07/10/2017 at 7:15 AM #401891234triggerdown=lowest[4](low)triggerdup=highest[4](high)buy 1 contract at triggerup stopsellshort 1 contract at triggerdown stopThe only way to buy “in the middle of a candle” are stop-orders.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on