Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

variable in onexecution

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

    variable in onexecution

    Hello,

    when I use in the onexecutionsection a variable like

    if (exitOrder1a != null && exitOrder1a == execution.Order&& execution.Order.OrderState == OrderState.Filled)
    {
    if(stopstep ==1) then do
    if(stopstep==2) then do

    (also when I do if (stopstep!= null && stopstep ==1) then do )

    there appears in the output window the errormessage "error onexecution.. object reference not set to an instance"

    When I do without the variables then there is no error-message in my script.

    Can´t I use a variable in this section? Or how can I use it without causing error?

    Thanks
    Tony
    Last edited by tonynt; 03-09-2013, 08:01 AM. Reason: clearify

    #2
    You can use variables in this section and it sounds like you understand checking for null before proceeding is the correct action.

    I'm not seeing any apparent error with the code here. Where is stopstep defined in your code?

    I would begin by adding various Print() statements to your OnExecution() to ensure you correctly identify the cause of this error.
    LanceNinjaTrader Customer Service

    Comment


      #3
      Hello,

      thank you for your reply. I have defined my "stopstep" in the variables section with double stopstep = 0;

      This I do for counting inside the script-strategy. Every time the stops are changed this counts +1, so that I always know in which "part of the strategy or trade something occurs" and also this way I can touch it as a condition like I want to do here in onexecution.

      Best
      Tony


      Originally posted by NinjaTrader_Lance View Post
      You can use variables in this section and it sounds like you understand checking for null before proceeding is the correct action.

      I'm not seeing any apparent error with the code here. Where is stopstep defined in your code?

      I would begin by adding various Print() statements to your OnExecution() to ensure you correctly identify the cause of this error.

      Comment


        #4
        If you'd like you can post a simplified version of the code that replicates the error and I'll see if I can spot something.
        LanceNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        115 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        161 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        83 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        127 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        87 views
        0 likes
        Last Post PaulMohn  
        Working...
        X