Buy/close a position right at open
Forums › ProRealTime English forum › ProOrder support › Buy/close a position right at open
- This topic has 29 replies, 7 voices, and was last updated 3 years ago by therookie.
-
-
12/29/2020 at 3:09 PM #155569
Hi,
I am used to trading with Tradestation and Easylanguange so please excuse my very simple beginner question.
I will be trading only CFD-shares were I will ONLY buy or close positions at the open of the market and keep the position between 24 hours or up to 1 week. I will find the buy and sell signals through other platforms and will not be using PRT for that. Now so far I have been taking the trades manually but sometimes I have to take many trades at the open which makes some of the trades being delayed by up to a minute or two which is not good as they can be different from my backtesting results. I have been looking for a CFD-broker that allows you to buy “at-open-orders” but have so far been unsuccessful. So I saw that IG allows you to easily connect to PRT and I figured there has to be a simple way to code so that the PRT sends out a buy or sell order directly at the open of the market. I understand that I will have to prepare the chart and automated strategy for the specific trades each day before the open or the night before and after the trade is taken I have to deactivate the strategy so it doesnt take the same trade the day after.
So my questions are these:
- Does this seem like a viable thing to do?
- How would I achive this the easiest way and what would the best way to code this be? I assume it would be something simple like “if time > 0929 (for the american market) then buy next bar at market” or something similar and “sell next bar at market” for closing the position but I would appreciate if someone could give me the correct code.
Any help would be greatly appreciated.
Best regards
12/29/2020 at 4:39 PM #1555742. CFD’s usually don’t close, or just for a very short time, since they do not share futures/exchange trading hours, again you should check with IG
3. orders cannot be placed outside trading hours, so to enter a trade as soon as the market opens you need to place an order when the market is about to close the previous day; since, CFD’s do not share the real market trading hours, you can certainly place an order immediately when the market opens. For example DAX, IG closes it just one hour at night, so if you want to enter a trade when the official market opens (but there’s no relations between Futures and CFD’s, but for the price which can be similar) you can do it.
12/29/2020 at 4:48 PM #155576To buy at the open, and 09:30 is what you want, then you can use
1234567If time = 093000 and (your long conditions) thenbuy 1 contract at marketendifIf time = 093000 and (your short conditions) thensellshort 1 contract at marketendifI recently coded a strategy with this same idea for the FTSE, you may be able to adapt it for your purposes.
1 user thanked author for this post.
12/29/2020 at 4:53 PM #155579Sorry, I hadn’t seen Roberto’s reply and assumed you were trading indices – no idea if this would work for shares.
12/29/2020 at 9:29 PM #155620Thank you all. I will try the code that nonetheless provided.
And thank you robertogozzi for your inputs and I will ask IG. However what a strange thing to not specifically allow automatic trading for stock-CFDs. I wonder what the reasoning behind that is…
As of now I am using another broker and their stock-CFDs follow the opening hour of the underlying stock but I will check how it is on IG.
However there is one potential issue with using a specific time to take the trade (won’t be an issue if the CFD-share have a premarket I guess). Sometimes I noticed that the CFD-share opens a few seconds later than the underlying shares open. Is there a way to code so PRT buys the next bar at market (if you use daily bars) so the trade is taken as soon as the next bar is formed. This way the trade should be taken no matter what I guess. This is Easylanguage logic but I wonder if it would be possible with PRT?
Also do I have to write how many shares i want to buy in the code? Isn’t there a way to specify that in the PRT interface instead?
12/29/2020 at 9:59 PM #155622The FTSE code I attached runs on a 1 minute time frame. If you want to start just after Wall St opens then just change it to “If time = 093100”
Yes, you have to specify your position size in the code.
As you’re just beginning with PRT I would strongly recommend checking out the training videos:
https://www.prorealcode.com/courses/training-program-introduction-programming-prorealtime/
12/29/2020 at 11:25 PM #155629You have to specify the number of equities in your strategy, but you also have to specify a max. number of contracts when you launch it. The lowest of the two is the good one.
1 user thanked author for this post.
12/31/2020 at 3:53 PM #15580212/31/2020 at 3:55 PM #15580412/31/2020 at 4:12 PM #155805What disappeared?
12/31/2020 at 4:17 PM #15580612/31/2020 at 4:28 PM #155810I can move it if you post a link to the correct thread.
01/04/2021 at 10:30 AM #15616101/04/2021 at 11:55 PM #156366Hi again,
Thank you Nicolas, I acctually found out today that ProOrder should work fine through IG.
So I started reading the manual to be able to code what I want and so far I got this for entering the trade in the morning (Observe that this is for a non-US market that opens at 9 am local time without any pre-market):
123If not longonmarket and time > 085900 thenbuy 15000 cash at marketendifDoes this seem correct to you guys as an entry? FYI I will only use daily bars.
Now the question is how I should code the exit? What I want to do is to close the trade at the open on the next bar (next day) and also make sure that no other entry is taken on that day. I will then manually disable the strategy during the day after the position has been closed, so before the third day (so the strategy doesn’t buy at the open on the third day again).
I hope this will be easy to code as I don’t want to spend too much time coding such a simple thing. In worst case I can of course use alerts to do this but to my understanding the PRT software then has to stay open for orders attached to alert trades to go through. But if I use ProOrder then I don’t have to worry if the program closes or I loose internet connection right?
01/05/2021 at 9:56 AM #156394Does this seem correct to you guys as an entry? FYI I will only use daily bars.
There is no 085900 if you use a daily chart. You will have to trade on the one minute time frame to find a bar with a time of 085900.
-
AuthorPosts
Find exclusive trading pro-tools on