Alerts

Questions about MultiCharts and user contributed studies.
Guest

Alerts

Postby Guest » 05 Feb 2007

When a condition is satisfied, i want the indicator to immediately alert only once within the duration of the Candle.

I try this simple code:

variables: _CurrentBarNumber(Barnumber),_currentBarAlerted(false);

if currentbar<>_currentBarNumber then begin
_CurrentBarNumber=currentBar;
_currentBarAlerted=false;

end;

if ( high>high[1] ) and not _currentBarAlerted then begin
Alert( "Test Alert " );
_currentBarAlerted=true;

end;

But it does not work... it keeps alerting.
I am testing this on 30mins bar and am using the latest beta.

Is this a Multicharts bug or is there something wrong with the code ?

Guest

Postby Guest » 05 Feb 2007

Additional Information about the above code,
I have set Alert Type to Intra Bar, as i want to be alerted immediately when the condition is fulfilled.

User avatar
Kate
Posts: 758
Joined: 08 Dec 2006

Postby Kate » 06 Feb 2007

Please try to use this code:
Input :
condition(true),
alert_message("alert");

var : intrabarpersist _is_alerted_on_this_bar(false), intrabarpersist _currentbar(0);

if _currentbar<>currentbar then begin
_is_alerted_on_this_bar=false;
_currentbar=currentbar;
end;

if condition and not _is_alerted_on_this_bar then
begin
alert(alert_message);
_is_alerted_on_this_bar=true;
end;

Guest

Postby Guest » 06 Feb 2007

thanks, it work.

I have a query, when do we need to use intrabarpersist in variables declaration ?

I have some variables in indicators whose values seem to be carried over to the next bar even though i did not declare them are intrabarpersist....

thank you

Guest

Postby Guest » 08 Feb 2007

thanks, it work.

I have a query, when do we need to use intrabarpersist in variables declaration ?

I have some variables in indicators whose values seem to be carried over to the next bar even though i did not declare them are intrabarpersist....

thank you

User avatar
Kate
Posts: 758
Joined: 08 Dec 2006

Postby Kate » 09 Feb 2007

Here is a definition of Intrabarpersist taken from TS Help:

"IntrabarPersist (Reserved Word)

A reserved word used when declaring a variable (or array) that indicates that the value of the variable (or array element) can be updated on every tick. By default, the value of a variable or an array element is only updated at the close of each bar.

Examples
Declares the variable Count to an initial value of zero and increments the value of Count every time a tick is received and at the close of each bar..

Variable: IntrabarPersist Count(0);

Count = Count + 1 ;



(Default behavior without IntrabarPersist) Declares the variable Count to an initial value of zero and increments the value of Count at the close of the each bar.

Variable: Count(0);

Count = Count + 1 ;"


Return to “MultiCharts”