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

CS1513 Error

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

    CS1513 Error

    I've added an attachment of the error. Trying to figure out what may be the issue with the expected }. any advice would be greatly appreciated. Click image for larger version

Name:	NT8 snippet.png
Views:	41
Size:	102.9 KB
ID:	1287969

    #2
    Hello Ken7787,

    The error in this case lists the exact problem, the code you have is incomplete and the compiler is expecting that you finish the code. It is expecting a closing curly brace. By the looks of the code you may be missing multiple closing curly braces.

    If you take a look at one of the sample scripts like SampleMACrossOver near the bottom of the file you will see multiple closing braces }. Your code needs to be formatted exactly like that.

    NinjaScript uses the C# language which each section of code is contained within a body or opening and closing brace { }

    You need a closing brace for the class and another for the namespace.
    JesseNinjaTrader Customer Service

    Comment


      #3
      private bool IsTradingTime()
      {
      DateTime currentTime = Cbi.Globals.Now;
      DateTime start = DateTime.ParseExact(startTradingTime, "HH:mm", null);
      DateTime stop = DateTime.ParseExact(stopTradingTime, "HH:mm", null);

      return currentTime >= start && currentTime <= stop;
      }​

      So, with this I just need to add more curly braces? Also, it needs to look exactly like how your example is?

      Comment


        #4
        Hello Ken7787,

        Yes every script needs to follow the correct structure, as mentioned we are using C# language which is structured in a specific way. The code you provided is just a single method, that method has an opening and closing brace to contain the code inside the method. If you look in the SampleMACrossOver strategy it has a method inside of the class called OnBarUpdate. Your strategy would need to be structured in a similar way where the methods you create go inside the class which resides inside of the curly braces.

        A script needs multiple opening and closing braces, the default structure of a class looks like the following:

        Code:
        namespace NinjaTrader.NinjaScript.Strategies
        {
            public class SampleMACrossOver : Strategy
            {​
                  //your code inside here
        
            }
        }
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Haiasi, 04-25-2024, 06:53 PM
        2 responses
        17 views
        0 likes
        Last Post Massinisa  
        Started by Creamers, Today, 05:32 AM
        0 responses
        5 views
        0 likes
        Last Post Creamers  
        Started by Segwin, 05-07-2018, 02:15 PM
        12 responses
        1,786 views
        0 likes
        Last Post Leafcutter  
        Started by poplagelu, Today, 05:00 AM
        0 responses
        3 views
        0 likes
        Last Post poplagelu  
        Started by fx.practic, 10-15-2013, 12:53 AM
        5 responses
        5,408 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Working...
        X