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, 05-11-2026, 05:56 AM
      0 responses
      56 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      34 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      195 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      359 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      281 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X