Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Ninja Script with the built in Strategy Analyzer
Collapse
X
-
Hello dpeter,
Thanks for your post and welcome to the NinjaTrader forums!
In order to test in the strategy analyzer, you would need to be able to select the strategy from the strategy list.
To see the strategy name in the strategy analyzer list, the strategy must be compiled successfully.
If the strategy has been successfully compiled and the name of the strategy is still not visible in the strategy analyzer strategy list then reopen the strategy code in the Ninjascript editor and check that in OnStateChange() method that in the State.SetDefaults that the line "Name = " contains the name of the strategy. In general, the strategy filename, strategy public class name, and the Name = field should all be the same to minimize confusion.
Paul H.NinjaTrader Customer Service
-
Thanks, it was the name, since I used a snipplet published here. However, the snipplet seems not to work. I would like to find the highest high between eg. 8:00-9:00 and store it in a variable, which I can call later for comparison. I have tried in the strategy Builder and now directly with Ninja editor. I dont succeed.
Comment
-
Hello dpeter,
Thanks for your reply.
To debug we recommend using print statement to understand the value of what is being saved, compared and set. For example:
Print ("CB:"+CurrentBar+" High[0] "+High[0]+ " HH: "+HighestHigh+ " FirstIB: "+FirstIB);
You can find our debug tips here: https://ninjatrader.com/support/help...script_cod.htm
The line FirstIB = true; is not encapsulated with the if statement and would be set true on each OnBarUpdate(). If you mean to set it true when the if statement resolves true then you would need to add braces {} to contain all of the action statements related to the if statement, otherwise C# will only consider the first action statement with the if statement and as mentioned the FirstIB=true; will be executed on each OnBarUpdate() regardless of the if statement.
For example:
if (Bars.BarsSinceNewTradingDay > 60 && High[0] < High[1] && Low[0] > Low [1])
{
HighofFirstIB = High[0];
FirstIB = true;
}
Paul H.NinjaTrader Customer Service
Comment
-
Hello dpeter,
Thanks for your reply.
The Print statement will go to the output window, found in New>Ninjascript output.
If you are not seeing any printed output, first please check the "log" tab of the control center for any runtime errors associated with the strategy.
Please make sure that the print statement is contained within the OnBarUpdate() {}.
If you are still unable to see any print values in the output window, please post your entire code.
Paul H.NinjaTrader Customer Service
Comment
-
Hello dpeter,
Thanks for your reply.
What you have posted looks correct and you should be seeing print statements in the New>Ninjascript output.
If you are applying the strategy to a chart and you are connected to live data please note that you would need to "enable" the strategy when you apply it in order for the strategy to execute.
Paul H.NinjaTrader Customer Service
Comment
-
It is empty. I click in the Ninja editor, in the window with my current open program on the top on the icon Ninja Script Editor. It looks to me logical and I have read all the materials. It can not be that a simple range break out code takes me 8h and it doesnt work. Can you tell me how to do it in the strategy builder, instead. There must be something wrong with the code. I simply need the highest high of a time period of eg. 60 min. or 60 bars in 1 min. chart. The highest high needs to be stored as a variable, which I can call later, when other statements are fullfilled to execute an order. Please make a small example, the manual doesnt help and the videos do not go over a simple crossing mechanism.
Comment
-
Hello dpeter,
Thanks for your reply.
The strategy when run on a chart or in the strategy analyzer will output to the New>Ninjascript output. I've created a short video to demonstrate using as much of your code as you have shown: https://Paul-ninjaTrader.tinytake.co...U4OF84OTQyNzE4
In terms of looking for crossovers, once you have determined your upper and lower levels for the breakout, you could use the CrossAbove() or CrossBelow() methods, where one input would be the price series (such as High) and the other input, would be your HighestHigh. In the help guide links for the cross methods, there are several examples, the first shows the current value of the CCI over a defined numerical value, this would be similar to your needs in terms of CrossAbove(High, HighestHigh, 1)
References:
Paul H.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Padan, Today, 02:02 AM
|
9 responses
21 views
0 likes
|
Last Post Today, 03:27 PM | ||
Started by spottysallrite, Today, 11:31 AM
|
7 responses
22 views
0 likes
|
Last Post Today, 03:26 PM | ||
Started by nandhumca, Today, 03:15 PM
|
1 response
4 views
0 likes
|
Last Post Today, 03:23 PM | ||
Started by PopovDS, 03-11-2024, 12:49 PM
|
3 responses
17 views
0 likes
|
Last Post
by PopovDS
Today, 03:16 PM
|
||
Started by Lele2k24, Yesterday, 11:24 AM
|
12 responses
37 views
0 likes
|
Last Post Today, 03:07 PM |
Comment