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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    87 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    128 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    65 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    117 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    67 views
    0 likes
    Last Post PaulMohn  
    Working...
    X