[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Variable Text output in Explore?



PureBytes Links

Trading Reference Links

 

Anyone know how to get variable text output in Explore?

I have a column of numbers representing trades and would like to print stings for each trade as follows:

-1 = "Short"

0  = "Cash"

1  = "Long"

 

I have tried several things, but the lack of string arrays seems to be blocking all attempts. Here's some code to work with. The last line only produces the first conversion. It never loops to show each trade. I tried building a loop here, but AddColumn doesn’t respond to subscripts.

 

/* +++++++++ Exploration items for problem solving ++++++++++   */

trade = 0; //initialize so we can assign [i-1]

for (i = 60; i < BarCount;, i++)

{

if (Buy[i]) trade[i] = 1; //"Long";

    else if (Short[i]) trade[i] = -1; //"Short";

        else if (Sell[i] OR Cover[i]) trade[i] = 0; //"Cash";

            else trade[i] = trade[i-1]; //repeat yesterday's value

}

Filter = 1;

SetOption("NoDefaultColumns",True);

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

AddColumn(trade,"Trade",1.0,IIf(trade == 1,colorGreen,IIf(trade == -1,colorRed,colorGold)),colorDefault);

 

//AddTextColumn(WriteIf(trade == 1,"Long",WriteIf(trade == -1,"Short","Cash")), "Signal",5);

 

--

Terry

 



Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html





YAHOO! GROUPS LINKS