MS returns a boolean value of 1 or 0 depending on whether a
condition can be expressed as true or false, so you dont need the If((AA-Ref(AA,-2)>0),1,0) it can just be written as (AA-Ref(AA,-2))>0 and it will return a value of 1 if this condition is true, 0 otherwise.
Binary values can be added together, e.g.
|
ma1:=Mov(C,12,S); ma2:=Mov(C,33,S);
x:=Cross(ma1,ma2) + (C>10);
{plot} x; |
"x" will take on three possible values:
0 if the Cross() event did not happen AND the price is not greater than 10
1 if either of the Cross() event happened OR the price is greater than 10, but NOT both
2 if both of the Cross() event happened AND the price is greater than 10.
These concepts allow you to write more simple code to deal with more complex situations.
wabbit
![Big Smile [:D]](/emoticons/emotion-2.gif)
[edit]I didn't deal with the N/A situations, but these can be easily figured out by looking at a chart with the above function plotted.
MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC & MDK
For custom MetaStock programming : http://www.wabbit.com.au
My SkyPE status : 
My SkyPE account : wabbit.com.au