AlertIf problem

#1
Hi,
I need some help with AFL coding.
What I want to have is simple text alerts when:
1) price hits new DAILY lows
2) price hits new DAILY heights
3) change between last price and previous day close i 0%
4)change between last price and current day Open is 0.

I use Amibroker Professional version so I can use function GetRTData:

I tried this:

x1=GetRTData("Last");
x2=GetRTData("Open");
x3=GetRTData("High");
x4=GetRTData("Low");
x5=GetRTData("Prev");

AlertIf(x2-x1=0,"","Open",1);
AlertIf(x3-x1=0,"","NewHigh",1);
AlertIf(x4-x1=0,"","NewLow",1);
AlertIf(x5-x1=0,"","Zero",1);

..but, in Alertif function there is lookback parameter.
How can I change lookback parameter to show only current day quotes.
I can't set this parameter to fixed number because I use 1min bars and in the first few minutes of the session it will takes numbers from previous day bars.
Maybe there is another way to run this simple alerts..

Thank You in advance
Marek
 

boarders

Well-Known Member
#2
xxx=lastvalue(barssince(day()!=ref(day(),-1))+1);

the above will count the number of bars since day open and output same.

or

xxx=lastvalue(iif(lastvalue(barssince(day()!=ref(day(),-1))+1) >=1 , 1 , lastvalue(barssince(day()!=ref(day(),-1))+1) ));

the above line will output 1 always...if you change the bold figures to the required number of lookback periods you require...then will output that value.

use one of the above lines in your code as required, both will not check or count the previous days candles. then

AlertIf(x2-x1=0,"","Open",xxx);
 

Similar threads