Is it possible to buy at open?
Forums › ProRealTime English forum › ProOrder support › Is it possible to buy at open?
- This topic has 5 replies, 2 voices, and was last updated 6 years ago by
Vonasi.
-
-
11/29/2018 at 4:29 PM #86011
Im wondering if there is a way to buy/sell exactly at the open on a lower timeframe strategy.
The following code works at backtest but not when running demo.
12345678910111213141516171819202122232425/-------------------------------------------------------------------------// Main code : buyopen Dow 5min//-------------------------------------------------------------------------DEFPARAM Cumulateorders = FalseDEFPARAM flatafter = 160000TIMEFRAME(5 minutes, default)buytime = currenttime > 152600 and currenttime < 153400size = 1If buytime THENBuy size contracts at marketENDIF11/29/2018 at 4:58 PM #86014On a 5 minute chart if you want to buy at 1530 then just write:
123if time = 153000 thenbuy 1 contract at marketendifDoes it buy in demo at a different time if so maybe it is your chart time settings?
1 user thanked author for this post.
11/29/2018 at 7:40 PM #86038Thank you for your answer!
I want to execute an order at exactly the open. But i want one parameter to be where the open is. For example over or below ma200.
The code below works in backtest but i fear that it will execute first 1 candle after the open. Guess il have to see tomorrow.
1234567891011121314DEFPARAM PRELOADBARS = 1000DEFPARAM Cumulateorders = FalseDEFPARAM flatafter = 160000timeframe(daily)ma200=average[200]TIMEFRAME(5 minutes, default)if time = 153000 and open[0]>ma200 thenbuy 1 contract at marketendif11/29/2018 at 7:55 PM #86039All decisions are made by any code at the close of a candle. So on your 5 minute chart the candle that opens at 1525 and closes at 1530 is the one you want to use. That candle has a TIME = 153000 and an OPENTIME = 152500.
So if you use OPEN[0] < AVERAGE[200] then it will be the opening price at 1525 that is used for the comparison. You cannot use the opening price of the next candle as all decisions are made at the close of a candle. This is only an issue in markets where there is a big gap between the close of the 1525 candle and the open of the 1530 candle.
I hope this makes things clearer!
Note: Also if you are not using MTF then you do not need to put the TIMEFRAME command in your code. just launch it on 5 min time frame and it will make decisions based on this.
11/30/2018 at 9:19 AM #86059So tried the code on the dax open now and it didnt execute, still works on backtests. Im using custom timezone UTC +01:00 with custom trading hours 09:00:00-17:30:00
im guessing that i have to change the custom time to 08:55:00 for it to work. since the open[0]>ma200 is outside the timezones
12345678910111213141516171819202122DEFPARAM PRELOADBARS = 1000DEFPARAM Cumulateorders = FalseDEFPARAM flatafter = 173000timeframe(daily)ma200=average[200]TIMEFRAME(5 minutes, default)if time = 090000 and open[0]>ma200 thenbuy 1 contract at marketendifif time = 090000 and open[0]<ma200 thensellshort 1 contract at marketendifset stop ploss 50set target pprofit 5011/30/2018 at 10:26 AM #86062I don’t use any custom hours as it just adds an extra level of confusion in my mind so I just use my memory to know when markets open and close on a UTC0000 chart so I have to guess that you are right about needing a 0855 candle as if you have set the chart to display from 0900 onwards then you have eliminated your decision candle which opens at 0855 and closes at 0900.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on