Pause an Indicator for some time

Questions about MultiCharts and user contributed studies.
lantama
Posts: 96
Joined: 20 Apr 2008
Has thanked: 5 times
Been thanked: 5 times

Pause an Indicator for some time

Postby lantama » 03 Jun 2014

Hello, I am looking for a function that can pause an indicator calculation for a specific time. The sense behind is that I would like to slow down "update on every tick" in certain situations. Is ther some function around? I did not find any.
Thanks
lantama

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

Re: Pause an Indicator for some time

Postby JoshM » 03 Jun 2014

Hello, I am looking for a function that can pause an indicator calculation for a specific time. The sense behind is that I would like to slow down "update on every tick" in certain situations. Is ther some function around? I did not find any.
If you add a variable to the indicator that counts the number of tick updates per bar, you could use the modulus operator to only update the indicator every `x` ticks (i.e., slow down the update on every tick setting). This `x` could then be based on, for example, the time of day.

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

Re: Pause an Indicator for some time

Postby Henry MultiСharts » 03 Jun 2014

Hello, I am looking for a function that can pause an indicator calculation for a specific time. The sense behind is that I would like to slow down "update on every tick" in certain situations. Is ther some function around? I did not find any.
If you add a variable to the indicator that counts the number of tick updates per bar, you could use the modulus operator to only update the indicator every `x` ticks (i.e., slow down the update on every tick setting). This `x` could then be based on, for example, the time of day.
...and if the current calculation is not on the desired tick, then use Return.

There is no way to completely stop indicator calculation on certain ticks.

lantama
Posts: 96
Joined: 20 Apr 2008
Has thanked: 5 times
Been thanked: 5 times

Re: Pause an Indicator for some time

Postby lantama » 03 Jun 2014

Interesting suggestions, thanks. I will play around a bit with it

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

Re: Pause an Indicator for some time

Postby JoshM » 03 Jun 2014

A way in which you can do this is:

Code: Select all

{
MultiCharts forum discussion topic:
'Pause an indicator for some time';
http://www.multicharts.com/discussion/viewtopic.php?f=1&t=46657

3-6-14

Note: Turn the 'Skip Identical Ticks' option off.
}

Variables:
IntraBarPersist counter(0),
x(10);

// If the calculation is not done on real-time data, skip the
// remainder of the indicator; we're only interested in real-time
// ticks (right?)
if (GetAppInfo(aiRealTimeCalc) <> 1) then
#return;

counter = counter + 1;

if (Mod(counter, x) = 0) then begin

// Calculate the indicator here
// ....

Print(NumToStr(BarNum, 0), "__",
"Tick counter: ",
NumToStr(counter, 0));

end

else begin

// The `Print` statement below just serves to test that everything works;
// by including it the indicator is still 'calculated' on every tick
Print(Spaces(10), "Tick number: ", NumToStr(counter, 0),
" (would otherwise been skipped)");

end;


// Reset counter on bar close and determine x
if (BarStatus(1) = 2) then begin
counter = 0;

// If the time is before 10 a.m. (i.e., 0.00 - 9:59 a.m.),
// update every 25 ticks; else every 10 ticks
if (Time < 1000) then
x = 25
else
x = 10;

end;
Which gives the following output:

Code: Select all

Tick number: 1 (would otherwise been skipped)
Tick number: 2 (would otherwise been skipped)
Tick number: 3 (would otherwise been skipped)
Tick number: 4 (would otherwise been skipped)
Tick number: 5 (would otherwise been skipped)
Tick number: 6 (would otherwise been skipped)
Tick number: 7 (would otherwise been skipped)
Tick number: 8 (would otherwise been skipped)
Tick number: 9 (would otherwise been skipped)
651__Tick counter: 10
Tick number: 11 (would otherwise been skipped)
Tick number: 12 (would otherwise been skipped)
Tick number: 13 (would otherwise been skipped)
Tick number: 14 (would otherwise been skipped)
Tick number: 15 (would otherwise been skipped)
Tick number: 16 (would otherwise been skipped)
Tick number: 17 (would otherwise been skipped)
Tick number: 18 (would otherwise been skipped)
Tick number: 19 (would otherwise been skipped)
651__Tick counter: 20
Tick number: 21 (would otherwise been skipped)
Tick number: 22 (would otherwise been skipped)
Tick number: 23 (would otherwise been skipped)
Tick number: 24 (would otherwise been skipped)
Tick number: 25 (would otherwise been skipped)
Tick number: 26 (would otherwise been skipped)
Tick number: 27 (would otherwise been skipped)
Tick number: 28 (would otherwise been skipped)
Tick number: 29 (would otherwise been skipped)
651__Tick counter: 30
Tick number: 31 (would otherwise been skipped)
Tick number: 32 (would otherwise been skipped)
Tick number: 33 (would otherwise been skipped)
Tick number: 34 (would otherwise been skipped)
Tick number: 35 (would otherwise been skipped)
Tick number: 36 (would otherwise been skipped)
Tick number: 37 (would otherwise been skipped)
Tick number: 38 (would otherwise been skipped)
Tick number: 39 (would otherwise been skipped)
651__Tick counter: 40
Tick number: 41 (would otherwise been skipped)
Tick number: 42 (would otherwise been skipped)
Tick number: 43 (would otherwise been skipped)
Tick number: 44 (would otherwise been skipped)
Tick number: 45 (would otherwise been skipped)
Tick number: 46 (would otherwise been skipped)
Tick number: 47 (would otherwise been skipped)
Tick number: 48 (would otherwise been skipped)
Tick number: 49 (would otherwise been skipped)
651__Tick counter: 50
Tick number: 51 (would otherwise been skipped)
Tick number: 52 (would otherwise been skipped)
Tick number: 53 (would otherwise been skipped)
Tick number: 54 (would otherwise been skipped)
Tick number: 55 (would otherwise been skipped)
Tick number: 56 (would otherwise been skipped)
Tick number: 57 (would otherwise been skipped)
Tick number: 58 (would otherwise been skipped)
Tick number: 59 (would otherwise been skipped)
651__Tick counter: 60
Tick number: 61 (would otherwise been skipped)
Tick number: 62 (would otherwise been skipped)
Tick number: 63 (would otherwise been skipped)
Tick number: 64 (would otherwise been skipped)
Tick number: 65 (would otherwise been skipped)
Tick number: 66 (would otherwise been skipped)
Tick number: 67 (would otherwise been skipped)
Tick number: 68 (would otherwise been skipped)
Tick number: 69 (would otherwise been skipped)
651__Tick counter: 70

lantama
Posts: 96
Joined: 20 Apr 2008
Has thanked: 5 times
Been thanked: 5 times

Re: Pause an Indicator for some time

Postby lantama » 04 Jun 2014

I decided to go for a time based solution. Example for >20Sec Interval:

Vars:
intrabarpersist set(0), intrabarpersist go(0);

if set=0 then set=q_Time_DT;
if(q_Time_DT-Set)*100000000>20000 then begin
set=q_Time_DT;
go=1;
end else go=0;


Return to “MultiCharts”