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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      47 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      23 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      33 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      51 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      42 views
      0 likes
      Last Post CarlTrading  
      Working...
      X