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!
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
NinjaTrader
Strat will not show any historical data
Collapse
X
-
Strat will not show any historical data
i was able to start a strategy but after compiling it i was unable to get any historical trades i think there is something that i have not set correctly in the strategy on the executing side is there anyway someone could look at my codeTags: None
-
Hello KM0990,
If the strategy is applied to a chart, is there data with new bars appearing on the chart the Strategy is applied to?
Is the strategy showing as enabled on the Strategies tab of the Control Center?
If the strategy is in the Strategy Analyzer, is there data appearing on the Chart Display of the Strategy Analyzer?
Importantly, are there errors appearing on the Log tab of the Control Center?
Try testing the Sample MA Crossover strategy included with NinjaTrader on the same chart or Strategy Analyzer using the same instrument, bar type, interval, and date range.
Do you see results with this strategy? (This would confirm for us data is available and the issue is with the logic in the custom script)
If the strategy is getting data and the strategy is enabled or a backtest is run with no errors in the Log tab of the Control Center, then would likely indicate the logic conditions did not evaluate as true or orders are being ignored or cancelled.
In order to better understand how the code is working, it will be necessary to use Print to see how the conditions are evaluating and enable TraceOrders to see if orders are being submitted, ignored, rejected, or cancelled.
Below is a link to a forum post that demonstrates using prints to understand behavior and includes a link to a video recorded using the Strategy Builder to add prints.
https://ninjatrader.com/support/foru...121#post791121
Enable TraceOrders, print the time of the bar and all values used in the conditions that submit entry orders.
Let me know if you need any assistance creating a print or enabling TraceOrders.
Save the output from the output window to a text file and provide this with your reply.
I'll be happy to assist with analyzing the output.Chelsea B.NinjaTrader Customer Service
-
Thank you for your response
it is not letting me upload the file for some reason here is a link https://1drv.ms/t/s!Alx6QLyubPwegqFh...-Yghw?e=vucEY1
the simple moving average crossover strategy does work. so i know everything should be enabled correctly
Comment
-
Hello KM0990,
Print the time of the bar and the indicator value and comparison value in the condition.
For example:
Code:if (AuSuperSmootherFilter1.SuperSmoother[0] == Up)
Code:Print(string.Format("{0} | AuSuperSmootherFilter1.SuperSmoother[0]: {1} == Up: {2}, ", Time[0], AuSuperSmootherFilter1.SuperSmoother[0], Up));
Chelsea B.NinjaTrader Customer Service
- Likes 1
Comment
-
Thank you! this definately helps is there a way to do this in the strategy editor or do i have to do this in the code editor?
aslo if i wanted the do the reverse for the exit would it be like this?
Print(string.Format("{0} | AuSuperSmootherFilter1.SuperSmoother[0]: {0} == Down: {2}, ", Time[0], AuSuperSmootherFilter1.SuperSmoother[0], Down));
Comment
-
Hello KM0990,
May I confirm you have reviewed the video 'Debugging using prints with the Strategy Builder' in the post on using prints to understand behavior I have linked in post #2?
I wouldn't be able to say if the custom AuSuperSmootherFilter1 is reversed when it equals Down. I would recommend reaching out to the vendor or author that distributes this script for insight on their software works.
But for any condition, print the values in the condition to understand how the condition will evaluate.Chelsea B.NinjaTrader Customer Service
- Likes 1
Comment
-
i am trying to set variables of some sort in the strategy so that when Trend[0] = 1 Enter long trade and when Trend[0] = -1 enter short trade. the indicator will not let me do this in the wizard so i have to find a way to enter the code in for it manually. i am new to this so i am fighting a steep learning curve also im still trying to learn all of the processes and details of the syntax
i have attatched a file with the a copy of the code i have so far. anything helps. im not looking for someone to do it for me but examples and infromation on where i may be missing the ticket would be greately appreciated.
{
Value[0] = (CurrentBar == 0 ? Input[0] : Input[0] * constant1 + constant2 * Value[1]);
if (CurrentBar < 1)
{
if (showPlot)
Plots[0].Brush = Brushes.Gray;
else
Plots[0].Brush = Brushes.Transparent;
}
{
alphaBarClr = 25 * opacity;
Trend[0] = 0;
if (Value[0] > Value[1])
Trend[0] = 1;
else if (Value[0] < Value[1])
Trend[0] = -1;
{
if (Trend[0] == 1)
return TRND = 1;
else if (Trend[0] == T-1)
return TRND = 0;}
Attached Files
Comment
-
Hello KM0990,
At heart, if a an action is not taking place, there would either be errors that cause the strategy to abort, or the logic is not allowing the actions to take place.
Checking the log tab of the Control Center can hint at runtime errors seen, and printing out the values used to evaluate your conditions can tell you why a condition is not becoming true. Additional prints to track how those values get set can then be done to check your work if a certain variable does not have a value you expect.
The snippet of code you have shared in post #7 looks to be added in State.DataLoaded, but you are not closing the curly braces of State.DataLoaded and OnStateChange, so the script will not compile. You should also not try to access and set Series objects (which are synced to a data series) in State.DataLoaded, because the script has not started processing historical data yet.
If you want to get further acquainted with unlocked code, I suggest viewing our NinjaScript Editor 401 course, and to first practice with simple strategies, clicking View Code after each change to better observe the syntax. Publicly available resources on C# will also be helpful when working with unlocked code because NinjaScript is built on top of C#.
NinjaScript Editor 401 - https://www.youtube.com/watch?v=O5-C8GyV9OI
Strategy tutorials - https://ninjatrader.com/support/help...strategies.htm
JimNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by bmartz, Today, 09:30 AM
|
2 responses
11 views
0 likes
|
Last Post
by bltdavid
Today, 11:24 AM
|
||
Started by f.saeidi, Today, 11:02 AM
|
1 response
2 views
0 likes
|
Last Post Today, 11:08 AM | ||
Started by geotrades1, Today, 10:02 AM
|
4 responses
12 views
0 likes
|
Last Post
by geotrades1
Today, 11:08 AM
|
||
Started by rajendrasubedi2023, Today, 09:50 AM
|
3 responses
16 views
0 likes
|
Last Post Today, 10:57 AM | ||
Started by lorem, Today, 09:18 AM
|
2 responses
11 views
0 likes
|
Last Post Today, 10:55 AM |
Comment