usingSystem;usingSystem.Text;usingcAlgo.API;namespacecAlgo.Indicators{[Indicator]publicclassMarketDepthIndicator:Indicator{privateMarketDepth_marketDepth;publicoverridevoidCalculate(intindex){}protectedoverridevoidInitialize(){// Get Market Depth_marketDepth=MarketData.GetMarketDepth(Symbol);// subscribe to event Updated_marketDepth.Updated+=MarketDepthUpdated;}voidMarketDepthUpdated(){// Draw Market Depth Entries in the indicator panelvarse=newStringBuilder();se.Append("Bid");se.Append(" ");se.Append("Ask");Chart.DrawStaticText("DOM",se.ToString(),VerticalAlignment.Center,HorizontalAlignment.Center,Color.White);se.Clear();se.AppendLine();se.AppendLine();foreach(varentryin_marketDepth.BidEntries){doubledVolume=Math.Round(entry.Volume/1000000.0,2);stringvolume=string.Format("{0}{1}",dVolume,"m");doubleentryPrice=entry.Price;stringaskText=string.Format("{0} {1}",entryPrice.ToString("0.00000"),volume);se.AppendLine(askText);}Chart.DrawStaticText("Bid",se.ToString(),VerticalAlignment.Center,HorizontalAlignment.Center,Color.Red);se.Clear();se.AppendLine();se.AppendLine();foreach(varentryin_marketDepth.AskEntries){doubledVolume=Math.Round(entry.Volume/1000000.0,2);stringvolume=string.Format("{0}{1}",dVolume,"m");doubleentryPrice=entry.Price;se.Append(" ");stringbidText=string.Format("{0} {1}",entryPrice.ToString("0.00000"),volume);se.AppendLine(bidText);}Chart.DrawStaticText("Ask",se.ToString(),VerticalAlignment.Center,HorizontalAlignment.Center,Color.Turquoise);}}}
MarketDepth_marketDepth;protectedoverridevoidInitialize(){_marketDepth=MarketData.GetMarketDepth(Symbol);// subscribe to event Updated_marketDepth.Updated+=MarketDepthUpdated;}// user defined function MarketDepthUpdatedvoidMarketDepthUpdated(){// Do something}