Three Options

Option A -- The best solution would be to ask Tomasz to add PRODUCT to
AFL's function list in a future upgrade.

Option B -- Do a backtest with a very large portfolio such as 100,
200, or 500 stocks. Have the backtest force exits for stocks every 5
bars. You could force an exit every bar to get something like
ValueLine's VLIC index but forcing exits every 5 or 10 bars would like
be a good approximation. This does work since I have done it to make
unweighted indexes of several groups of 100 stocks. For example: index
of the 100 stocks with prices closest to $2, stocks closest to $5, etc.

Option C -- I have not tested this third option, but it might work.
Write a loop in AFL that references individual bars of the array.  Eg,
yourarray[barindex] where barindex is your counter. Put "1.0" in the
first bar and then fill the rest of the bars using the previous bar
times change ratio for each bar which you already have in your foreign
array. Here is some really rough pseudo code to give the idea. 

Factor = yourfactorfromforeign ;// as per your code
barindex = 1; // need to check to see if first bar is 1 or 0
YourIndex[barindex] = 1.000; //This initial value is arbitrary

startloop
barindex = barindex + 1;// there likely is a better way to count
YourIndex[barindex] = YourIndex[barindex - 1] * Factor;
repeatloop until barindex == lastvalue(cum(1)); //or something better

Good luck. 

b


--- In [email protected], "personal592002"
<[EMAIL PROTECTED]> wrote:
>
> How to code Unweighted Arithmetic Price Index using ATC?
> I am stuck. I can export/import to/from Excel but was hoping someone 
> could suggest an easier way.  
> 
> /*Unweighted Arithmetic Price Index
> http://www.valueline.com/news/vlv030328x.html*/
> 
> AddToComposite( C/Ref(C,-1), "~UPI", "X", flags = 1 ) ;
> AddToComposite( 1, "~UPI", "I" );
> Buy = 0; 
> Factor = Foreign("~UPI","C") / Foreign("~UPI","I");
> 
> // needs PRODUCT function like in Excel not Cum() 
> UAPI =  100 * Cum(Factor); 
> 
> Plot(UAPI,"Unweighted Arithimetic Index",colorGreen,styleLine);
>


Reply via email to