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
Adding multiple data series in one strategy
Collapse
X
-
Adding multiple data series in one strategy
I have looked every where I am at the point of giving up. I need to add 4 different times frames in one strategy. Am I writing this correct? AddDataSeries(Data.BarsPeriodType.Day, 1);Tags: None
-
Hello faisamtrader,
AddDataSeries is the correct method for adding data, we have this documented with some samples in the following pages:
I highly suggest reviewing the second like that goes over multi timeframe scripts, there are a lot of considerations to make when using more than one series and this page highlights these items.
I look forward to being of further assistance.JesseNinjaTrader Customer Service
-
-
Originally posted by NinjaTrader_Jesse View PostHello faisamtrader,
AddDataSeries is the correct method for adding data, we have this documented with some samples in the following pages:
I highly suggest reviewing the second like that goes over multi timeframe scripts, there are a lot of considerations to make when using more than one series and this page highlights these items.
I look forward to being of further assistance.
Comment
-
but I have MACD1min and 5 min added to strategy, when I pick primary series to be 1 min, for the MACD 5 min, I can see nothing for the MACD5min but just MACD1min have data, whats wrong?WHEN I add the 5min series from the chart manually to the chart(both 1min and 5min chart can be seen) , it could show the 5min MACD back as normal. BUT WHEN I RUN THE STRATEGY, IT CAUSE ERROR AS THE SCREEN ATTACHED AND whole NINJATRADER PLATFORM CLOSED DOWN AUTOMATICALLY,SEEMS THERE ARE ERRORS. I attached my strategy and can u help to check what is the problem?
Comment
-
Hello stantenlee,
I was unable to see what code you used as the file attached was a compiled assembly. If you want to upload a small sample of what you are doing you can attach the .cs file or copy/paste the relevant code into the post.
The error you are seeing is that an order was rejected, that is 1 part of the error message. You generally see two popups for a rejection with one including a reason, alternatively you can review the control center log tab to check for the rejection reason.
If the platform is closing down or crashing in that use case it could be a result of the code being used, I would need more details about what code was used and the specific situation that you are encountering. You can run the sampleMACrossOver strategy to verify the platform in general is working, that strategy should produce historical trades and not cause an issues.
JesseNinjaTrader Customer Service
Comment
-
Comment
-
-
Hello stantenlee,
That is not code but is is instead a file which compliments the .dll file inside the .zip file you previously attached. If this is a script you created using the NinjaScript editor or strategy builder then you need to export the script as source code using the platforms export tool. When exporting leave the compiled assembly box unchecked to export as source code. If this is a third party item then what you provided already was a protected file which cannot be viewed.
JesseNinjaTrader Customer Service
Comment
-
-
Originally posted by stantenlee View Postbut I have MACD1min and 5 min added to strategy, when I pick primary series to be 1 min, for the MACD 5 min, I can see nothing for the MACD5min but just MACD1min have data, whats wrong?Originally posted by stantenlee View PostWHEN I add the 5min series from the chart manually to the chart(both 1min and 5min chart can be seen) , it could show the 5min MACD back as normal. BUT WHEN I RUN THE STRATEGY, IT CAUSE ERROR AS THE SCREEN ATTACHED AND whole NINJATRADER PLATFORM CLOSED DOWN AUTOMATICALLY,SEEMS THERE ARE ERRORS. I attached my strategy and can u help to check what is the problem?
Comment
-
Hello stantenlee,
Thank you for providing the source code.
I took a look at the file however I am not sure on the question about the data series here. The error you provided is an order rejection, that specifically does not have anything to do with AddDataSeries, the order was just rejected based on the reason it had noted. AddDataSeries could relate if you supplied an incorrect price
I see that you are trying to use AddChartIndicator with the secondary series however that wont work based on the following comment in the help guide:
•An indicator being added via AddChartIndicator() cannot use any additional data series hosted by the calling strategy, but can only use the strategy's primary data series. If you wish to use a different data series for the indicator's input, you can add the series in the indicator itself and explicitly reference it in the indicator code (please make sure though the hosting strategy has the same AddDataSeries() call included as well)
You can't visualize the indicators but you can use them in code. Please try removing the AddChartIndicator code from the script.
JesseNinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_Jesse View PostHello stantenlee,
Thank you for providing the source code.
I took a look at the file however I am not sure on the question about the data series here. The error you provided is an order rejection, that specifically does not have anything to do with AddDataSeries, the order was just rejected based on the reason it had noted. AddDataSeries could relate if you supplied an incorrect price
I see that you are trying to use AddChartIndicator with the secondary series however that wont work based on the following comment in the help guide:
•An indicator being added via AddChartIndicator() cannot use any additional data series hosted by the calling strategy, but can only use the strategy's primary data series. If you wish to use a different data series for the indicator's input, you can add the series in the indicator itself and explicitly reference it in the indicator code (please make sure though the hosting strategy has the same AddDataSeries() call included as well)
You can't visualize the indicators but you can use them in code. Please try removing the AddChartIndicator code from the script.
ANY SAMPLE shared so I can know more clearly??
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by SnailHorn, 03-27-2024, 09:54 AM
|
4 responses
16 views
0 likes
|
Last Post
by SnailHorn
Today, 09:19 AM
|
||
Started by ninza33, Today, 07:16 AM
|
3 responses
18 views
0 likes
|
Last Post
by ninza33
Today, 09:01 AM
|
||
Started by foxtrott21, Today, 08:27 AM
|
0 responses
4 views
0 likes
|
Last Post
by foxtrott21
Today, 08:27 AM
|
||
Started by jaypelle3, Today, 08:26 AM
|
0 responses
3 views
0 likes
|
Last Post
by jaypelle3
Today, 08:26 AM
|
||
Started by linkcou, Today, 07:01 AM
|
2 responses
24 views
0 likes
|
Last Post
by bltdavid
Today, 08:25 AM
|
Comment