Can someone help on the proper use of 'addtextcolumn' function ???

#1
Can someone help me out?

During AFL coding, i wanted results to show in cells of the column that meet the criteria while the other cells in the column remain blank/null.

My afl coding solution was as follows:
QUOTE:
Filter = 1;
AddColumn(MA(EstSec_3,260),"Volatility",1.6,IIf(MA(EstSec_3,260)>0,colorGreen,colorRed));
AddColumn(EstSec_5,"Relative Price Strength",1.6,IIf(EstSec_5>1,colorGreen,colorRed));
AddColumn(EstSec_7,"Cash Momentum Rate",1.6,IIf(EstSec_7>0,colorGreen,colorRed));
SetSortColumns(-3);
AddRankColumn();
SetSortColumns(-5);
AddRankColumn();
SetSortColumns(-4);
AddRankColumn();
AddTextColumn(IIf(((MA(EstSec_3,260)>0)AND(EstSec_5>1)AND(EstSec_7>0)),printf(FullName()),null),"Stock Purchase",colorBlue);
UNQUOTE:

Unfortunately, my use of the function "addtextcolumn" is not proper as the error sign gave 'wrong arguements'. Can someone help on the proper use of "addtextcolumn" function ???

I remain.

Mike-Ekwueme (respartner)

N.B: i am an AFL coding beginner....
 

mastermind007

Well-Known Member
#2
Can someone help me out?

During AFL coding, i wanted results to show in cells of the column that meet the criteria while the other cells in the column remain blank/null.

My afl coding solution was as follows:
QUOTE:
Filter = 1;
AddColumn(MA(EstSec_3,260),"Volatility",1.6,IIf(MA(EstSec_3,260)>0,colorGreen,colorRed));
AddColumn(EstSec_5,"Relative Price Strength",1.6,IIf(EstSec_5>1,colorGreen,colorRed));
AddColumn(EstSec_7,"Cash Momentum Rate",1.6,IIf(EstSec_7>0,colorGreen,colorRed));
SetSortColumns(-3);
AddRankColumn();
SetSortColumns(-5);
AddRankColumn();
SetSortColumns(-4);
AddRankColumn();
AddTextColumn(IIf(((MA(EstSec_3,260)>0)AND(EstSec_5>1)AND(EstSec_7>0)),printf(FullName()),null),"Stock Purchase",colorBlue);
UNQUOTE:

Unfortunately, my use of the function "addtextcolumn" is not proper as the error sign gave 'wrong arguements'. Can someone help on the proper use of "addtextcolumn" function ???

I remain.

Mike-Ekwueme (respartner)

N.B: i am an AFL coding beginner....
Mike

I cannot make head or tail of the logic you are trying to implement. .

However, I can say following w.r.t. AddText function.

Values passed to AddText column need to be scalar or array-invariant textual information. If you pass an Array in place of text function, only the last value of array will get printed as text.

Also, you cannot use IIf function with textual data. You need to use WriteIf(...) function

HTH
 
#3
Mike

I cannot make head or tail of the logic you are trying to implement. .

However, I can say following w.r.t. AddText function.

Values passed to AddText column need to be scalar or array-invariant textual information. If you pass an Array in place of text function, only the last value of array will get printed as text.

Also, you cannot use IIf function with textual data. You need to use WriteIf(...) function

HTH
============================================

Dear MM,

I have tried 'writeif" function but it seems not appropriate as it demands a "text" result. I made progress using function - fullname() which is an array (if i am not mistaken). The following command line worked without any criteria:

AddTextColumn(Fullname(),"Stock Purchase",77, colorBlue);

-----------------------------------------------------------------

Would the following command line be appropriate when there is a criteria with a 'last spring/value of an array' result ?

AddTextColumn(printf(IIf((MA(EstSec_3,260)>0)AND(EstSec_5>1)AND(EstSec_7>0),FullName(),null)),"Stock Purchase",77, colorBlue);


or

AddColumn(IIf((MA(EstSec_3,260)>0)AND(EstSec_5>1)AND(EstSec_7>0),FullName(),Null),"Stock Purchase",77,colorBlue);


Command Explanation: I want the last string/value in the array {(fullname()} to show in a cell of a column if the criteria is met unless the cell remains blank...

I hope this time my explanation was clearer.
Your kind advice and solution proposal will be gladly appreciated.
I remain.

Mike....
 
#4
Hi Mike

What MM had said is right,
use only text functions like AddTextColumn with WriteIf
don't mix them up

for e.g.

Code:
AddTextColumn(WriteIf( MA(C,7) > MA(C,13), FullName(), ""),"Stock Purchase",77, colorBlue);
In the above just change the condition i.e. in place of MA(C,7) > MA(C,13), use your own criteria


Happy :)

============================================

Dear MM,

I have tried 'writeif" function but it seems not appropriate as it demands a "text" result. I made progress using function - fullname() which is an array (if i am not mistaken). The following command line worked without any criteria:

AddTextColumn(Fullname(),"Stock Purchase",77, colorBlue);

