Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calling methods error messages

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

    Calling methods error messages

    Hi
    When calling a method if a condition is true, my code is:-

    if (bool ==true)
    {
    this.method();
    }

    private void method ()
    {
    }

    1) I get an error message "statement expected." after "this.method();" and a ";" expected the the first "}".
    2) Then at the end of private void method(), I also get a "statement expected" error.

    Why am I getting these error messages? How do I rectify these issues?

    #2
    Kay, bool is a reserverd word, please try for example boolean as variable name instead.

    Also - where are you declaring your own method? Please ensure this is outside the OnBarUpdate() of the indicator and then retry compiling it.

    Comment


      #3
      Hi Bertrand,
      the method was declared inside OnBarUpdate(). how do i set up methods outside the OnBarUpdate()?

      Comment


        #4
        Just do it for example after the OnBarUpdate() closing brace -

        Code:
         
        protected override void OnBarUpdate()
        {
        }
         
        private void MyMethod()
        {
        }




        Comment


          #5
          Hi Bertrand,

          Did that.

          There is now an error at the second last brace of the code...just before "NinjaScript generated code. Neither change nor remove."

          The error message is "Namespace member declaration expected." What is this?

          BTW, I removed the brace in question and all seems fine...for now...

          Comment


            #6
            Kay, might have been a duplicate one accidentially left in...

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            579 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            334 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            554 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            551 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X