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 chbruno, Today, 04:10 PM
        0 responses
        1 view
        0 likes
        Last Post chbruno
        by chbruno
         
        Started by josh18955, 03-25-2023, 11:16 AM
        6 responses
        436 views
        0 likes
        Last Post Delerium  
        Started by FAQtrader, Today, 03:35 PM
        0 responses
        6 views
        0 likes
        Last Post FAQtrader  
        Started by rocketman7, Today, 09:41 AM
        5 responses
        19 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by frslvr, 04-11-2024, 07:26 AM
        9 responses
        127 views
        1 like
        Last Post caryc123  
        Working...
        X