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:
- 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 )?
- 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?
- 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?
- 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