﻿var Global={};
try{window.top.Global=Global;}
catch(err){}
Global.AppUrl="http://www.stockmarketstudio.com";

Global.Inicators=new Indicators();
Global.Inicators.Combo=[
"MA",		"Simple Moving Average",
"EMA",		"Exponential Moving Average",
"BOLLINGER","Bollinger Bands",
"MAE",		"MA Envelopes",
"LR",		"Linear Regression",
"LRC",		"Linear Regression Channel",
"PC",		"Price Channel",
"PSAR",		"Parabolic SAR",
"TSF",		"Time Series Forecast",
"VBP",		"Volume by Price",
//"----------------------------"
"ACCDIS",		"Accumulation / Distribution Line",
"CCI",			"Commodity Channel Index",
"CV",			"CV - Chaikin's Volatility (UD)",
"DMI",			"Directional Movement Index",
"FSTOCHASTIC",	"Fast Stochastic Oscillator",
"MACD",			"MACD - Moving Average Convergence / Divergence",
"MOMENTUM",		"Momentum",
"OBV",			"On Balance Volume",
"ROC",			"Rate of Change",
"RSI",			"RSI - Relative Strength Index",
"SSTOCHASTIC",	"Slow Stochastic Oscillator",
"WILLIAMS",		"Williams %R",
"ADX",			"ADX - Average Directional Index",
"ATR",			"Average True Range",
"VOLP",			"Volume+",
"NVI",			"Negative Volume Index",
"PVI",			"Positive Volume Index",
"VACC",			"Volume Accumulation",
"VROC",			"Volume Rate of Change",
"COSC",			"Chaikin Oscillator",
"POSC",			"Price Oscillator",
"ULTOSC",		"Ultimate Oscillator",
"VOLOSC",		"Volume Oscillator",
"DPO",			"Detrended Price Oscillator",
"EMV",			"Ease of Movement",
"MONEYFLOW",	"Money Flow Index",
"WVOL",			"Wilder's  Volatility",
"WAD",			"Williams Accumulation/Distribution Indicator"
];

Global.Inicators.Pages=[
"MA","MovingAverage.aspx",
"EMA","ExponentialMovingAverage.aspx",
"BOLLINGER","BollingerBands.aspx",
"MAE","MAEnvelopes.aspx",
"LR","LinearRegression.aspx",
"LRC","LinearRegressionChannel.aspx",
"PC","PriceChannel.aspx",
"PSAR","ParabolicSAR.aspx",
"TSF","TimeSeriesForecast.aspx",
"VBP","VolumeByPrice.aspx",
//"----------------------------"
"ACCDIS",		"AccumulationDistributionLine.aspx",
"CCI",			"CommodityChannelIndex.aspx",
"CV",			"ChaikinVolatility.aspx",
"DMI",			"DirectionalMovementIndex.aspx",
"FSTOCHASTIC",	"FastStochasticOscillator.aspx",
"MACD",			"MovingAverageConvergenceDivergence.aspx",
"MOMENTUM",		"Momentum.aspx",
"OBV",			"OnBalanceVolume.aspx",
"ROC",			"RateOfChange.aspx",
"RSI",			"RelativeStrengthIndex.aspx",
"SSTOCHASTIC",	"SlowStochasticOscillator.aspx",
"WILLIAMS",		"WilliamsR.aspx",
"ADX",			"AverageDirectionalIndex.aspx",
"ATR",			"AverageTrueRange.aspx",
"VOLP",			"VolumePlus.aspx",
"NVI",			"NegativeVolumeIndex.aspx",
"PVI",			"PositiveVolumeIndex.aspx",
"VACC",			"VolumeAccumulation.aspx",
"VROC",			"VolumeRateOfChange.aspx",
"COSC",			"ChaikinOscillator.aspx",
"POSC",			"PriceOscillator.aspx",
"ULTOSC",		"UltimateOscillator.aspx",
"VOLOSC",		"VolumeOscillator.aspx",
"DPO",			"DetrendedPriceOscillator.aspx",
"EMV",			"EaseOfMovement.aspx",
"MONEYFLOW",	"MoneyFlowIndex.aspx",
"WVOL",			"WilderVolatility.aspx",
"WAD",			"WilliamsAccumulationDistribution.aspx"
 ];

Global.Inicators.Panels=["Description","Charts","Strategy"];

DG_CF.Indicators=function(){return new Indicators();}
function Indicators()
{
	DG_Object.call(this);
	var myself=this;
	this.Panel=0;
	this.Method="MA";
	this.Symbol="MSFT";
	var chartIFrame=DG_Obj("chartIFrame");
	var chartIFrameURL=Global.AppUrl+"/SnapCharts.html";

	this.ParseUrl=function()
	{
		var ss=document.location.pathname.split('/');
		if(ss.length<4)throw("");
		this.Panel=ss[2];
		var a=Global.Inicators.Pages;
		for(var i=0;i<a.length;i++)
		{
			var name=a[i];
			if(name.toLowerCase()==ss[3].toLowerCase())
				this.Method=a[i-1];
		}
		var req=DG_ParseUrl();
		var symbol=req["s"];
		if(!symbol)symbol="MSFT";
		this.Symbol=symbol;
		if(chartIFrame)
			chartIFrame.src=chartIFrameURL+"?s="+this.Symbol+"&m="+this.Method;
	}
	this.PageUrl=function()
	{
		var a=myself.Pages;
		var p;
		for(var i=0;i<a.length;i++){if(myself.Method==a[i])p=a[i+1];}
		return Global.AppUrl+"/Indicators/"+myself.Panel+"/"+p+"?s="+this.Symbol;
	}
}

function Trends()
{
	DG_Object.call(this);
	var myself=this;
	this.Symbol="MSFT";
	
	this.PageUrl=function()
	{
		var a=myself.Pages;
		var p;
		for(var i=0;i<a.length;i++){if(myself.Panel==a[i].i)p=a[i].p;}
		return Global.AppUrl+"/Trends/"+p+"?s="+this.Symbol;
	}
	
	this.ParseUrl=function()
	{
		var ss=document.location.pathname.split('/');
		if(ss.length<2)throw("");
		var page=ss[2].toLowerCase();
		Global.Trends.Panel="Indexes";
		for(var i=0;i<Global.Trends.Pages.length;i++)
		{
			var p=Global.Trends.Pages[i];
			if(page==p.p.toLowerCase())
				Global.Trends.Panel=p.i;
		}
	}
}
Global.Trends=new Trends();
Global.Trends.Panels=["Stocks","Indexes"];
Global.Trends.Pages=[{i:"Stocks",p:"StockForecast.aspx"},{i:"Indexes",p:"IndexForecast.aspx"}];


DG_CF.ChartParams=function(){return new ChartParams();}
function ChartParams()
{
	DG_Object.call(this);
	var myself=this;
}
Global.ChartParams=new ChartParams();
Global.ChartParams.DurationCombo=[
"3m", "3 Month (Daily)",
"6m", "6 Month (Daily)",
"1y", "1 Year (Daily)",
"3y", "3 Year (Weekly)",
"5y", "5 Year (Weekly)",
"5ym","5 Year (Monthly)"
];

Global.ChartParams.StyleCombo=[
"1","Candle",
"2","Bar",
"4","Line",
"8","Histogram",
"12","Area"
];

