World Market AFL

#1
hi i got this afl modified for our india stock version..
Code:
_SECTION_BEGIN("World Markets");

//custom csv list of indicies, etfs, stocks on finance.google.com
symbols = ".DJI,.INX,VNM,XFVT,UKX,SHA:000001,NIFTY,BANKNIFTY,SENSEX,INDEXEURO:PX1,INDEXNIKKEI:NI225,INDEXHANGSENG:HSI,INDEXFTSE:UKX,";
symbols+= "CURRENCY:EURUSD,CURRENCY:GBPUSD,CURRENCY:USDJPY,CURRENCY:EURJPY,";

//===============================================
Title  = "";//"WORLD MARKETS";
Interv = Param("Interval,sec", 300, 60,600,60,0);	//refresh rate, in sec	
RequestTimedRefresh( interv, onlyvisible = True ) ;

EnableScript("jscript");
<%
function getQuotes(symbols)	{
	url = "http://finance.google.com/finance/info?q=" + symbols;
	var httpReq = new ActiveXObject("WinHttp.WinHttpRequest.5.1");	//xml?
	httpReq.Open("GET", url, true);	//true=Asynchronously
    httpReq.Send();
    httpReq.WaitForResponse(10);	//Asynchr
    response = httpReq.ResponseText;//google respones a JSON array
    // [ { "id": "983582" ,"t" : ".DJI" ,"e" : "INDEXDJX" ,...} ,{...} ]
	
    return response.substring(5).replace("]",""); 
}

function jsonParse(jsonQuote)	{
	eval("quote=" + jsonQuote);
	return quote;
}
%>

width = 160;
height= 80;
cols  = int((Status("pxwidth")-80)/width); //or Status("pxheight")
GfxSetBkMode(1);
//GfxSetBkColor(colorDarkYellow);

script = GetScriptObject();
jsonQuoteArray = script.getQuotes(symbols);
jsonQuoteArray = StrReplace(jsonQuoteArray, ",{", "|{");

for (i = 0; (jsonQuote=StrExtract(jsonQuoteArray,i,separator='|'))!=""; i++ )  { 
	quote = script.jsonParse(jsonQuote);
	
	x = 10 + width*(i%cols);
	y = 10 + height*int(i/cols);
	clr= IIf(StrToNum(quote.c)>=0, colorbrightgreen, colorRed);
	
	GfxGradientRect( x, y, x+width-10, y+height-10, 28, colordarkGrey );
	GfxSetTextColor(clr);
	GfxSelectFont("Tahoma", 10 );
	GfxTextOut ( quote.e+":" +quote.t, x, y   );	//e:exchange, t:ticker
	GfxTextOut ( quote.l+"  "+quote.c, x, y+50);	//l:last, c:change
	GfxSelectFont("Tahoma", 14 );						
	GfxTextOut ( quote.cp+"%"  , x+30, y+20  );		//cp:change% Hcenter
	//Title+= "\n"+EncodeColor(clr)+ quote.t +" "+ quote.l +" "+ quote.c +" ("+quote.cp+"%)";

}

_SECTION_END();



:thumb::thumb:
 

mastermind007

Well-Known Member
#2

Similar threads