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

[amibroker] Exploration Questions: Sorting, display decimals,array functions and price chg functions



PureBytes Links

Trading Reference Links

Hi,

I have a couple of questions based on this exploration example:

 

//Constants

RSI_BUY_SIG = 25;

RSI_SELL_SIG = 75;

RSI_PER = 5;

 

rsiArr = RSI( RSI_PER );

 

//only set if it's the first time RSI crosses threshold, otherwise set to 0

bArray = IIf(rsiArr < RSI_BUY_SIG && Ref( rsiArr, -1 ) > RSI_BUY_SIG, RSI( RSI_PER ), 0 );

 

//only set if it's the first time RSI crosses threshold, otherwise set to 0

sArray = IIf(rsiArr > RSI_SELL_SIG && Ref( rsiArr, -1 ) < RSI_SELL_SIG ,RSI( RSI_PER ), 0);

 

color = IIf( RSI( RSI_PER )< RSI_BUY_SIG , colorGreen, colorRed ) ;

 

AddColumn( bArray , "rsiBuy", 1.0, colorDefault, color );

AddColumn( sArray , "rsiSell", 1.0, colorDefault, color );

AddColumn( C , "Close", 1.0, colorDefault, color );

 

Filter = bArray > 0 || sArray > 0  ;

 

 

In the above example, I am basically listing the price and RSI each time it crossed above 75 or below 25.  My questions are:

  1. Is there a way to programmatically sort by multiple columns in an exploration (i.e sort by the color scheme ( which is based on condition “RSI( RSI_PER) < RSI_BUY_SIG)  then by date )?
  2. The above shows the rsiBuy, rsiSell and Close column values in whole numbers, why is this and how can I tell it to display with a two decimal precision?
  3. In the code above, i am using two arrays, bArray and sArray, however I would like to display these in one column since there will never be a “collision” for a given bar.  I realize there are other ways of modifying the above code to do this, but wanted to know if there is any type of array union function in AFL, or would I have to do this in a for loop? 
  4. I would like to expand the above to add a “% Price Chg” column.  I would this to be the % gain in price after N days from when the buy/sell signal occurs (so N would be a new constant, i.e. if N=3 then I’d like to know how much the price move 3 periods after the signal).  I am not clear what functions would facilitate this or if this would require looping.

 

Thanks much
    



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





--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.5/178 - Release Date: 11/22/2005