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 hazylizard, Today, 08:38 AM
        3 responses
        10 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by geddyisodin, Today, 05:20 AM
        2 responses
        18 views
        0 likes
        Last Post geddyisodin  
        Started by Max238, Today, 01:28 AM
        5 responses
        47 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by giulyko00, Yesterday, 12:03 PM
        3 responses
        13 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by habeebft, Today, 07:27 AM
        1 response
        16 views
        0 likes
        Last Post NinjaTrader_ChristopherS  
        Working...
        X