Order Timing  [SOLVED]

Questions about MultiCharts and user contributed studies.
rreyes22
Posts: 15
Joined: 12 Apr 2016
Has thanked: 1 time

Buy {"BUY"} Next Bar at Open ;

Postby rreyes22 » 29 Mar 2018

I am using "Buy Next Bar Open" and "Buy Next Bar Market" and I am assuming that this means the first tick at the opening of the next bar, but this is not happening. My "Buy" at the next bar is happening all up and down the next bar, usually from the middle of the bar on up to the "High" of the bar, never at the opening. I have tried using different data feeds ( IQFeed and Interactive Brokers ), but I still am getting the same results. I understand that the data is coming into the MultiCharts platform in mega seconds so I don't understand the resulting "Buy" at the next bar being so erratic. My automated strategy (Signal) depends on a Buy position at the opening of the next bar (first tick) foe me to realize any profit, anything else will create a losing position. The answer to the problem should lie with MultiCharts. Can anyone help??

hughesfleming
Posts: 275
Joined: 22 Apr 2014
Has thanked: 70 times
Been thanked: 72 times

Re: Buy {"BUY"} Next Bar at Open ;

Postby hughesfleming » 29 Mar 2018

Where are you located and what time frame are you using? Your strategy sounds very time sensitive. Take a look at your log and see when your order gets generated and when it is filled. In fast markets, you may very well get filled well into the next bar.

There is not much you can do about that. You can reduce the effect of this latency by collocating which may or may not solve your problem. You may have to rethink your strategy. Time sensitive strategies and retail trading rarely work. There are a lot of limitations.

Alex

rreyes22
Posts: 15
Joined: 12 Apr 2016
Has thanked: 1 time

Re: Buy {"BUY"} Next Bar at Open ;

Postby rreyes22 » 29 Mar 2018

Alex, I am located in San Antonio, Texas and I am on a 5 minute chart. Many Thanks

hughesfleming
Posts: 275
Joined: 22 Apr 2014
Has thanked: 70 times
Been thanked: 72 times

Re: Buy {"BUY"} Next Bar at Open ;

Postby hughesfleming » 29 Mar 2018

Check what the log says about your fills. You should be able get a time stamp from IB as well. You should be able to check the time/sales at the bar open time to see how many orders filled ahead of you. This will depend on liquidity and the volatility of your instrument. Keep in mind that your quote gets generated at the exchange, has to travel to Nebraska where IQFeed have their servers. It then goes to you in San Antonio and then to NJ where IB receive your order. They do their risk management and your order gets routed from there. There are many internet related delays that could technically slow your order.

There are a lot of possible reasons why your orders fill where they do.

regards,

Alex

rreyes22
Posts: 15
Joined: 12 Apr 2016
Has thanked: 1 time

Re: Buy {"BUY"} Next Bar at Open ;

Postby rreyes22 » 29 Mar 2018

Alex, would it make sense to use the data coming from IB instead of IQFeed thereby taking out a third party and therefore the data would come from IB to MC and then the Buy order would go back to IB. Does this make sense? I am looking at everything. Many Thanks for all your help.

Zheka
Posts: 223
Joined: 13 Jan 2016
Has thanked: 8 times
Been thanked: 53 times

Re: Buy {"BUY"} Next Bar at Open ;

Postby Zheka » 29 Mar 2018

But does it work as it should in backtesting?

rreyes22
Posts: 15
Joined: 12 Apr 2016
Has thanked: 1 time

Re: Buy {"BUY"} Next Bar at Open ;

Postby rreyes22 » 29 Mar 2018

The strategy works as it should when I back test it. All Buy orders are executed at the opening of the next bar in back testing, but in real time, the Buy is executed all over the next bar and usually in the upper half of the bar.

Zheka
Posts: 223
Joined: 13 Jan 2016
Has thanked: 8 times
Been thanked: 53 times

Re: Buy {"BUY"} Next Bar at Open ;

Postby Zheka » 29 Mar 2018

Does the order get executed on time, i.e. as soon as the next bar opens?

rreyes22
Posts: 15
Joined: 12 Apr 2016
Has thanked: 1 time

Re: Buy {"BUY"} Next Bar at Open ;

Postby rreyes22 » 29 Mar 2018

In real time trading (Demo), the order does not get executed at the opening of the next bar, that is the problem. The strategy works as it should when back tested, but does not work in real time.

Zheka
Posts: 223
Joined: 13 Jan 2016
Has thanked: 8 times
Been thanked: 53 times

Re: Buy {"BUY"} Next Bar at Open ;

Postby Zheka » 29 Mar 2018

My question was about the time, not price. How much time passes - on average - since bar open? Is there a pattern?

rreyes22
Posts: 15
Joined: 12 Apr 2016
Has thanked: 1 time

Order Timing

Postby rreyes22 » 03 Apr 2018

