Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator button to modify ATM Target

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

    Indicator button to modify ATM Target

    I currently have an indicator that can modify Stop1 order to BE of an ATM that has been placed on the Chart. I am trying to get another button to Modify the Target1 order to BE +1 is this possible, I have pasted the button 'code' below

    protected void myTargetBE(object sender, RoutedEventArgs e)
    {
    Account Acct = Account.All.FirstOrDefault(x => x.Name == xAlselector.SelectedAccount.ToString());
    Position thisPosition=Acct.Positions.FirstOrDefault(x => x.Instrument.FullName==Instrument.FullName) ;
    NinjaTrader.Cbi.Order myOrderToChange = null;
    foreach (Order order in Acct.Orders)
    {
    if(order.OrderType==OrderType.Limit || order.OrderType==OrderType.MIT)

    if(order.OrderState != OrderState.Cancelled & order.OrderState != OrderState.Filled)
    {
    if (order.Name=="Target1")
    {
    myOrderToChange.LimitPriceChanged = thisPosition.AveragePrice+ 1 * TickSize; // adjust to +1 ticks above entry price
    Acct.Change(new [] { myOrderToChange });
    }
    }


    }
    }

    #2
    Hello thepcmd,

    Yes, it would be possible to change the price of an order from a button click handler method.

    This is from a manually submitted entry that has an Atm Strategy attached?
    As a heads up, the Atm Strategy would continue running and would likely undo any price changes you make as it continues operating.

    Is there an issue or error you having you want assistance with?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Whenever I use the code above I get the following 'Unhandled exception: Object reference not set to an instance of the object.' That is what I am having issue with.

      Comment


        #4
        Hello thepcmd,

        The error is stating that a variable you are using has a null value.

        You can add prints above each line and look to see what the last print to appear is. The line of code below is likely the line causing the error.

        You can test each variable and check to see if it is null.

        For example:

        private Order myOrderToChange;

        if (myOrderToChange == null)
        {
        Print("myOrderToChange is null");
        }

        If you are not finding the order in the account Orders collection, print each order in the collection.
        Print(order.ToString());

        Below is a link to a forum post that demonstrates how to use prints to understand behavior.


        What variable has a null value?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thank you for your input - I was able to resolve my issue

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          601 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          347 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          559 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          558 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X