Trabajando con Market Depth
La API le permite recibir datos sobre la actualización de MarketDepth. Es necesario anular el método MarketDepthChanged(MarketDataArg arg).
public class SampleMD:Indicator { protected override void OnCalculate(int bar, decimal value) { } protected override void MarketDepthChanged(MarketDataArg arg) { } }
También puede obtener el volumen total de todas los bids y el volumen total de todos los asks utilizando las propiedades del objeto MarketDepthInfo: CumulativeDomAsks, CumulativeDomBids.
Un ejemplo de indicador, que muestra el historial de volúmenes totales de asks y bids.
public class DomPower : Indicator { private ValueDataSeries _asks; private ValueDataSeries _bids=new ValueDataSeries("Bids"); private int _lastCalculatedBar = 0; privte bool _first = true; public DomPower():base(true) { Panel = IndicatorDataProvider.NewPanel; _asks = (ValueDataSeries)DataSeries[0]; _asks.Name = "Asks"; _bids.Color = Colors.Green; DataSeries.Add(_bids); } protected override void OnCalculate(int bar, decimal value) { } protected override void MarketDepthChanged(MarketDataArg arg) { if (_first) { _first = false; _lastCalculatedBar = CurrentBar - 1; } var lastCandle = CurrentBar - 1; var cumAsks = MarketDepthInfo.CumulativeDomAsks; var cumBids = MarketDepthInfo.CumulativeDomBids; for (int i = _lastCalculatedBar; i <= lastCandle; i++) { _asks[i] = -cumAsks; _bids[i] = cumBids; } _lastCalculatedBar = lastCandle; } }
En algunos casos, puede que necesite obtener una porción de los datos de market depth. Para ello, puede utilizar la función MarketDepthInfo.GetMarketDepthSnapshot(). La función devuelve una lista de todos los niveles en el libro de órdenes.
Servicio de atención al cliente por UserEcho