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 CarlTrading, 03-31-2026, 09:41 PM
            1 response
            152 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            87 views
            1 like
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            131 views
            2 likes
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            127 views
            1 like
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            106 views
            0 likes
            Last Post CarlTrading  
            Working...
            X