Built-in global variables

Questions about MultiCharts and user contributed studies.
janus
Posts: 835
Joined: 25 May 2009
Has thanked: 63 times
Been thanked: 104 times

Built-in global variables

Postby janus » 20 May 2010

How well do the built-in MC global variable functions (GVSetNamedInt, etc.) work when multiple studies run simultaneously on multi-core/threaded PCs? Are they written such that one can't read and and write to the same global variable at the same time (using I presume one of MS's built-in synchronization functions, such as critical sections, mutex or some other method)?

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Postby bowlesj3 » 21 May 2010

I don't have the answer but it is an interesting question. I asked if the GV named string searches were being done in binary but got no answer so you may suffer the same fate on this question.

In this regard generally, I often think that studies and charts should be processed in a predetermined sequence (always the same order within one workspace) and the only proper solution is to have a computer that is so dam fast that the user simply can not tell if there is any slowdown. In this ideal senario we could select the order that charts are to be processed and maybe even the order that studies are processed within charts. In this regard MC should tell us with internal auditing if the studies we have decide to feed MC can not complete before the next tick comes in. At that point it is up to us to determine if we reduce the load or get a faster computer (or maybe MC needs to somehow process faster) (or maybe other speedups to our computer need be done) (whatever). Maybe the auditing could tell us how long it takes to get a study completed and we could figure out where our code is taking too long (start time, end time and length of time might be all that is needed). I have another post suggesting internal auditing for the trader to analyse.

So one might ask, how does this relate to the question. Traders should have control of the order of events. If they do and things go so dam fast they can not tell the difference then one GV function at a time is all they need. If charts get executed randomly that makes programming studies a tad bit tricky. For that matter is it too hard for the trader to make the decision as to which charts are to be subject to multi threading. Maybe (some traders) or (some studies) are okay to function under this situation and others need to be executed in a proper sequence. If someone got to the moon maybe this could some day be possible. Heres how I might want to force the order of execution of my charts based upon the logic of my studies

10sec 1st
1min-A 2nd
1min-B 3rd
5min 4th
10min 5th
15min multi thread
30min multi thread
60min multi thread
daily multi thread

or if the speed is okay (based upon audit results) maybe I would order them all.
Last edited by bowlesj3 on 21 May 2010, edited 7 times in total.

janus
Posts: 835
Joined: 25 May 2009
Has thanked: 63 times
Been thanked: 104 times

Postby janus » 21 May 2010

You read my mind. I was thinking of the exact same issues for some time. I have a couple of studies that are applied to multiple charts with different time frames. The studies should run in a specific sequence to be effective but since there's no way to make this so I've resorted to a number of tricks. I'm using global variables to check when specific events have occurred. It's a crude way to synchronize the studies.

Another approach I almost tried is to do everything in the one chart based on the lowest resolution. That way I can aggregate multiple time frames based on the one chart. Alternatively, I could plot them all on the same chart window as separate base data numbers and refer to them using say "close of data(x)". Either way it makes the code more complicated for various reasons I won't allude to here, but I can handle all that. I rather use the other approach as it keeps the code simple, and is more aligned to using object orientated approaches to programming.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Postby bowlesj3 » 21 May 2010

I think others have asked about this.

For me although I have a few studies that would be better with charts executing in a specific order I don't think not having this will effect my bottom line income that much. I just think that if TSS has nothing better to do some day and if it is not that hard to do (probably is hard) then it might be worth considering.

janus
Posts: 835
Joined: 25 May 2009
Has thanked: 63 times
Been thanked: 104 times

Postby janus » 21 May 2010

I agree. this is a low priority feature. There are many other feature requests that are far more important, and should be implemented first.

User avatar
Dave Masalov
Posts: 1712
Joined: 16 Apr 2010
Has thanked: 51 times
Been thanked: 489 times

Postby Dave Masalov » 24 May 2010

How well do the built-in MC global variable functions (GVSetNamedInt, etc.) work when multiple studies run simultaneously on multi-core/threaded PCs? Are they written such that one can't read and and write to the same global variable at the same time (using I presume one of MS's built-in synchronization functions, such as critical sections, mutex or some other method)?
Dear janus,

Global variable functions in MC, such as GVSetNamedInt and GVGetNamedInt, were designed specifically for the data transfer from one study to another, when multiple studies run simultaneously. You can read and and write to the same global variable at the same time.


Return to “MultiCharts”