I have a continuing problem in the timing of my BUY trigger coming from my automated strategy (Signal). I have spoken with IB about this and they have referred me back to MC. My BUY line reads "Buy next bar open" and this should mean that at the open of the next bar, at the first tick, the code will trigger a BUY. IB is telling me that when they receive my BUY order, the order is execute within mega seconds and acknowledgement is sent back to MC almost immediately. So the entire round trip from MC to IB and then back to MC should not even take 1 second. This is not the case and IB has instructed me to check my order logs which I have. In one specific trade, using the orders tab > "Generated" tab, this specific trade was generated at 10:10:00.732 and was "Filled" at 10:10:00.919 only a millisecond later. Looking at the time that passed, my trade should be reflected on the corresponding "next bar" at or close to the opening tick of this next bar yet it is not. Please take a look at my chart and corresponding bar Smiley: Sleeping Half Moon to see what you make of this problem. IB is telling me that there may be a delay in the way that MC processes orders, I hope not because my profit model is predicated on my order being filled at the opening of the next bar.
Last edited by rreyes22 on 03 Apr 2018, edited 1 time in total.

User avatar
Smoky
Posts: 507
Joined: 03 Dec 2010
Location: Thailand
Has thanked: 97 times
Been thanked: 115 times

Re: Order Timing

Postby Smoky » 03 Apr 2018

hi Rreyes22 this forum is public, dont give TeamViewer login and password here !

send it by chat for support ;-)

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Order Timing

Postby TJ » 03 Apr 2018

I have a continuing problem in the timing of my BUY trigger coming from my automated strategy (Signal). I have spoken with IB about this and they have referred me back to MC. My BUY line reads "Buy next bar open" and this should mean that at the open of the next bar, at the first tick, the code will trigger a BUY. IB is telling me that when they receive my BUY order, the order is execute within mega seconds and acknowledgement is sent back to MC almost immediately. So the entire round trip from MC to IB and then back to MC should not even take 1 second. This is not the case and IB has instructed me to check my order logs which I have. In one specific trade, using the orders tab > "Generated" tab, this specific trade was generated at 10:10:00.732 and was "Filled" at 10:10:00.919 only a millisecond later. Looking at the time that passed, my trade should be reflected on the corresponding "next bar" at or close to the opening tick of this next bar yet it is not. Please take a look at my chart and corresponding bar Smiley: Sleeping Half Moon to see what you make of this problem. IB is telling me that there may be a delay in the way that MC processes orders, I hope not because my profit model is predicated on my order being filled at the opening of the next bar.

You have to give more specific detail.

Please go to your database and call up the quotes at 10:10:00.732 and 10:10:00.919.
Did you get filled at the price of the time?

What is your chart resolution?

For the record, there is NO such a specific quote that is called "Open" except the first quote of RTH.
All the other so-called "Open" of an intraday-bars are strictly conjectural.

rreyes22
Posts: 15
Joined: 12 Apr 2016
Has thanked: 1 time

Re: Order Timing

Postby rreyes22 » 03 Apr 2018

My code command is "Buy ("BUY") next bar Open" Open could be substituted with Market as they both refer to the first tick of the next bar. The two (2) times that I gave in my initial question are for Buy time generated and for time filled. These times are coming straight form the "Order and Position Tracker Window > Orders tab". The time between order generated and order filled is in the 100ths of a second yet the Buy Arrow on the next bar (the buy next bar bar) is showing the actual Buy at a different spot other than the open first tick. If the order is filled in a 100th of a second, then the buy arrow on the bar (positive bar) should be at the bottom most point on the bar, just like in back testing. In back testing everything works as it should. Please advise. Many Thanks

hughesfleming
Posts: 275
Joined: 22 Apr 2014
Has thanked: 70 times
Been thanked: 72 times

Re: Order Timing

Postby hughesfleming » 04 Apr 2018

rreyes22,

What are you trading and what is the spread? You are sending market orders, not limit orders. Also, what is the average duration of your trades? Keep in mind that real time data and historical data don't match perfectly. I often have targets and stops hit in real time that don't show up when I run a back test later. The only thing that matters is the PnL at the broker. If your back test and your broker PnL is way off then there is something fundamentally wrong with the assumptions you are making in your strategy.

Zheka
Posts: 223
Joined: 13 Jan 2016
Has thanked: 8 times
Been thanked: 53 times

Re: Order Timing

Postby Zheka » 04 Apr 2018

What's wrong with what you described? An arrow placed incorrectly or the real trade?

What's the timestamp of the first tick (=open) of this bar? By default, MC opens a bar only when the first tick of it appears.

A screenshot would help.

rreyes22
Posts: 15
Joined: 12 Apr 2016
Has thanked: 1 time

Re: Buy {"BUY"} Next Bar at Open ;

Postby rreyes22 » 04 Apr 2018

Please note the Log at the bottom of the Chart Window. There is little to no difference from the Order Generated time and the Order Filled time. Next note the placement of the Green Buy Arrow on the next bar - "Buy Next bar Open". What is happening and why the big difference between Order Filled time and the placement of the actual trade on the bar on the chart? Many Thanks
MultiCharts2.png
(151.15 KiB) Downloaded 2259 times

rreyes22
Posts: 15
Joined: 12 Apr 2016
Has thanked: 1 time

Re: Order Timing

