Is there a way to induce a delay in an indicator  [SOLVED]

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Is there a way to induce a delay in an indicator  [SOLVED]

Postby arjfca » 12 Sep 2013

Hello

How can I induce a delay of 1 second in my indicator

Under a given condition, I need to let time to other indicator to respond from a global variable command

Martin

Dru
Posts: 107
Joined: 28 Aug 2007
Has thanked: 4 times
Been thanked: 171 times

Re: Is there a way to induce a delay in an indicator

Postby Dru » 13 Sep 2013

How can I induce a delay of 1 second in my indicator

Code: Select all

DEFINEDLLFUNC: ThreadSafe, "Kernel32.dll", void, "Sleep", dword;
Sleep(1000);

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Is there a way to induce a delay in an indicator

Postby JoshM » 13 Sep 2013

How can I induce a delay of 1 second in my indicator

Code: Select all

DEFINEDLLFUNC: ThreadSafe, "Kernel32.dll", void, "Sleep", dword;
Sleep(1000);
Nice.

Is every indicator in MultiCharts running on a different thread? (As this code implies)

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Is there a way to induce a delay in an indicator

Postby Henry MultiСharts » 25 Sep 2013

Is every indicator in MultiCharts running on a different thread? (As this code implies)
1 chart window = 1 calculation thread for all studies on this chart.

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

Re: Is there a way to induce a delay in an indicator

Postby bowlesj3 » 25 Sep 2013

If I understood Henry correctly, it confirms my understanding (from my tests) that all studies within a chart are executed in alphabetical order and this is done very quickly since they are all stored in memory. At the same time all the studies in chart #1 will be randomly executed before or after all the studies in chart #2, chart #3, etc. Okay so I have had situations where I had a series of up to 6 studies processing data (in addition to an external program also doing some processing) and these studies were scattered across two charts (1 minute bars and 10 second bars). For this reason I used a control GV which started at value zero and was incremented as each study finished the processing. Each successive study will not execute until that GV is set to the value it is looking for and once that study is finished the processing it increments the value of the GV. I believe this is the only way to handle a situation where you have multiple studies doing the work scattered across charts (including scattered across other programs).

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: Is there a way to induce a delay in an indicator

Postby arjfca » 25 Sep 2013

Question to MC team related to process execution

Is it faster or using less memory to have a single big indicator that contain all process to be done or have a separated indicator for each operation

Martin

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: Is there a way to induce a delay in an indicator

Postby arjfca » 25 Sep 2013

If I understood Henry correctly, it confirms my understanding (from my tests) that all studies within a chart are executed in alphabetical order and this is done very quickly since they are all stored in memory. At the same time all the studies in chart #1 will be randomly executed before or after all the studies in chart #2, chart #3, etc. Okay so I have had situations where I had a series of up to 6 studies processing data (in addition to an external program also doing some processing) and these studies were scattered across two charts (1 minute bars and 10 second bars). For this reason I used a control GV which started at value zero and was incremented as each study finished the processing. Each successive study will not execute until that GV is set to the value it is looking for and once that study is finished the processing it increments the value of the GV. I believe this is the only way to handle a situation where you have multiple studies doing the work scattered across charts (including scattered across other programs).
I'm using a similar approach, but not for the same reason. I'm using a handshake protocol where the slave wrote to GV that the process is over. The master will process the data only after verifying that the slave has put the message that the operation is complete. Once process, the master will erase the completed message in GV. The slave won't put new process result before he seen that the data has been read by the master

Using this, I'm insuring that either the master and slave are in sync.

Martin

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Is there a way to induce a delay in an indicator

Postby Henry MultiСharts » 02 Oct 2013

Question to MC team related to process execution

Is it faster or using less memory to have a single big indicator that contain all process to be done or have a separated indicator for each operation

Martin
Fewer indicators use less memory. But the more code you have inside one indicator - the more difficult it is to design, understand and debug the code.


Return to “MultiCharts”