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