1. I want to update a EOD indicator right after the end of session vs on nextbar (session open) anyone have a script for this to happen or ideas?
2. Second issue, the following error: Indicator could not be serialized. (when saving as template)
The indicator recently had a live trend line added to it that updated per bar, since then the indicator cannot be saved as a template if the line is plotted on the chart, if its not plotted then I can save as a template.
Any ideas?
1. You need to set your indicator to CalculateOnBarClose = false, otherwise it will only update with the first tick of the new session.
2. First close the offending chart. Shutdown and restart NinjaTrader. Now add the indicator to a virgin chart (only this indicator and nothing else !) and try to save it as a template. If the problem persists, your indicator has coding errors.
3. In case that there are coding errors, please post the indicator here and I will have a look which lines of the code create the problem.
-----
1. I tried this and did not update when changed to false. Its currently programmed to update per bar, from what I can see I need it programmed to have Bars.Session.GetNextBeginEnd, but this is out of my league LOL, so will need to find a programmer to help me.
2. I fluked out and fixed this myself, a class needed switched from public to private.
Here is basic EMA code, can you alter it to do the following:
1. Continue to update on each bar
2. Update at session end
many thanks
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Add(new Plot(Color.Orange, "EMA"));
#region Properties
/// <summary>
/// </summary>
[Description("Numbers of bars used for calculations")]
[GridCategory("Parameters")]
public int Period
{
get { return period; }
set { period = Math.Max(1, value); }
}
#endregion
}
}
Where within the EMA script does it trigger the at session end update?
For some reason this false function does not have the same affect on my indicator as it does in the EMA script I pasted here as I see the EMA does update with false inserted as you stated.
1 So if I create a second session within the same day, it updates the second session also (if set at false) even if no bars are developed because the market is closed?
Example:
Session 1 Monday - 9:30 am to 4:00 pm (market open) set at false updates at 4:00
Session 2 Monday - 4:30 pm to 6:00 pm (market closed) set at false updates at 6:00
2. When set at false it still updates on each new bar also? just confirming this.
With COBC = false, OnBarUpdate() will update with each incoming tick, no more and no less. So what you will see at session end is the state of the indicator as per last tick of that session. If there are no incoming ticks, OnBarUpdate() will not be triggered.
Historical bars are 1-tick bars, so OnBarUpdate() will be triggered once only for each bar on your chart.
I have a feeling were stepping backwards or missed communication happen.
Its the indicator update that is my focus, using the OnBarUpdate() the indicator is updated on the first tick of the new bar, but at session end say at 4:00 pm the next bar is possibly at 9:30 am the next morning and I don't wait for the first tick at 9:30 am that creates a new bar and a indicator update. I want it triggered at session end "also" and thought setting it at false did this? so indicator updates would occur at new bar and session end both.
I likely will see if the false works on live today as I have a symbol that is currently trading in a trigger spot on my indicator, so I hope to berify this today.
But what happens if one uses EOD data (not live) and the data comes in after the session end, this is where I wanted to have the indicator update immediately vs waiting for the EOD on the next day (needs next cansle) to trigger the indicator. Maybe I need a false ending session that occurs after the EOD delayed data comes in so it updates immediately.
If you want an update at session end you need to set you indicators to COBC = false. I am repeating this now. Otherwise the indicator value of the last bar of the session will not be calculated until the first tick of the new session arrives.
For EOD data you need to make the difference between live real-time data and historical data. After the session end you have to wait for a few minutes until the data provider is ready to supply you with daily historical data (this is not an incoming real-time tick). Once daily data is available, you can either
-> download it for all instruments via the Historical data manager (this is what I do, I select the default list and download everything at once)
-> connect to NinjaTrader and open a new chart for the instrument
Once you have downloaded historical data, to show the indicator value for the last day, guess what, you have to set your indicators to COBC = false.
1. Altered the session time to occur after the EOD data was available.
2. Updated the EOD data and set the false setting and saved template.
3. Opened Ninja from scratch after the session ended to see if the indicator updated, it did not trigger as it should have.
So I must have an issue within the indicator that is not allowing the "false" function to work?
Its not that I don't want to show you, I first had to determine what I should show you, as stated I'm not programmer.
I have had feed back from the actual programmer today:
"An event is classified as when a tick comes in and the current candle is updated, or when the user scrolls the chart window. So the program starts by initializing the indicator and scans through each historical candle in Ninja's database and calculates the indicator. This loop starts at line 3670. When it reaches the end (the right hand side / the current candle) it stops. During this loop it checks for directional triggers."
The issue is as stated when the indicator gets all the way over to the current EOD data, it does not use the data on that day to update if a trigger occurred that day, it needs the follow on EOD to trip the trigger.
My live daily chart also has the same issue, checking if it updates on the first tick at 6:00pm for NG, it should because the trigger is defined under live updates differently, for lack of better words.
Ok I have found out that he did use OnBarUpDate () when plotting historic EOD??
he even says that function has no value on the live candle, but I know off live candles it updates on the first tick of the new bar, which operates fine.
Maybe the following data helps you out?
Should I some how insert the OnBarUpdate() in the script for the historic EOD update, like I know how to do it LOL.
And why I asked for a separate script to trigger an update at session end as the quick fix set to false was not working.
With the separate script I thought I could add it in as a second trigger process for updating an event in the indicator if one occurred on the last historic bar on EOD.
Something like Bars.Session.GetNextBeginEnd possibly, but I need the script written that would execute this second evaluation process.