Buy/close a position right at open

Forums ProRealTime English forum ProOrder support Buy/close a position right at open

Viewing 15 posts - 1 through 15 (of 30 total)
  • #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:

    1. Does this seem like a viable thing to do?
    2. 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

    #155574

    2. 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.

     

     

    #155576

    To buy at the open, and 09:30 is what you want, then you can use

    I 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.
    #155579

    Sorry, I hadn’t seen Roberto’s reply and assumed you were trading indices – no idea if this would work for shares.

    #155620

    Thank 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?

    #155622

    The 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/

    #155629

    You 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.
    #155802

    This one should work

    Bougth 2 at open and 1 at top (on demo)

     

     

     

    #155804

    Is it something wrong with this forum as things dissapear for some resaon?

     

     

    #155805

    What disappeared?

     

    #155806

    Sorry

    wrong thread delete this and the one before

    and maybe move the code and picture to the other thread? (orders through alert)

     

    time for a break i think

    #155810

    I can move it if you post a link to the correct thread.

     

    #156161

    I do confirm that auto trading stocks is possible with IG through ProOrder.

    1 user thanked author for this post.
    #156366

    Hi 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):

    Does 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?

    #156394

    Does 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.

Viewing 15 posts - 1 through 15 (of 30 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login