Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CS1501 regardless

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

    CS1501 regardless

    I'm trying to get the strategy to place the take profit and entry at the levels of two indicators.

    The entry indicator is static and plots a line X ticks from the open[0]. This isn't generating any issues when compiling.

    The take profit indicator is dynamic. This keeps generating a "No overload for method 'name' takes 1 arguments." error. I have tried setting indicator parameters after initialization
    indicator = indicator();

    indicator.high = 10;
    indicator.low = 10;

    setting the parameters within the initialization,
    indicator = indicator(10,10)

    omitting all parameters,
    indicator = indicator;

    Only placing one parameter (as both numbers are the same anyway)
    indicator = indicator(10)


    If I don't initialize the indicator I can successfully compile, but when I activate the strategy I get "Error on calling 'OnStateChange' method: Object reference not set to an instance of an object."
    I get the same cs1501 error code regardless. Please advise.

    #2
    Hello ThatMikey,

    Thank you for your post.

    Is this pseudocode? It's hard to say why you are getting this error without knowing the exact line of code listed in the error and what indicator you are referencing. This first error 'No overload for method x takes n arguments' means you aren't supplying the correct amount of arguments to the method.


    The second Object reference not set to an instance of an object error indicates that there is a null value in a variable being used in your script.​ Specifically in OnStateChange. To determine what the source of the error is you will need to debug your strategy using print statements.

    It's not clear to me from the script which variable could be leading to the object reference error, so I suggest you add a print statement every few lines of code and then observe the output window when you apply the strategy.

    The last print statement shown in the output window would indicate the error occurs after that print statement, you can then add further print statements to zero in on the offending code. After you find the exact object returning null, you could add a condition check in the script to check that the value is not null.
    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      I sorted it out. Thank you.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by meatskin, Today, 03:07 PM
      0 responses
      11 views
      0 likes
      Last Post meatskin  
      Started by Pa_Baz, 12-14-2024, 09:40 PM
      26 responses
      372 views
      1 like
      Last Post MarioM94  
      Started by crystalet, 12-06-2022, 06:59 AM
      2 responses
      52 views
      1 like
      Last Post mrmark123  
      Started by ClauTrade, Today, 02:26 PM
      2 responses
      10 views
      0 likes
      Last Post ClauTrade  
      Started by jpapa, Today, 01:44 PM
      6 responses
      23 views
      0 likes
      Last Post jpapa
      by jpapa
       
      Working...
      X