Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
CS1513 Error
Collapse
X
-
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.
-
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
-
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 } }
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by DannyP96, 05-18-2026, 02:38 PM
|
1 response
84 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 05-11-2026, 05:56 AM
|
0 responses
143 views
0 likes
|
Last Post
by CarlTrading
05-11-2026, 05:56 AM
|
||
|
Started by CarlTrading, 05-10-2026, 08:12 PM
|
0 responses
83 views
0 likes
|
Last Post
by CarlTrading
05-10-2026, 08:12 PM
|
||
|
Started by Hwop38, 05-04-2026, 07:02 PM
|
0 responses
256 views
0 likes
|
Last Post
by Hwop38
05-04-2026, 07:02 PM
|
||
|
Started by Mindset, 04-21-2026, 06:46 AM
|
0 responses
334 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|

Comment