Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Reducing Position Problem

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

    Reducing Position Problem

    When using multiple instruments, I am trying to reduce positions, but for some reason, it doesn't seem to be working. That part of the code looks like this......what am I missing?

    {
    if (BarsInProgress == 0)
    if ((Positions[0].MarketPosition == MarketPosition.Long)
    && (Closes[0][0] < Opens[0][0])
    && Position.Quantity > oneThousand)
    {
    ExitLong(1000);
    Print ("**************************Reducing GBP/USD Position");
    }
    }
    // ================================================== =========

    {
    if (BarsInProgress == 1)
    if ((Positions[1].MarketPosition == MarketPosition.Short)
    && (Closes[1][0] > Opens[1][0])
    && Position.Quantity > oneThousand)
    {
    ExitShort(1000);
    Print ("**************************Reducing EUR/USD Position");
    }

    }

    #2
    If you're checking what Bars object is calling the OnBarUpdate() with BIP, you do not need to call Positions[1].MarketPosition. You can simply check Position.MarketPositon == MarketPositon.Short within the Context of BIP == 0 or BIP ==1

    You're currently checking both of these - Please try using one approach or the other.

    Please review our Help Guide for an example of both approaches:



    If that does not help, can you please expand on what is not working?
    MatthewNinjaTrader Product Management

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    649 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    370 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    109 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    573 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    576 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X