Sometime ago I got global variables working, but had sequencing problems. Used the Concurrent Dictionary process which has a certain robustness. I had stepped away from global variables since I had to reload things to completely load everything frequently. Now my uprocessor is bogging down and I am revisiting the use of Global Variables. I am assuming if the "Environment" for the use of Global Variables is done correctly, then they will work robustly. Please comment if you think the use of Global Variables to broadcast Breadth info (TRIN, TICK, COMP, and etc.) is problematic.
My first assumption is the code for Global Variables has to run first. This would be in a separate Workspace having several Indicators. So my questions include; how do I get a specific Workspace to process first? The first case that comes to mind is on starting Multicharts. Does the leftmost Workspace run first? Here the Indicators can run in any order and supply the Global Variables. It has been too long ago, I can't remember any other problems right now
Being able to control what processes first inside a Workspace would be good. I read somewhere the Indicators run first. I don't think "Visual Order" that selects an Indicator's multiple plots priority is what I am looking for.
Summary: How do I guarantee a specific Workspace will run first? Can I sequence the order of processes running inside a Workspace?
Thanks in advance for your assistance!
Ron
Control processing order of Indicators and Strategy?
- Anna MultiCharts
- Posts: 560
- Joined: 14 Jul 2017
- Has thanked: 42 times
- Been thanked: 140 times
Re: Control processing order of Indicators and Strategy?
Hello, RonS!
Unfortunately it is not possible to fully regulate the order of the data downloading and strategies calculation. Especially when you open multiple workspaces at a time or have numerous charts on one workspace.
Unfortunately it is not possible to fully regulate the order of the data downloading and strategies calculation. Especially when you open multiple workspaces at a time or have numerous charts on one workspace.
Re: Control processing order of Indicators and Strategy?
Hi, Is it possible to postpone a Indicator (or strategy)? For example:
CalcBar() {
If(get_ContinueFlagGlobalVar()) {
//my code...
}
}
It seems after all the historical bars have run in the other Indicators, then the above would not have anything loaded.
Put another way, the "other" Indicators would have processed all their Bars and be waiting for Real Time Bars.
The above code would have for example no iSeries Bars or VariableSeries data.
Is it possible to load iSeries and VariableSeries at the Last Bar On Chart for the above code (once)?
I suppose manually starting Workspaces that generate Global Variable first, would load the Global Variables first.
Then Workspaces that rely on Global Variables could be manually started after.
Is it true when a new Bar is generated, the Indicators are processed before the Strategy(s)?
Ron
CalcBar() {
If(get_ContinueFlagGlobalVar()) {
//my code...
}
}
It seems after all the historical bars have run in the other Indicators, then the above would not have anything loaded.
Put another way, the "other" Indicators would have processed all their Bars and be waiting for Real Time Bars.
The above code would have for example no iSeries Bars or VariableSeries data.
Is it possible to load iSeries and VariableSeries at the Last Bar On Chart for the above code (once)?
I suppose manually starting Workspaces that generate Global Variable first, would load the Global Variables first.
Then Workspaces that rely on Global Variables could be manually started after.
Is it true when a new Bar is generated, the Indicators are processed before the Strategy(s)?
Ron
- Anna MultiCharts
- Posts: 560
- Joined: 14 Jul 2017
- Has thanked: 42 times
- Been thanked: 140 times
Re: Control processing order of Indicators and Strategy?
RonS,
– no, it’s not.Is it possible to postpone a Indicator (or strategy)?
– no, this is also not possible.Is it possible to load iSeries and VariableSeries at the Last Bar On Chart for the above code (once)?
– the studies are added to the calculation queue as soon as they are initialized, and then it all depends on the speed of calculation. If one study was calculated longer than others then the order can be changed. If your indicators use the keywords starting with i_* then they can be additionally recalculated after the signal even if they have already been calculated before it.Is it true when a new Bar is generated, the Indicators are processed before the Strategy(s)?
Re: Control processing order of Indicators and Strategy?
Could the timing be controlled in the code? For example, reset the global variable to a default value of zero at the start of the session and have the other indicators require a value > 0?
-
- Posts: 53
- Joined: 18 Feb 2011
- Has thanked: 11 times
- Been thanked: 13 times
Re: Control processing order of Indicators and Strategy?
A possible solution would be to use Events in C#. I have been reading and I am going to try to use them instead of global variables. I have not implemented it yet. I hope to get 'around-to-it' during holidays. I will have some indicators / strategies be an event publisher and others will subscribe / listen for various event(s). MC.Net uses events for Volume profile changes. I am presuming using this code technique will save on a fair amount of processing and remove conflicts of multiple things trying to access the Global Variables at the same time. When an event is raised, it can also pass along some data. So, my strategy should know who raised what event and what is the variable / state change value.
In your case you should be able to receive an event, and then tell the receiving indicator to restart.
Here are some C# links I found useful, relative to events.
https://www.intertech.com/Blog/c-sharp- ... -c-events/
https://www.codeproject.com/Articles/20 ... -Practices
https://docs.microsoft.com/en-us/dotnet ... de/events/
https://docs.microsoft.com/en-us/dotnet ... rom-events
JohnR
Event notifications (frequently expressed as, "fire an event" or "raise an event" or "trigger an event") are generally in the form of the event publisher calling a method in one or more subscribers. Consequently, the raising of an event ultimately means that code in the event publisher causes code in one or more subscribers to run.
In cases where no subscribers [to an event] have registered with the publisher, the event would not be raised.
In your case you should be able to receive an event, and then tell the receiving indicator to restart.
Here are some C# links I found useful, relative to events.
https://www.intertech.com/Blog/c-sharp- ... -c-events/
https://www.codeproject.com/Articles/20 ... -Practices
https://docs.microsoft.com/en-us/dotnet ... de/events/
https://docs.microsoft.com/en-us/dotnet ... rom-events
JohnR
Event notifications (frequently expressed as, "fire an event" or "raise an event" or "trigger an event") are generally in the form of the event publisher calling a method in one or more subscribers. Consequently, the raising of an event ultimately means that code in the event publisher causes code in one or more subscribers to run.
In cases where no subscribers [to an event] have registered with the publisher, the event would not be raised.