Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can't place an order when it's into a position

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

    Can't place an order when it's into a position

    Hi,


    When trying to place a market order when it's not flat, nothing happens...

    I have a strategy that works with two dataseries and my intention is to to place complementary orders in the same direction of the initial orders when a certain condition is reached.

    The code is the following:

    protected override void OnBarUpdate()
    {

    if (Bars == null)
    return;

    // Initial positions

    if ( PositionsAccount[0].MarketPosition == MarketPosition.Flat
    && PositionsAccount[1].MarketPosition == MarketPosition.Flat
    && <condition1> == true)
    {
    EnterLong(0, 1, "LongEntryPrimaryA");
    EnterShort(1, 1, "ShortEntrySecondaryA");
    }

    // Complementary positions

    if( PositionsAccount[0].MarketPosition != MarketPosition.Flat
    && PositionsAccount[1].MarketPosition != MarketPosition.Flat
    && <condition2> == true)
    {
    Print("Before Enter Long");
    EnterLong(1, 1, "LongEntryPrimaryB");
    Print("Before Enter Short");
    EnterShort(1, 1, "ShortEntrySecondaryB");
    Print("After Enter Long and Short");
    }

    }

    Even though <condition2> is met, it doesn't place the complementary positions, but it do print the three messages:

    Before Enter Long
    Before Enter Short
    After Enter Long and Short


    Any suggestions about the cause of the problem?

    Thanks in advance.

    #2
    Hello, thanks for writing in. The Entries Per Direction setting must be set to at least 2 to allow the two subsequent entries. The second EnterLong() and EnterShort() are also both targeting the secondary data series with the "1" for the BarsInProgress index. Please be aware of the order handling rules listed here and turn on TraceOrders to see if there are ignored orders:

    https://ninjatrader.com/support/help...andlingRulesTh atReduceUnwantedPositions


    Kind regards,
    -ChrisL

    Comment


      #3
      Hi Chris.
      That was actually it. Now it works perfectly.
      Thanks a lot.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      88 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      135 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      119 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      69 views
      0 likes
      Last Post PaulMohn  
      Working...
      X