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 AaronKoRn, Yesterday, 09:49 PM
        0 responses
        11 views
        0 likes
        Last Post AaronKoRn  
        Started by carnitron, Yesterday, 08:42 PM
        0 responses
        10 views
        0 likes
        Last Post carnitron  
        Started by strategist007, Yesterday, 07:51 PM
        0 responses
        11 views
        0 likes
        Last Post strategist007  
        Started by StockTrader88, 03-06-2021, 08:58 AM
        44 responses
        3,981 views
        3 likes
        Last Post jhudas88  
        Started by rbeckmann05, Yesterday, 06:48 PM
        0 responses
        9 views
        0 likes
        Last Post rbeckmann05  
        Working...
        X