Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

GetAtmStrategyMarketPosition returning error

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

    GetAtmStrategyMarketPosition returning error

    Hi,

    i created a strategy that creates Atm strategies.

    Position.MarketPosition does not work in this case, so I want to check if I am flat with GetAtmStrategyMarketPosition.

    However I get ann error : Value cannot be null. Parameter name : key

    I generate a unique atm strategy Id for every trade.

    What do i do wrong?

    Code:
    if
             (
                     atmStrategyId != null &&
                          (GetAtmStrategyMarketPosition(atmStrategyId) == MarketPosition.Flat ) &&
                                EMA1[0] > EMA2[0]
                             && EMA2[0] > EMA3[0]
                            )
    
    {
         atmStrategyId = GetAtmStrategyUniqueId();
          atmStrategyOrderId = GetAtmStrategyUniqueId();
     
        
                    ChartControl.Dispatcher.InvokeAsync((Action)(() =>
                                                {
                                                    NinjaTrader.Gui.Tools.QuantityUpDown quantitySelector = (Window.GetWindow(ChartControl.Parent).FindFirst("ChartTraderControlQuantitySelector") as NinjaTrader.Gui.Tools.QuantityUpDown);
    
                                                    contr = quantitySelector.Value ;    
                                                    
                                                    AtmStrategyCreate(OrderAction.Buy, OrderType.Market, 0, 0, TimeInForce.Day,
              atmStrategyOrderId,  atmname, atmStrategyId, (atmCallbackErrorCode, atmCallbackId) => {
     
              // checks that the call back is returned for the current atmStrategyId stored
              if (atmCallbackId == atmStrategyId)
              {
                  // check the atm call back for any error codes
                  if (atmCallbackErrorCode == Cbi.ErrorCode.NoError)
                  {
                      // if no error, set private bool to true to indicate the atm strategy is created
                      isAtmStrategyCreated = true;
                  }
              }
          });
    }​
                        )​

    #2
    Hello gyilaoliver,

    Ensure the isAtmStrategyCreated is returning true first, and that GetAtmStrategyEntryOrderStatus() is entryOrder[2] == Filled to confirm the atm has activated.


    If you have multiple entries, you need to track the specific atmStrategyId and isAtmStrategyCreated for that specific entry. You might want to do this in a List<string> and List<bool>.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    48 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    126 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    66 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X