thanks for your answer. Are you telling me DataSeries objects always synchronize with the last bar in the chart? If yes, I need to loop through the chart from the first to the last bar to load my indicator values to the DataSeries object? The indicator would then automatically be synchronized to the chart. But, what would be the way (the loop) to fill my Data Series with the indicator data?
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
external date for indicator construction
Collapse
X
-
Hello Jesse,
thanks for your answer. Are you telling me DataSeries objects always synchronize with the last bar in the chart? If yes, I need to loop through the chart from the first to the last bar to load my indicator values to the DataSeries object? The indicator would then automatically be synchronized to the chart. But, what would be the way (the loop) to fill my Data Series with the indicator data?
-
Hello,
Yes the DataSeries is synced with the bars on the chart, here is a simple example on what is happening:
Lets start on Bar 0.
Now lets assume we are setting a DataSeries to the CurrentBars value and the CurrentBar increments for each call to OnBarUpdate:
Code:protected override void OnBarUpdate() { Plot0.Set(CurrentBar); }
What is going to happen, on Bar 0 counter is 0 and Plot0 is set to 0 for bar 0.
On bar 1, Plot0 is set to 1 on bar 1.
Lets stop here and look what happened, The DataSeries now has 2 points of data because OnBarUpdate has been called for Bar0 and Bar1.
Lets now assume on bar 0 we do the following instead:
Code:protected override void OnBarUpdate() { Plot0.Set(CurrentBar); Plot0.Set(12345); }
For what you are trying to do, there are a few possibilities.
One would be to check the date on Bar 0 and locate that line in the file then read line by line from that point setting the value for each OnBarUpdate.
Another way would be once you are in RealTime and not Historical, you could run a loop or for statement looping through the lines of data. You could then use the syntax:
Plot0.Set(BarsAgo, Value);
to set the value of a specific BarsAgo from the current bar in the DataSeries you are using.
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
-
Thank you for your help. In the meantime I was able to understand the logic of ninja script better and could write the import script. But now, I have another problem.
If I read daily data in a daily chart, for example sentiment data, I have sentiment data for each trading day and I have a bar for each trading day. No problem so far. But if I collapse the chart to weekly or monthly bars, NT7 seems to change from a trading day calendar to a calendar that is not considering holidays. The reference date of the weekly bar for example seems to be always Friday, regardless if the day was a trading day or a holiday. If it was a holiday, I cannot reference my indicator data to the bar, because the Indicator data series only contains data for trading days. Is it possible to change the calendar behind the weekly and monthly charts to a trading day calendar?
I use the following statement to synchronize the indicator data with the price bars
if (ToDay(Time[0]) == date)
myDataSeries.Set(Indicator);Last edited by Atreio; 08-18-2015, 02:34 PM.
Comment
-
Hello Atreio,
When using a weekly or monthly bar, this will use Daily bars as the underlying bar type.
When you load a daily chart, there is no session for saturday so the bar for saturday does not show.
However, weekly bar will simply call 7 days of daily bars. If there is no bar on saturday, it simply is not included with the weekly bar.
That said, NinjaTrader 7 is not able to account for holidays. You would need to write explicit code into your script that changes the behavior if the day is a holiday. You would also need some kind of array that contains the dates for the holidays.
The bar on chart will try and include the holiday, but likely you will get a doji for that day since there will be no activity or data on that day. (Meaning a bar where the open, high, low, and close are all the same price.Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Brevo, Today, 01:45 AM
|
0 responses
6 views
0 likes
|
Last Post
by Brevo
Today, 01:45 AM
|
||
Started by aussugardefender, Today, 01:07 AM
|
0 responses
3 views
0 likes
|
Last Post Today, 01:07 AM | ||
Started by pvincent, 06-23-2022, 12:53 PM
|
14 responses
241 views
0 likes
|
Last Post
by Nyman
Today, 12:47 AM
|
||
Started by TraderG23, 12-08-2023, 07:56 AM
|
9 responses
384 views
1 like
|
Last Post
by Gavini
Today, 12:29 AM
|
||
Started by oviejo, Today, 12:28 AM
|
0 responses
6 views
0 likes
|
Last Post
by oviejo
Today, 12:28 AM
|
Comment