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 StockTrader88, 03-06-2021, 08:58 AM
        45 responses
        3,992 views
        3 likes
        Last Post johntraderuser2  
        Started by TAJTrades, Today, 09:46 AM
        0 responses
        7 views
        0 likes
        Last Post TAJTrades  
        Started by rhyminkevin, Yesterday, 04:58 PM
        5 responses
        62 views
        0 likes
        Last Post dp8282
        by dp8282
         
        Started by realblubb, Today, 09:28 AM
        0 responses
        8 views
        0 likes
        Last Post realblubb  
        Started by AaronKoRn, Yesterday, 09:49 PM
        1 response
        19 views
        0 likes
        Last Post Rikazkhan007  
        Working...
        X