alarms

Questions about MultiCharts and user contributed studies.
Capitanicoraggiosi3
Posts: 11
Joined: 07 Mar 2017
Has thanked: 2 times

alarms

Postby Capitanicoraggiosi3 » 07 Mar 2017

Hi, does anyone knows why only the first alert get created even if the counter get bigger than 15?
thanks


Code: Select all

[IntrabarOrderGeneration = true]

Vars: intrabarpersist counter(0);
Recalclastbarafter(5);
counter = IFF(getappinfo(aicalcreason) = calcreason_timer, counter + 1, 0);

if counter > 5 then alert("IQFEED GBP - NO REAL TIME DATA!!!");


if counter > 15 then alert("AGAIN NO REALTIME DATA");


i_setplotvalue(118, counter);
Last edited by Capitanicoraggiosi3 on 07 Mar 2017, edited 1 time in total.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: alarms

Postby TJ » 07 Mar 2017

see posts 1 & 2
viewtopic.php?t=11713

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

Re: alarms

Postby JoshM » 08 Mar 2017

Hi, does anyone knows why only the first alert get created even if the counter get bigger than 15?
thanks
Probably because MultiCharts can only generate one alert each time the script calculates. Because you have two alert conditions that can both happen at the same time, the later alert 'overrules' the earlier one.

One way to fix that is to use an if/else statement like so:

Code: Select all

if (counter > 15) then
Alert("Again no real time data")
else if (counter > 5) then
Alert("IQFeed GBP - No real time data");

Capitanicoraggiosi3
Posts: 11
Joined: 07 Mar 2017
Has thanked: 2 times

Re: alarms

Postby Capitanicoraggiosi3 » 08 Mar 2017

Thanks JoshM, I will try but I'm afraid that this is not the case. The system runs every 5 seconds and the 2 conditions cannot happen at the same time.

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

Re: alarms

Postby JoshM » 09 Mar 2017

The system runs every 5 seconds and the 2 conditions cannot happen at the same time.
I might not have been clear enough, I think. What I meant was with the two conditions happening at the same time is that, looking at your code:

Code: Select all

counter = IFF(getappinfo(aicalcreason) = calcreason_timer, counter + 1, 0);

if counter > 5 then alert("IQFEED GBP - NO REAL TIME DATA!!!");

if counter > 15 then alert("AGAIN NO REALTIME DATA");
.. then when `counter` has any value bigger than 15, both if statements evaluate to true and both `alert()` statement execute. So in that situation we would have two alerts happening at the same time.

Capitanicoraggiosi3
Posts: 11
Joined: 07 Mar 2017
Has thanked: 2 times

Re: alarms

Postby Capitanicoraggiosi3 » 09 Mar 2017

I have tried in this way but same issue.. the first alarm works... the others doesn't...

Code: Select all

[IntrabarOrderGeneration = true]

Vars: intrabarpersist counter(0);
Recalclastbarafter(5);
counter = IFF(getappinfo(aicalcreason) = calcreason_timer, counter + 1, 0);

If dayofweek(currentdate) <> 6 and dayofweek(currentdate) <> 7 then begin

if counter > 24 and counter < 40 and currenttime < 1900 and currenttime > 900 then alert("IQFEED GBP - NO REAL TIME DATA!!! 120 sec");

if counter > 41 and counter < 100 then alert("IQFEED GBP - NON HA RIPRESO DOPO LA NOTTE 30 min - NO REAL TIME DATA!!!");

if counter > 130 then alert("IQFEED GBP - NON HA RIPRESO DOPO IL WEEKEND 48,5 ore - NO REAL TIME DATA!!!");



end;




i_setplotvalue(118, counter);

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: alarms

Postby TJ » 09 Mar 2017

Why are you using intrabarpersist?

Capitanicoraggiosi3
Posts: 11
Joined: 07 Mar 2017
Has thanked: 2 times

Re: alarms

Postby Capitanicoraggiosi3 » 10 Mar 2017

Honestly.. I don't know. that code has been created by a multicharts expert here on the forum. It is used to know when the broker data get blocked for any reason. the only thing that I have changed are the alarms.

User avatar
Angelina MultiСharts
Posts: 260
Joined: 28 Dec 2016
Has thanked: 28 times
Been thanked: 66 times

Re: alarms

Postby Angelina MultiСharts » 10 Mar 2017

Capitanicoraggiosi3,

Please print out the counter values.

Capitanicoraggiosi3
Posts: 11
Joined: 07 Mar 2017
Has thanked: 2 times

Re: alarms

Postby Capitanicoraggiosi3 » 11 Mar 2017

the counter arrives much higher than those values... at the moment is 5000. The problem could be also to undesratand with does every time that the system runs (every 5 second) a new alarm is not sent?

Should't be that line read everytime and due to the fact that counter is grater should send another alarm. Is there a parameter in the system that tell the system to do not send same alarm over and over again?


Return to “MultiCharts”