Postby rreyes22 » 04 Apr 2018

I am trading the E-MINI S & P 500 on a 5 minute time frame. Plenty of liquidity, minimal spreads and a supposedly fast, quick almost instantaneous fill.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Buy {"BUY"} Next Bar at Open ;

Postby TJ » 04 Apr 2018

Please note the Log at the bottom of the Chart Window. There is little to no difference from the Order Generated time and the Order Filled time. Next note the placement of the Green Buy Arrow on the next bar - "Buy Next bar Open". What is happening and why the big difference between Order Filled time and the placement of the actual trade on the bar on the chart? Many Thanks

MultiCharts2.png

Please take ONE example and show us a magnified chart.
Please draw/write on the chart/statement what is the specific problem you see.
ie what is shown on the chart/statement, and what do you think the right answer should be.

As is, there are a ton of information there. People are not going to scrutinize it to find the "needle" in the haystack that is wrong.

Zheka
Posts: 223
Joined: 13 Jan 2016
Has thanked: 8 times
Been thanked: 53 times

Re: Buy {"BUY"} Next Bar at Open ;

Postby Zheka » 04 Apr 2018

You don't have a problem.

The difference between the arrows and the fills is because of Heikin-Ashi bars; HA Open is not determined by time.

rreyes22
Posts: 15
Joined: 12 Apr 2016
Has thanked: 1 time

Looking For "BUY" Code

Postby rreyes22 » 05 Apr 2018

I am looking for a BUY code that will allow me to BUY the next bar at Open and I mean that I want to BUY the very first tick of the bar when the bar opens. "Buy Next Bar at Open/Market" does not work. Need help, many thanks

hughesfleming
Posts: 275
Joined: 22 Apr 2014
Has thanked: 70 times
Been thanked: 72 times

Re: Looking For "BUY" Code

Postby hughesfleming » 06 Apr 2018

rreyes22,

I don't think that you need to keep opening new threads that ask the same question. People here are responding to you because they are trying to help you. As Zheka explained to you, you will never get close to the new bar open if you are using Heiken-Ashi bars. Your back tests will be flawed. This goes for many other bar types as well. If you had a strategy that had a long holding duration, you might get away with HA bars but not with a strategy that exits on the next bar. Think about using bars that don't filter price in some way. You still have many choices.

As far as being able to consistently buy the first tick of a new bar.....that is another unrealistic assumption. With market orders, there is always a chance of slippage. There will always be traders in front of you who are faster than you. You can't compete on speed using retail platforms. Look at the current ranges compared to last year. There are strategies that just fall apart in high volatility. You have two choices, adapt your strategy to the current market conditions or stay out and wait.

Spend some time to see why your equity curve does not correspond to what you see in your broker PnL. Everyone that has ever tried to build an automated trading system has fallen into that trap at least once. Add in two ticks of slippage and make sure you are accurately accounting for your trading cost. If your equity curve falls apart then you are cutting it too tight with your strategy. If the tick sizes are too large in the ES mini, see if your strategy works on SPY where the spread is much tighter. Read up on curve fitting, selection bias, look ahead bias and all the other reasons systems fail in the real world. There is plenty of material out there on this subject.

Alex

Zheka
Posts: 223
Joined: 13 Jan 2016
Has thanked: 8 times
Been thanked: 53 times

Re: Looking For "BUY" Code

Postby Zheka » 06 Apr 2018

Alex, you are soooo generous and kind to spend 20+min of your precious time on smbdy who does not listen, is not appreciative of other people's time, lazy to do the homework and/or just does not get it.

IMHO, 1-2-3 ->ban! (or ignore)

As for buying exactly the "opening tick" : for strategies not utilising stop orders for entry, there is no real material benefit to expending time and resources to reduce the latency of getting to the market asap. 50% of the time you will get a better price, 50% - worse.....same -on balance.

rreyes22
Posts: 15
Joined: 12 Apr 2016
Has thanked: 1 time

Re: Order Timing  [SOLVED]

Postby rreyes22 » 17 Apr 2018

To everyone, thank you as due to your responses, I have figured it out and now my entry orders are literally at the Open in every case - live trading. Again, many thanks to all and to ZHEKA, get out every once in awhile, there is more to the world than just yourself.

Zheka
Posts: 223
Joined: 13 Jan 2016
Has thanked: 8 times
Been thanked: 53 times

Re: Order Timing

Postby Zheka » 18 Apr 2018

Negotiations (and changes) start with the word "NO" :-)

User avatar
Sky
Posts: 47
Joined: 05 Dec 2013
Has thanked: 19 times
Been thanked: 4 times

Re: Order Timing

Postby Sky » 09 Jun 2018

Hey rreyes22.........it's kind of customary to share a solution that you stated you discovered from the forums as you asked for help with a problem. Many of us would like to know how you solved your problem as it may come in handy for our own coding solutions. Please share with us how you place the orders on the open. I have a similar problem for my back testing and wonder if: "buy next bar at open limit" will solve the problem? If not, please tell us how you overcame the hurdle. Thanks


Return to “MultiCharts”