Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Over fill with ToTime(DateTime.Now)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Over fill with ToTime(DateTime.Now)

    Hi,

    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:
    · A position is open and an order submitted by an enter method (EnterLongLimit() for example) is active and the order is used to open a position in the opposite direction
    · A position is open and an order submitted by an exit method (ExitLongLimit() for example) is active

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

    #2
    pms123,

    Are you shutting the strategy down overnight?

    Do you use ExitOnClose set to false or true?

    How are you verifying that the strategy is placing trades after 4:30PM?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Hi,

      Thank you for the quick feedback.

      Yes, I shut down the strategy at night.
      I don't use ExitOnClose at all.
      I haven't done anything manually and I have successful orders (entry and exit) in my records from after 4:30PM.

      Thanks
      These are shown on the chart aswell

      Comment


        #4
        pms123,

        Can you please send me the strategy so that I can test this on my end?

        You can find the strategy in (My) Documents -> NinjaTrader 7 -> bin -> Custom -> Strategy

        You can send the strategy to platformsupport [at] ninjatrader [dot] com

        Put ATTN Cal in the subject and reference this thread in the body
        Cal H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        61 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        148 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        162 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        98 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        286 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X