Exemple #1
0
 private void miTwoIndi_Click(object sender, System.EventArgs e)
 {
     if (ChartControl.Chart.Areas.Count > 2)
     {
         ChartControl.Chart[2].Formulas.Clear();
         ChartControl.Chart[2].AddFormula("RSI");
         ChartControl.Chart[2].AddFormula("VOL");
         ChartControl.Chart[2].Bind();
         ChartControl.Chart[2].Formulas[1].AxisYIndex = 1;
         ChartControl.NeedRebind();
     }
 }
Exemple #2
0
        /// <summary>
        /// Load data from yahoo, and start a streaming data thread to update current price.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
//		private void miLoadFromYahooStreaming_Click(object sender, System.EventArgs e)
//		{
//			//Use yahoo data manager as inner data manager
//			YahooDataManager ydm = new YahooDataManager();
//			ydm.CacheRoot = FormulaHelper.Root+"Cache";
//
//			//MemoryDataManager manage stock data in memory,
//			//Use AddNewPacket to add streaming data packet to it.
//			//Use RemoveSymbol to remove data from memory.
//			//It takes an inner data manager, all historical data is from the inner data manager
//			MemoryDataManager mdm = new MemoryDataManager(ydm);
//
//			//Assign memory data manager to the chart control.
//			string s = LoadDataManager(mdm,"MSFT",DataCycle.Day,200);
//
//			//Avoid flicker when refresh the chart
//			ChartControl.MemoryCrossCursor = true;
//
//			//Show 15 days future bar.
//			ChartControl.EndTime = DateTime.Today.AddDays(15);
//			//Show chart from 8 months ago.
//			ChartControl.StartTime = DateTime.Today.AddMonths(-8);
//
//			//You can use mdm.AddNewPacket to add a single bar
//			//mdm.AddNewPacket(new DataPacket("MSFT",DateTime.Now,25,28,24,26,100000,26));
//
//			//dcbStream is a DataClientBase class,
//			//It will let you add streaming data to MemoryDataManager in a thread.
//			if (dcbStream==null)
//			{
//				dcbStream = new YahooDataClient();
//				//You can use other data client,
//				//dcbStream = new ProphetDataClient();
//				//dcbStream.Login("...","...");
//
//				//When streaming packet arrive, call  dcb_OnStreamingData
//				dcbStream.OnStreamingData +=new StreamingDataChanged(dcb_OnStreamingData);
//				dcbStream.UtcStreamingTime = false;
//
//				//Start the download thread
//				dcbStream.StartStreaming(s);
//			}
//			else
//			{
//				//SetStreamingSymbol will set symbol for downloading
//				//You can use AddSymbol for multi-symbols downloading
//				dcbStream.SetStreamingSymbol(s);
//			}
//		}

//		private void miText_Click(object sender, System.EventArgs e)
//		{
//			LoadDataManager(new TextDataManager(),"TEST", DataCycle.Day,200);
//		}

//		private void miForexText_Click(object sender, System.EventArgs e)
//		{
//			MemoryDataManager mdm = new MemoryDataManager(new ForexTextDataManager());
//			string s = LoadDataManager(mdm,"EURUSD", DataCycle.Parse("Minute15"),150)+"=X";
//
////			if (dcbForex==null)
////			{
////				dcbForex = new YahooDataClient();
////				dcbForex.OnStreamingData+=new StreamingDataChanged(dcb_OnStreamingData);
////				dcbForex.UtcStreamingTime = false;
////				dcbForex.StartStreaming(s);
////			}
////			else dcbForex.SetStreamingSymbol(s);
//		}

//		private void miLoadBond_Click(object sender, System.EventArgs e)
//		{
//			LoadDataManager(new BondTextDataManager(),"ZT1", DataCycle.Parse("Minute10"),200);
//		}

        /// <summary>
        /// Refresh the chart when new data streaming data come
        /// </summary>
        /// <param name="dp"></param>
        private void dcb_OnStreamingData(object sender, DataPacket dp)
        {
            if (dp.Symbol.EndsWith("=X"))
            {
                dp.Symbol = dp.Symbol.Substring(0, dp.Symbol.Length - 2);
            }

            if (ChartControl.HistoryDataManager is MemoryDataManager)
            {
                MemoryDataManager mdm = ChartControl.HistoryDataManager as MemoryDataManager;

                //Add streaming data to mdm
                mdm.AddNewPacket(dp);
                if (ChartControl.Symbol == dp.Symbol)
                {
                    ChartControl.NeedRebind();
                }
                //GC.Collect();  //Release memory
            }
        }