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
Detecting when a chart is done loading.
Collapse
X
-
Hello ntbone, thanks for your question.
Unfortunately not. The addon framework can not peek into each individual chart in the workspace to know when it has finished loading. One solution could be to have an indicator update a .txt file and write the state information to the .txt file, then the addon can read the .txt file to know what state the indicator is in.
Please let me know if I can assist any further.Chris L.NinjaTrader Customer Service
-
Hello ntbone, thanks for your reply.
You would not be able to know about the other indicators unless you programmed the same thing in all indicators. Indicators will load in the order they were added to the chart. What is the reason you needed to do this? I could possibly provide an alternative solution.
Best regards.Chris L.NinjaTrader Customer Service
Comment
-
In the indicator configuration dialog the order there is the order processed?
I want an addon to scroll through some instruments automatically changing them. Using linked instrument functionality it can change the charts of linked windows. However I don't want it to change them unless they have all finished loading.
Comment
-
Hello ntbone,
In the indicator configuration dialog the order there is the order processed?
Unfortunately, there is no supported or documented way for an addon to easily peek into all charts of a workspace. Regrettably, I will not be able to suggest any solution here.
Please let me know if I can be of any further assistance.
Chris L.NinjaTrader Customer Service
Comment
-
Aren't all the indicators on a chart brought through the various
state changes via OnStateChange together en masse, on a
per state basis?
I mean, wouldn't NT8 loop through all indicators for the single state,
such as "DataLoaded", one by one, before sending any indicator
the state change to next state of "Historical"?
... and then loop through all indicators sending "Historical" before
sending the next state "Transition"?
... and then loop through all indicators sending "Transition" before
sending the next state "RealTime"?
So, in state "RealTime", it seems to me, the OP's question becomes,
have all other indicators completed their transition to state "RealTime"?
My quick idea (not tested) out of the box is this:
Code:protected override void OnStateChange() { if (State == State.RealTime) TriggerCustomEvent(OnRealTimeComplete, null); } private void OnRealTimeComplete(object obj) { ChartObjectCollection<IndicatorRenderBase> indCollection = ChartControl.Indicators; int stateCount = 0; foreach (IndicatorRenderBase ind [COLOR=#0000ff]in[/COLOR] indCollection) { if (ind.State >= State.RealTime) ++stateCount; } if (stateCount != indCollection.Count) { // keep checking TriggerCustomEvent(OnRealTimeComplete, obj); return; } Print("All Indicators are at state RealTime or later"); }
It all depends if TriggerCustomEvent schedules the custom call into
the queue of events (ie, enqueues our delegate into call stream of
pending callbacks, such as OnBarUpdate, OnStateChange, etc) or
immediately sets up the CurrentBar context and calls the delegate
right then and there?
Unfortunately, the immediate case would probably cause an endless loop.
Therefore,
the hope is that our custom event would be scheduled. Which means,
while it is waiting to be called, NT8 does other work, such as sending
those State changes to other indicators, so that when our custom event
is called again (perhaps multiple times), it will eventually see the State
changes made to the other indicators, until at some point, all states
are State.RealTime or greater.
The benefit of this approach might also depend on multi-threading
considerations, but I don't know. Obviously, this needs testing. I don't
know precisely how TriggerCustomEvent interacts with NT8's event-driven
programming model. I would hope it inserts our custom event at the back
of the normal event queue ... can some one in Support comment on this?
[Also, an "event" in NT8's even-driven programming parlance is really, I
presume, just a call to any of the overridden callbacks prefixed with "On",
such as OnBarUpdate, OnMarketDepth, OnStateChange, etc etc]
The idea has some merit, I think.
But, can't test it right now ... not at NT8 trading computer.
Last edited by bltdavid; 02-19-2021, 05:46 PM.
Comment
-
Interesting idea. If I create an indicator that uses it I might be able to have it signal my addon so it knows everything is done and it can move on. This indicator would need to be added to each chart that I am interested in checking.
I am guessing that each indicator goes through each state one at a time as well based on behavior of the app. I haven't verified it though.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by cls71, Today, 04:45 AM
|
0 responses
1 view
0 likes
|
Last Post
by cls71
Today, 04:45 AM
|
||
Started by mjairg, 07-20-2023, 11:57 PM
|
3 responses
213 views
1 like
|
Last Post
by PaulMohn
Today, 04:22 AM
|
||
Started by TheWhiteDragon, 01-21-2019, 12:44 PM
|
4 responses
544 views
0 likes
|
Last Post
by PaulMohn
Today, 04:09 AM
|
||
Started by GLFX005, Today, 03:23 AM
|
0 responses
3 views
0 likes
|
Last Post
by GLFX005
Today, 03:23 AM
|
||
Started by XXtrader, Yesterday, 11:30 PM
|
2 responses
12 views
0 likes
|
Last Post
by XXtrader
Today, 03:07 AM
|
Comment