Data2 causing orders to be sent late

Questions about MultiCharts and user contributed studies.
monick
Posts: 19
Joined: 20 Nov 2015

Data2 causing orders to be sent late

Postby monick » 20 Nov 2015

I was running a strategy in TS without intra-bar order generation enabled. The strategy has a data1 and a data2. Data1 is heavily traded and Data2 is not. I was relying on the bidsize, bid, ask, and asksize of Data to make decisions about trading Data1 in a short time window (1-5 minutes). Data1 is set to 2 second bars and Data2 to 1 minute bars.

When I swtiched to multicharts, I noticed that orders were being sent on time, late, never, etc, with no consistency. For several days, I could not figure out the problem. Then I looked at the time and sales of data2 and realized that the strategy was waiting for a trade to occur in Data2 before sending the order.

If this is true, why is it true, and is there a way around it? What are the options here? Must I turn on intrabar order generation and use recalclastbar in the code or is there any easier way. Is this set this way by design. Again, TS did not have this problem.

As I use about 5 different entry orders based on how the orderbook in data1 looks, (5 conditions that cannot be true at the same time), I am finding that occasionally this results in double fills with IOG enabled as an order is filled before it has time to cancel and send a different order. Without IOG, the 2 second bars seem to be sufficient to what I am trying to do, but if data2 must trade, then it becomes impossible to have control over time, and I need to have control over the time to within +-2 seconds.

Does anyone have thoughts or experience with this issue?

tony
Posts: 420
Joined: 14 Jun 2013
Has thanked: 30 times
Been thanked: 81 times
Contact:

Re: Data2 causing orders to be sent late

Postby tony » 21 Nov 2015

Do you have real-time history matching unchecked?

monick
Posts: 19
Joined: 20 Nov 2015

Re: Data2 causing orders to be sent late

Postby monick » 21 Nov 2015

I have it checked. Should it be unchecked? This is on the backtest tab, so I didn't think this would influence live trading anyway?

tony
Posts: 420
Joined: 14 Jun 2013
Has thanked: 30 times
Been thanked: 81 times
Contact:

Re: Data2 causing orders to be sent late

Postby tony » 21 Nov 2015

I would uncheck it.
Then I looked at the time and sales of data2 and realized that the strategy was waiting for a trade to occur in Data2 before sending the order.
Is one of your conditionals related to Data2? Stating the obvious, and sorry for doing so, when Data1 has met conditionals for an order to generate but Data2 has not, then obviously you won't generate a signal. And vice versa. Again it's obvious, but sometimes we get so focused on a problem we (at least I do) ignore the obvious.

One other thing to note with multiple data series (and I do not believe this has changed yet), MC in backtesting is able to calculate with bar magnifier resolution on Data1, but on Data2, DataN it is only 4 times per bar OHLC. Which will produce erroneous results.

monick
Posts: 19
Joined: 20 Nov 2015

Re: Data2 causing orders to be sent late

Postby monick » 21 Nov 2015

Yes, One of the conditionals is related to data2, but it only relates to the market (bid, bid size, ask, ask size), nothing to do with a trade occurring or not. So in many if not most cases, the conditions for data2 are met constantly, so i am only waiting for the time component condition to kick in before sending the order. So as I said, I started noticing that let's say for example

I wanted to buy 1 future at time_s > 093100, then the order would not be sent till 093233. Then I looked at time and sales in data2 and sure enough a trade occurred at 093233. But I don't want to wait for this trade to occur. In fact I don't even care at all that it did occur (just the market).

I can turn off real-time history matching and see if this works, but even after reading about this setting, I still don't fully understand it's function in live trading.

tony
Posts: 420
Joined: 14 Jun 2013
Has thanked: 30 times
Been thanked: 81 times
Contact:

Re: Data2 causing orders to be sent late

Postby tony » 21 Nov 2015

Yes, One of the conditionals is related to data2, but it only relates to the market (bid, bid size, ask, ask size), nothing to do with a trade occurring or not. So in many if not most cases, the conditions for data2 are met constantly, so i am only waiting for the time component condition to kick in before sending the order. So as I said, I started noticing that let's say for example
Is one of these conditional statements needed to be true to generate an order? I'm confused in how you phrased it whether it is or not. Also remember, when conditions are met to generate an order, the order is not actually sent until the next "tick / close." If you are trading a slow moving instrument like say ZB then you'll have some delay in when the trade is actually filled.
Data1 is heavily traded and Data2 is not
Are you using the same instrument in Data1 and Data2?

In troubleshooting why something is (or is not) happening, I like to use print statements and then test in playback mode. On a tick by tick basis (or close to such) you can better understand what is happening. Without seeing more of your code I can't help much more than just offer suggestions on what to look at. If you can share more code, then please do so. Ideally the statements that generate buy / sellshort order(s).

monick
Posts: 19
Joined: 20 Nov 2015

Re: Data2 causing orders to be sent late

Postby monick » 22 Nov 2015

No, I am not using the same instrument in data1 and data2.

As I said, Data1 is heavily traded and data2 is not. Here is a sample from the code

If time_s >= 093100 and currentbid of data2> 100 and bidsize of data > 2000 then buy ("buy") next bar at currentask limit;


Return to “MultiCharts”