Hi guys, this statement isn't working, any ideas? When i moved my new strat to production it began to print historical print statements.
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
if(Historical) return;
Collapse
X
-
if(Historical) return;
if(Historical) return;
Hi guys, this statement isn't working, any ideas? When i moved my new strat to production it began to print historical print statements.Tags: None
-
Hello,
Thank you for the question.
Can you provide an example of this not working so that I can see how you have implemented this? Also how are you running the strategy, in live data or is this in market replay or on simulated data?
In general this can be placed before any statements that do not need to be run Historically as you know, depending on the placement anything before it would still be run anything after would not.
I look forward to being of further assistance.JesseNinjaTrader Customer Service
-
I have 1 primary series and 2 secondary series in a strategy. When I move the strategy to production it continues to print out historical values from previous days. Primary series is 2 betterrenko. I just also tested it on the 1 minute and its the same effect.
Comment
-
Hello,
Thank you for the reply.
I have not experienced this when using the if(Historical) bool.
If you can provide an example of this in code that produces the issue I would be happy to take a look at it and see what is happening.
Without an example to see how this is happening I can only tell you that this is the correct syntax you are using and that preventing historical data from being used would be its use.
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
-
Hey guys I think i may have found the cause of this error. It appears to occur when you refer to another dataseries while you are inside the 0 bar series that causes the historical statement to malfunction. Will post more info when I found the exact statement.
Comment
-
Hey guys this error just appears to be caused by adding more than 1 series to a strategy! hope you will be able to help me solve it here is the strategy as it stands now:
Initialize:
// Set calculation options
CalculateOnBarClose = true;
BarsRequired = 150;
EntriesPerDirection = 3;
Add("A", PeriodType.Minute, 1440);
Add("ABC", PeriodType.Minute, 5);
Add("ACT", PeriodType.Minute, 1);
// Exit trade at end of session
ExitOnClose = true;
ExitOnCloseSeconds = 60;
protected override void OnBarUpdate()
{
if(BarsInProgress==1)
{
if(Historical) return;
}
if(BarsInProgress==3)
{
if(Historical) return;
}
if(BarsInProgress==0)
{
if(Historical) return;
}
if(BarsInProgress==2)
{
if(Historical) return;
}
//THIS IS 5 MINUTE BAR SERIES
if(BarsInProgress==2)
{
if(Historical) return;
}
if(BarsInProgress==0)
{
if(Historical) return;
Print("this is a test for time series: " + Time[0]);
} // END OF BAR 0
}
Comment
-
As you can see, the print time statement should not be executing but it does in realtime, for example it prints from the bars from June today! Please advise.
Comment
-
Hello,
In the code you have posted the print should be happening during live data because it is not historical data and that is what the condition is checking for.
The if(Historical) return is returning for all historical bars and then when live data comes in it will allow the print.
If you do not want something to happen in Live data you would want to use if(!Historical) or in English if not historical then
I think you are looking for if(!Historical) return; this will not happen live if you do this.
Please let me know if i may be of additional assistance.JesseNinjaTrader Customer Service
Comment
-
Sorry, but I think you have misunderstood, the statement below executes on both historical and real-time bars:
if(BarsInProgress==0)
{
if(!Historical)
{
Print("this is a test for time series: " + Time[0]);
}
}
Comment
-
Hello,
The code you had provided previously did not include this statement, and I have replied based on the code you provided.
In the new statement you provided I have tested this and yes your findings are correct. It would seem that the added bar series is not getting a request for historical data. This is a known limitation when adding multiple data series. In certain cases the historical data is not loaded so there are no historical bars to process.
The resolution I have found was to Open a chart with the instruments you are adding and request historical data so that it is downloaded.
Here is the code I was using for the test so that you can confirm on your end.
Code:if(BarsInProgress == 0) { if (Historical) { Print("This will print historically"); } else if(!Historical) { Print("This will print during Live data"); } }
Please let me know if I may be of additional assistance.JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Mestor, 03-10-2023, 01:50 AM
|
12 responses
307 views
0 likes
|
Last Post
by z.franck
Today, 04:29 AM
|
||
Started by AgriTrdr, 07-16-2023, 12:54 PM
|
32 responses
267 views
0 likes
|
Last Post
by f.saeidi
Yesterday, 06:49 AM
|
||
Started by Mestor, Today, 03:15 AM
|
0 responses
2 views
0 likes
|
Last Post
by Mestor
Today, 03:15 AM
|
||
Started by Padan, Today, 02:02 AM
|
0 responses
6 views
0 likes
|
Last Post
by Padan
Today, 02:02 AM
|
||
Started by bukowa, 11-09-2023, 06:07 PM
|
20 responses
409 views
0 likes
|
Last Post
by Adfra
Today, 01:36 AM
|
Comment