Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Best way to handle dynamic stops?

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

    #16
    Tried this, using the eight separate variables approach, but I'm getting an error message when I compile. For example, I have the following code that's supposed to capture the fill price from the first short entry order, named "ShortEntry1"+shortcount.


    Code:
     
    protected override void OnOrderUpdate(IOrder order)
    {
         if (myEntryOrder != null && myEntryOrder.OrderState == OrderState.Filled && Order.Name == "ShortEntry1"+shortcount) 
         { 
         orderFillPriceShort1 = Order.AvgFillPrice;
         }
    }


    The error I get is:

    An object reference is required for the non-static field, method, or property 'NinjaTrader.Cbi.Order.Name.get'


    I assume this is because the shortcount piece of the entry name is a variable? Should this price-catching code be under OnBarUpdate instead? I'm not sure that's something I want to do though because I want to call the price-catching code when the entry order for the trade fills. What is a good solution for this?

    Comment


      #17
      Hi PhillyD,

      Your capitalization may be causing issues.

      I'm not quite sure what Order.Name will return, the object from the OnOrderUpdate(IOrder order) is lowercase. (Variable names are case sensitive)

      Also, I would recommend you start simple if you run into an error. Does it work when using a specific name?
      Chelsea B.NinjaTrader Customer Service

      Comment


        #18
        Originally posted by PhillyD View Post
        Tried this, using the eight separate variables approach, but I'm getting an error message when I compile. For example, I have the following code that's supposed to capture the fill price from the first short entry order, named "ShortEntry1"+shortcount.


        Code:
         
        protected override void OnOrderUpdate(IOrder order)
        {
             if (myEntryOrder != null && myEntryOrder.OrderState == OrderState.Filled && Order.Name == "ShortEntry1"+shortcount) 
             { 
             orderFillPriceShort1 = Order.AvgFillPrice;
             }
        }


        The error I get is:

        An object reference is required for the non-static field, method, or property 'NinjaTrader.Cbi.Order.Name.get'


        I assume this is because the shortcount piece of the entry name is a variable? Should this price-catching code be under OnBarUpdate instead? I'm not sure that's something I want to do though because I want to call the price-catching code when the entry order for the trade fills. What is a good solution for this?
        Straighten out your variable references. you are passing order to the method, but in the body of the method you are referencing Order and myEntryOrder, with no tie-in to the order variable that you passed in.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        579 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        334 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        554 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X