Duplicate orders onbar method
Duplicate orders onbar method
05 Dec 2017, 14:08
Hi all,
Just wondering has anyone else ever come across the scenario of a cbot placing 2 limit or stop orders in the exact same location as per the algo logic on an on onbar trigger event. It seems to me that logic is looping through the code twice at the onbar event only a few seconds apart. I don't mind it can just set a smaller position size, however I would like to understand why it would be doing this. I am using segments of code from the trading time interval reference page.
Thanks,
Tony
Replies
HTtrader
26 Dec 2017, 21:58
Thanks Andrey,
I thought it was a line of code that triggered the event. That poses 2 questions after my testing
1. Has spotware provided a solution or update to this bug?
2. Is there a way to code delete duplicate orders?
Surprisingly after my tests the code runs through twice on the first onbar event but then subsequent onbar only runs once, is this an anomaly or something else?
I have my code working the way I want it to so these are just nice to know and have maybe for the next version.
Thanks,
Tony
@HTtrader
ap11
28 Dec 2017, 10:17
Hi Tony,
1. This bug was fixed and fix will be in released in next version
2. To avoid this behaviour, you can call MarketDate.GetSeries in OnStart method and use result later:
private MarketSeries seriesM15; protected override void OnStart() { seriesM15 = MarketData.GetSeries(TimeFrame.Minute15); } protected override void OnBar() { var close = seriesM15.Close.LastValue; }
> Surprisingly after my tests the code runs through twice on the first onbar event but then subsequent onbar only runs once, is this an anomaly or something else?
After calling MarketData.GetSeries, next call with same settings will return same MarketSeries instance. So bug affects only first OnBar event after MarketData.GetSeries call.
Kind Regards,
Andrey
@ap11
ap11
06 Dec 2017, 12:20
RE:
Hi Tony,
Do you have a MarketData.GetSeries() method call inside OnBar?
There is a known issue with version 2.01. When you call MarketData.GetSeries() method inside OnBar, On bar will be called once again on the next tick.
Kind Regards,
Andrey
hungtonydang said:
@ap11