I had the following strategy in place (CalculateOnBarClose = false which was working as expected:
// Condition set 1
if (Position.MarketPosition == MarketPosition.Flat
&& CrossAbove([SOME DATA OF AN INDICATOR])
&& BarsSinceExit() > 2 || BarsSinceExit() == -1)
{
EnterLong(Quantity, "");
}
// Condition set 2
if (Position.MarketPosition == MarketPosition.Flat
&& CrossBelow([SOME DATA OF AN INDICATOR])
&& BarsSinceExit() > 2 || BarsSinceExit() == -1)
{
EnterShort(Quantity, "");
I have added the following line to both condition sets so that the conditions shall only be met at or after 9 o'clock a.m. and before or at 4:30 o'clock p.m.:
&& ToTime(DateTime.Now) >= 90000 && ToTime(DateTime.Now) <= 163000)
The strategy waits perfectly until 9 o'clock to take action but then 2 strange things happen:
- The strategy continues to trade if the conditions are met after 4:30 o'clock p.m
- At 09:00:01, an over fill happens on 3 of the 4 products I`m trading
These over fills never happened before I added the time line to the condition sets.
According to the logs, it seems that the strategy is fired for all 4 products at 09:00:01 even if the other conditions are not met.
Prior to the over fill message, I can see this entry:
A Set() method to submit an exit order at '08.10.2014 09:15:00' has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.
I found the following:
Set() methods that generate orders to exit a position will be ignored if:
-> I have indeed "SetProfitTarget("", CalculationMode.Ticks, Ticks);" in my strategy.
I though "Position.MarketPosition == MarketPosition.Flat" would prevent such scenarios (entering another position before the other position is flat) as it seems to have done before I added the time condition.
Can you point me in the right direction?
Thank you
Philipp
Comment