Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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
    Chris L.NinjaTrader Customer Service

    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 rhyminkevin, Today, 04:58 PM
      1 response
      42 views
      0 likes
      Last Post Anfedport  
      Started by iceman2018, Today, 05:07 PM
      0 responses
      5 views
      0 likes
      Last Post iceman2018  
      Started by lightsun47, Today, 03:51 PM
      0 responses
      7 views
      0 likes
      Last Post lightsun47  
      Started by 00nevest, Today, 02:27 PM
      1 response
      14 views
      0 likes
      Last Post 00nevest  
      Started by futtrader, 04-21-2024, 01:50 AM
      4 responses
      49 views
      0 likes
      Last Post futtrader  
      Working...
      X