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

[amibroker] Can't get EMA from jscript array .



PureBytes Links

Trading Reference Links

Hello,

Today, I am writing an AFL that contains some jscript. The AFL works 
fine up to the point I want to get the EMA of the evwma. The evwma is 
the returned output array of the jscript. Below is the code and the 
error:

EnableScript("jscript");

<%
function eVWMA( x, y, f0)
{

x = VBArray( x ).toArray();

y = VBArray( y ).toArray();

eVWMA = new Array();

j = 0;
for( i = 1; i < y.length; i++ )
{
	if (y[ i ] > j)
			j = y[ i ];
}

// initialize the first element of result array
eVWMA[ 0 ] = x[ 0 ];

for( i = 1; i < x.length; i++ )
{
   eVWMA[ i ] = (f0 * j - y[ i ]) * eVWMA[ i - 1 ] + y[ i ] * x[ i ]; 

	eVWMA[ i ] = eVWMA[ i ] / ( f0 * j);
}

return eVWMA;

} 

%>

script = GetScriptObject();

sharesFloat = Param("Shares Floating", 2, 0, 10, 0.5 );

Graph0 = Close;
Graph0Color = colorBlack;
Graph0Style = 128;
Graph1 = script.eVWMA( Close, Volume, sharesFloat);

//  evwma = script.eVWMA( Close, Volume, sharesFloat);

//  Graph2 = EMA(evwma, 8);
//  Graph2Color = colorYellow;
//  Graph2Style = styleLine;

The erroneous code has been commented out. How can I get EMA( evwma, 
8 ) ?

TIA RS



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark
Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/l.m7sD/LIdGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/