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 NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      63 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      139 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      75 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      45 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      50 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X