• Australian (ASX) Stock Market Forum

Hello and welcome to Aussie Stock Forums!

To gain full access you must register. Registration is free and takes only a few seconds to complete.

Already a member? Log in here.

Amibroker - AddColumn and Immediate If (IIF)

Discussion in 'Software and Data' started by Peter2047, Aug 9, 2011.

  1. Peter2047

    Peter2047

    Posts:
    32
    Likes Received:
    0
    Joined:
    May 8, 2006
    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.
     
  2. howardbandy

    howardbandy

    Posts:
    838
    Likes Received:
    92
    Joined:
    Jun 13, 2007
    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
     
  3. Peter2047

    Peter2047

    Posts:
    32
    Likes Received:
    0
    Joined:
    May 8, 2006
    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
     
  4. howardbandy

    howardbandy

    Posts:
    838
    Likes Received:
    92
    Joined:
    Jun 13, 2007
    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
     
  5. Peter2047

    Peter2047

    Posts:
    32
    Likes Received:
    0
    Joined:
    May 8, 2006
    Hi Howard,

    To an expert like you, it's so effortless.
    Once again, thank you very much.
     
Loading...

Share This Page