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.

    Comment


      #3
      I sorted it out. Thank you.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      60 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      39 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      21 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      23 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      51 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X