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