Australian (ASX) Stock Market Forum

Amibroker - AddColumn and Immediate If (IIF)

Joined
8 May 2006
Posts
32
Reactions
0
Hi All,

Need help from Amibroker expert here. In my analysis scanner, I need to add column under the following conditions.
1. 0-1% up from previous day - assign a 1
2. 1-2% up from previous day - assign a 2
3. >2% up from previous day - assign a 3
The next 3 conditions are for down, just -1, -2, and -3.

I am having trouble with this statement AddColumn(IIF(........),1.4). I am using a nested IFF for the 6 conditions. Is this possible ? Thanks in advance.
 
Hi Peter --

See if this helps.

// AddColumnExample.afl
//
DailyChange = 100 * ( C - Ref( C, -1 ) ) / Ref( C, -1 );
DCInt = IIf( DailyChange > 0, int( DailyChange ) + 1, int( DailyChange ) - 1 );

Plot( DailyChange, "DC", colorGreen, styleLine );
Plot( DCInt, "DCInt", colorRed, styleLine );

Filter = 1;
AddColumn( Close, "Close", 10.4 );
AddColumn( DailyChange, "DailyChange", 10.4 );
AddColumn( DCInt, "DailyChangeInteger", 10.0 );

////////////////// end ///////////////////////

Thanks,
Howard
 
Hi Howard,
Thank you very much for the suggested solution. It works.
The outout list is very long. Is it possible to add a condition to show only e.g. changes more than > +/- 0.5% ?

Thanks again. Peter
 
Hi Peter --

One way to restrict the output is through use of the Filter statement.

For example something like this:

Filter = abs(DailyChange) >= 0.5;

Thanks,
Howard
 
Top