I did it with the SQL code instead...  it's a really cool routine that 
calculates Mov Avg and Standard Deviation then the Bollinger Bands and I send 
that to FLEX... if anyone wants the SQL code let me know... cra...@steury.com 
(I don't receive emails from this thread)

--- In flexcoders@yahoogroups.com, "jc_bad28" <jc_ba...@...> wrote:
>
> I'll vouche for ta-lib as well.  I used it in an excel trading/chart app I 
> made years ago.  
> 
> My approach for the ticker data array would be to use a for..loop instead of 
> hard coding.  That way you could adjust a few paramaters.
> 
> When it comes to technical indicators, I prefer making the calcs on the 
> server side and then having the data available to be plotted 
> passed/requested/whatever. The reason being I can use that data in whatever 
> client I want versus trying to learn different ways of doing the same thing 
> in different clients.
> 
> Another approach you might want to look at is using a charting library that 
> has built in functions for the traditional indicators.  I've used 
> ChartDirector from ASE in multiple clients and multiple platforms.  
> http://www.advsofteng.com/
> 
> You could write up your charting section in whatever and then bring it into 
> flex as an image. ChartDirector is also open enough that you can program 
> custom indicators into as well which is something I've done quite a few times 
> and is what really sold me on the product.
> 
> --- In flexcoders@yahoogroups.com, Jake Churchill <reynacho@> wrote:
> >
> > We do the same thing.  See this screen shot:
> > 
> > http://www.reynacho.com/wp-content/uploads/2009/05/cse-charting.jpg
> > 
> > There's a lot more than just a moving average and bollinger bands there but
> > those are parts of it.  In order to get this data, we first tapped into a
> > feed which you have to pay good money for.  I believe we are using NxCore
> > which I think is a DTN product.  You might look into that but I know there
> > are others as well.
> > 
> > For the data, we pass data into a java library called ta-lib:
> > http://ta-lib.org/
> > 
> > It has methods for moving averages, deviations, etc.  We found that the
> > calculations for our app were simply too intense to be done on the client.
> > But, we have 5-7 years worth of data that we are looking at for calculations
> > so you might not run into the same bottleneck we had
> > 
> > -Jake
> > 
> > On Fri, Oct 23, 2009 at 11:49 AM, cjsteury2 <craigj@> wrote:
> > 
> > >
> > >
> > >
> > >
> > > <answer>.net SQL database through Web services call to Flex...</answer>...
> > > would like to create a new Array based on existing Array of Ticker data..
> > >
> > > So I need to create a new Array Collection then loop through and add the
> > > date from the Tickers Array Collection along with the Moving 20 day 
> > > average
> > > of the Close Price... THEN ( I have not mentioned this ) What I REALLY 
> > > want
> > > is a Standard Deviation Calcuation against the Moving Average to plot 
> > > Upper
> > > and Lower Bollinger Bands....
> > >
> > > Here's my initial guesstimate at building the new 20 Day Moving Average
> > > Array Collection from the Existing Array_Tickers ArrayCollection....
> > >
> > > [Bindable] public var Array_BBands:ArrayCollection; (new mov avg Ac)
> > >
> > > public function bld_Array_BBands():void
> > > {
> > > Array_BBands = new ArrayCollection;
> > > for (var i:int=0;i<Array_Tickers.length;i++) \\ loop through existing
> > > Array_Tickers
> > > {
> > > Array_BBands.addItem(Array_Tickers.getItemat(i).date);
> > > if (i>=20) \\ start at 20th row - as Moving Avg is 20 day
> > > {
> > > var mavg_tick:Int = 0; \\ create variable to hold Moving Average
> > > mvag_tick = Array_Tickers.getItemAt(i).close.valueof(); \\ need to pick up
> > > the date of the Array_Tickers
> > > mvag_tick += Array_Tickers.getItemAt(i-1).close.valueof();
> > > mvag_tick += Array_Tickers.getItemAt(i-2).close.valueof();
> > > mvag_tick += Array_Tickers.getItemAt(i-3).close.valueof();
> > > mvag_tick += Array_Tickers.getItemAt(i-4).close.valueof();
> > > mvag_tick += Array_Tickers.getItemAt(i-5).close.valueof();
> > > mvag_tick += Array_Tickers.getItemAt(i-6).close.valueof();
> > > mvag_tick += Array_Tickers.getItemAt(i-7).close.valueof();
> > > mvag_tick += Array_Tickers.getItemAt(i-8).close.valueof();
> > > mvag_tick += Array_Tickers.getItemAt(i-9).close.valueof();
> > > mvag_tick += Array_Tickers.getItemAt(i-10).close.valueof();
> > > mvag_tick += Array_Tickers.getItemAt(i-11).close.valueof();
> > > mvag_tick += Array_Tickers.getItemAt(i-12).close.valueof();
> > > mvag_tick += Array_Tickers.getItemAt(i-13).close.valueof();
> > > mvag_tick += Array_Tickers.getItemAt(i-14).close.valueof();
> > > mvag_tick += Array_Tickers.getItemAt(i-15).close.valueof();
> > > mvag_tick += Array_Tickers.getItemAt(i-16).close.valueof();
> > > mvag_tick += Array_Tickers.getItemAt(i-17).close.valueof();
> > > mvag_tick += Array_Tickers.getItemAt(i-18).close.valueof();
> > > mvag_tick += Array_Tickers.getItemAt(i-19).close.valueof();
> > > var mavg:Int = (mavg_tick/20);
> > > Array_BBands.addItem(mavg);
> > > }
> > > }
> > >
> > > }
> > >
> > > If that works ( and I have no idea if it will ) then I need to get the
> > > Standard Deviation calcualted somehow. Because the Formula for what I 
> > > really
> > > want as previously stated is The Bollinger Bands formular or (MA+K*sigma)
> > > Moving Average (20 period) + or - depending if it's upper or lower (2 *
> > > sigma) Sigma is the Standard Deviation, and I am fairly certain that
> > > actionscript does not calculate the Standard Deviation, so I'll need to do
> > > that somehow and I have no idea how to do that...
> > >
> > > This is a lot for me, and I don't expect you or others have the answers 
> > > but
> > > I need to get the Std Deviation caclulated from the Mean Value above and
> > > this is how to do that...
> > >
> > > http://en.wikipedia.org/wiki/Standard_Deviation
> > >
> > > I am not sure exactly the best way to proceed, but if anyone has a
> > > suggestions... I guess I would take the difference of each number in the
> > > series above form the mean, divide the sum of the numbers by the count 
> > > (20)
> > > and take the square root.
> > >
> > > It's a brain teaser and I am working on it a piece at a time.....
> > >
> > > If anyone has a shortcut I'd take it.
> > >
> > > --- In flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>,
> > > "jc_bad28" <jc_bad28@> wrote:
> > > >
> > > > How are you receiving your price data to plot? Price feed? Static file?
> > > What you could do is create a function to loop through the array and 
> > > perform
> > > the moving average calculation and add the result as an extra "column" in
> > > the array. Are you plotting the full historic price data set? If so, your 
> > > MA
> > > will begin at the nth bar where n is your MA period setting. eg.. a 20 day
> > > MA won't start until the 20th day into the data set.
> > > >
> > > > If you're using a static dataset, you could do the calculation in Excel
> > > and then save the entire datset as XML and just bring that into flex and
> > > plot the MA from the existing values.
> > > >
> > > > --- In flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>,
> > > "cjsteury2" <craigj@> wrote:
> > > > >
> > > > > Hi all,
> > > > >
> > > > > I am stumped.
> > > > >
> > > > > If I want to add an additional data series to a HLOC Chart that is a
> > > line series of a simple 20 day moving average for the closing price
> > > ("Close") value in an array collection (Array_Tickers)... how would I
> > > perform that calculation in Flex?
> > > > >
> > > > > <mx:lineSeries id=mavg
> > > > > dataprovider="Array_Tickers"
> > > > > ySeries="Close" />
> > > > >
> > > > > How would I calculate "Close" as {The SUM for the Value of "Close" for
> > > the previous 20 days / divided by 20}...
> > > > >
> > > >
> > >
> > >  
> > >
> >
>


Reply via email to