Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 aussugardefender, Today, 01:07 AM
        0 responses
        3 views
        0 likes
        Last Post aussugardefender  
        Started by pvincent, 06-23-2022, 12:53 PM
        14 responses
        238 views
        0 likes
        Last Post Nyman
        by Nyman
         
        Started by TraderG23, 12-08-2023, 07:56 AM
        9 responses
        384 views
        1 like
        Last Post Gavini
        by Gavini
         
        Started by oviejo, Today, 12:28 AM
        0 responses
        4 views
        0 likes
        Last Post oviejo
        by oviejo
         
        Started by pechtri, 06-22-2023, 02:31 AM
        10 responses
        125 views
        0 likes
        Last Post Leeroy_Jenkins  
        Working...
        X