-----------------------------------------------------------------

Would the following command line be appropriate when there is a criteria with a 'last spring/value of an array' result ?

AddTextColumn(printf(IIf((MA(EstSec_3,260)>0)AND(EstSec_5>1)AND(EstSec_7>0),FullName(),null)),"Stock Purchase",77, colorBlue);


or

AddColumn(IIf((MA(EstSec_3,260)>0)AND(EstSec_5>1)AND(EstSec_7>0),FullName(),Null),"Stock Purchase",77,colorBlue);


Command Explanation: I want the last string/value in the array {(fullname()} to show in a cell of a column if the criteria is met unless the cell remains blank...

I hope this time my explanation was clearer.
Your kind advice and solution proposal will be gladly appreciated.
I remain.

Mike....
 
#5
Dear Happy & MM007,

Thanks again, it worked !!!
The command was as follows:

AddTextColumn(WriteIf(MA(EstSec_3,260)>0 AND EstSec_5>1 AND EstSec_7>0,FullName(),""),"Stock Purchase",77,colorBlue);

Mike....

==============================

Hi Mike

What MM had said is right,
use only text functions like AddTextColumn with WriteIf
don't mix them up

for e.g.

Code:
AddTextColumn(WriteIf( MA(C,7) > MA(C,13), FullName(), ""),"Stock Purchase",77, colorBlue);
In the above just change the condition i.e. in place of MA(C,7) > MA(C,13), use your own criteria


Happy :)
 
#6
Dear Happy,

The 'addrankcolumn' function creates ranking columns which are one-based.

Can the numbers (ranks) within the rank column be used for other logic purpose ?
If yes, can the name of the rank column be the name of the array within a logic statement ?

For example:
rank(relative price strength)<21
//accept all tickers with rank number or position less than No. 21//

If this is wrong, is there an alternative function for such rank logic ?
Please yr kind advice will be most highly appreciated.
I remain.

Mike-Ekwueme....
 
#7
Dear MM007,

The 'addrankcolumn' function creates ranking columns which are one-based.

Can the numbers (ranks) within the rank column be used for other logic purpose ?
If yes, can the name of the rank column be the name of the array within a logic statement ?

For example:
rank(relative price strength)<21
//accept all tickers with rank number or position less than No. 21//

If this is wrong, is there an alternative function for such rank logic ?
Please yr kind advice will be most highly appreciated.
I remain.

Mike-Ekwueme....
 

mastermind007

Well-Known Member
#8
Dear MM007,

The 'addrankcolumn' function creates ranking columns which are one-based.

Can the numbers (ranks) within the rank column be used for other logic purpose ?
If yes, can the name of the rank column be the name of the array within a logic statement ?

For example:
rank(relative price strength)<21
//accept all tickers with rank number or position less than No. 21//

If this is wrong, is there an alternative function for such rank logic ?
Please yr kind advice will be most highly appreciated.
I remain.

Mike-Ekwueme....
Yes, Mike it is possible but getting it right is bit difficult and will take serious debugging efforts.
 
#9
Yes, Mike it is possible but getting it right is bit difficult and will take serious debugging efforts.
Dear MM007,

I have rcv-ed a lot of thanks for this question.
It seems that this simple 'ranking number' logic function in Excel is not adequately provided in Amibroker.
Can you help us all by providing a rough copy of the code for everyone to work on?
Maybe with more minds working on it - we can create the code.
I remain.

Mike-Ekwueme...
 

TradeOptions

Well-Known Member
#10
Yes, Mike it is possible but getting it right is bit difficult and will take serious debugging efforts.
Dear MM007,

I have rcv-ed a lot of thanks for this question.
It seems that this simple 'ranking number' logic function in Excel is not adequately provided in Amibroker.
Can you help us all by providing a rough copy of the code for everyone to work on?
Maybe with more minds working on it - we can create the code.
I remain.

Mike-Ekwueme...
respartner, I am not sure if it will help you directly, but you might find something useful from the following link. "If you do not find this useful, then I am sorry to bug." -

ww w.poweryourinvestment.com/indian-stock-market/amibroker/rank-stocks-based-scan-criteria-1964-2.html#post51579
The AFL is given in the same thread. All credit goes to the original programmer ST for this work -

Code:
p = ROC(Close, 14); 

Plot(PercentRank(p,200), "P Rank", colorBlue,styleLine); //200 value can be replaced with what you want

Filter = 1; 

SetOption("NoDefaultColumns", True );

AddColumn( DateTime(), "Date", formatDateTime );


AddTextColumn( FullName(), "Full name", 77 , colorDefault, IIf( Close < 10, colorLightBlue, colorDefault ) );

AddColumn(Close, "Close", 1.2); 

AddColumn(PercentRank(p,200), "Percent Rank ROC Score", 1.2);
Some more explanation given in this post -
ww w.poweryourinvestment.com/indian-stock-market/amibroker/rank-stocks-based-scan-criteria-1964-3.html?posted=1#post51595

Thanks and regards
 

Similar threads