Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    BertrandNinjaTrader Customer Service

    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()
        {
        }




        BertrandNinjaTrader Customer Service

        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...
            BertrandNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by pechtri, 06-22-2023, 02:31 AM
            10 responses
            124 views
            0 likes
            Last Post Leeroy_Jenkins  
            Started by judysamnt7, 03-13-2023, 09:11 AM
            4 responses
            59 views
            0 likes
            Last Post DynamicTest  
            Started by ScottWalsh, Yesterday, 06:52 PM
            4 responses
            36 views
            0 likes
            Last Post ScottWalsh  
            Started by olisav57, Yesterday, 07:39 PM
            0 responses
            7 views
            0 likes
            Last Post olisav57  
            Started by trilliantrader, Yesterday, 03:01 PM
            2 responses
            22 views
            0 likes
            Last Post helpwanted  
            Working...
            X