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

Re: Previous Value



PureBytes Links

Trading Reference Links

Hi Steve,
I did not see in your code
var1(0)=...
Is it necessary to define it?
This is the initial price.

Dimitris Tsokakis
--- In amibroker@xxxx, Steve Wiser <slwiserr@xxxx> wrote:
> Jeff:
> 
> This has been done using VBScript a couple of times once as an 
example and 
> another as a tool for an indicator.
> See the attached file as an example.
> 
> Steve
> 
> 
> 
> 
> At 03:29 PM 6/19/01 -0400, you wrote:
> >Hello to All!
> >
> >Just got the lastest issure of Active Trader Magazine....always 
like to 
> >play around with the systems they present in "The Trading Systems 
Lab" 
> >section...
> >
> >This month they present a system based on a Volume Weighted Moving 
> >Average. Everything is fairly simple to code into AFL, with one 
little 
> >exception...to start the calculation of the VWMA you must have the 
> >"previous" VWMA to preform the calculation. There is my 
problem...how to 
> >get a "previous" value of an array when you haven't preformed the 
first 
> >calculation of the array.
> >
> >All you "Codies" out there...any suggestions?
> >
> >Thanks
> >
> >Jeff
> 
> EnableScript("vbscript");
> <%
> close = AFL( "close" ) 
> factor = 0.09
> var1=close
> SetValue Close
> 
> Function SetValue(Close)
> for i = 1 to UBound( close )
> var1( i )= factor * close( i ) + (1 - factor) * var1( 
i - 1 )
> next 
> end function
> 
> AFL.Var("graph0") = close
> AFL.Var("graph1") = var1
> %>
> WriteVal( graph1 );