using System; using System.Drawing; using System.ComponentModel; using System.Runtime.InteropServices; using System.Xml.Serialization; using NinjaTrader.Data; using NinjaTrader.Cbi; using NinjaTrader.Gui.Chart; namespace NinjaTrader.Indicator { public class i14m16s:Indicator { private int _lastBar, otobr, drawCount = 0; private readonly TickProcSm09 _tickProcessor = new TickProcSm09 (); //public DataSeries BidPrice, AskPrice, TickPrice, TickVolume; //public DataSeries TradeAskBid; public i14m16s () { Period = 100; Step = 10; } protected override void Initialize () { DrawOnPricePanel = false; Add (new Plot (new Pen (Color.Green, 1), PlotStyle.Bar, "Предложения Bid")); // BidVolume = 0 Add (new Plot (new Pen (Color.Red, 1), PlotStyle.Bar, "Предложения Ask")); // AskVolume = 1 Add (new Plot (new Pen (Color.Blue, 1), PlotStyle.Line, "Уровень")); // Supply = 2 Add (new Plot (new Pen (Color.Transparent, 1), PlotStyle.Dot, "Остаток Bid")); // RemainingBid = 3 Add (new Plot (new Pen (Color.Transparent, 1), PlotStyle.Dot, "Остаток Ask")); // RemainingAsk = 4 Add (new Plot (new Pen (Color.Transparent, 2), PlotStyle.Dot, "Разница старая Bid")); // RestBid = 5 Add (new Plot (new Pen (Color.Transparent, 2), PlotStyle.Dot, "Разница старая Ask")); // RestAsk = 6 Add (new Plot (new Pen (Color.Black, 2), PlotStyle.Dot, "Номер тика")); // TickNumber - Номер тика в трейде MDTN = 7 Add (new Plot (new Pen (Color.Orange, 2), PlotStyle.Dot, "Снос")); // TradeSnos - Снос трейда MDTS = 8 Add (new Plot (new Pen (Color.Blue, 2), PlotStyle.Dot, "Объем")); // TradeVolume - Объем трейда MDTV = 9 Add (new Plot (new Pen (Color.Transparent, 1), PlotStyle.Dot, "Трейд")); // Trade MDT = 10 Add (new Plot (new Pen (Color.Lime, 2), PlotStyle.Dot, "ТрейдАскБидПред")); // PrevTradeAskBid = 11 Add (new Plot (new Pen (Color.Transparent, 1), PlotStyle.Dot, "Тиковый объем")); // TickVolume = 12 Add (new Plot (new Pen (Color.Transparent, 1), PlotStyle.Dot, "ТрейдАскБид")); // TradeAskBid = 13 Add (new Plot (new Pen (Color.Transparent, 1), PlotStyle.Dot, "Тиковый объемПред")); // PrevTickVolume = 14 Add (new Plot (new Pen (Color.Transparent, 2), PlotStyle.Dot, "РазницаПред Bid")); // PrevRestBid = 15 Add (new Plot (new Pen (Color.Transparent, 2), PlotStyle.Dot, "РазницаПред Ask")); // PrevRestAsk = 16 Add (new Plot (new Pen (Color.Transparent, 1), PlotStyle.Dot, "Остаток_S Bid")); // RB = 17 Add (new Plot (new Pen (Color.Transparent, 1), PlotStyle.Dot, "Остаток_S Ask")); // RA = 18 Add (new Plot (new Pen (Color.Transparent, 2), PlotStyle.Dot, "Разница Bid")); // bD = 19 Add (new Plot (new Pen (Color.Transparent, 2), PlotStyle.Dot, "Разница Ask")); // aD = 20 Add (new Plot (new Pen (Color.Cyan, 3), PlotStyle.Dot, "Айс Bid")); // bDR = 21 Add (new Plot (new Pen (Color.Magenta, 3), PlotStyle.Dot, "Айс Ask")); // aDR = 22 //Add (new Plot (new Pen (Color.Magenta, 2), PlotStyle.Dot, "ТрейдНовый")); // TradeN = 11 //Add (new Plot (new Pen (Color.Green, 1), PlotStyle.Bar, "Цена Bid")); // BidPrice //Add (new Plot (new Pen (Color.Red, 1), PlotStyle.Bar, "Цена Ask")); // AskPrice CalculateOnBarClose = false; _tickProcessor.Print = this.Print; _tickProcessor.InstrumentName = Instrument.FullName; //TradeAskBid = new DataSeries (this); /*BidPrice = new DataSeries (this); AskPrice = new DataSeries (this); TickPrice = new DataSeries (this); TickVolume = new DataSeries (this);*/ //Add(PeriodType.Tick, 1); //? } protected override void OnTermination () { if (_tickProcessor != null) _tickProcessor.Dispose (); } protected override void OnBarUpdate () { drawCount++; if (drawCount <= 1) return; /*long Rem10 = 0, Rem5 = 0; Math.DivRem(CurrentBar, 10, out Rem10); Math.DivRem (CurrentBar, 5, out Rem5); if (Rem10 == 0) { DrawText ("DT" + drawCount.ToString (), true, CurrentBar.ToString (), 0, -4, 0, Color.Black, new Font (FontFamily.GenericSansSerif, 8.0F, FontStyle.Bold), StringAlignment.Far, Color.Transparent, Color.White, 0); DrawDiamond ("DD" + drawCount.ToString (), true, 0, -4, Color.Orange); } else if (Rem5 == 0) { DrawDiamond ("DD" + drawCount.ToString (), true, 0, -4, Color.Orange); }*/ if (Historical) { _tickProcessor.NextHistoricalBar (Time[1]); // Time[0] - необходимо для соответствия графиков от реала и по F5 UpdatePreviousDataSeries (); //string PrUp = TickVolume[2].ToString (); // Ask TickNumber TickVolume TradeSnos TradeVolume RestAsk /*DrawText ("HA1 " + drawCount.ToString (), true, PrUp, //.Substring (4, 1), _tickProcessor.AskVolume 1, 1.00009 * Close[1], 0, Color.Black, new Font (FontFamily.GenericSansSerif, 8.0F, FontStyle.Bold), StringAlignment.Center, Color.Transparent, Color.White, 0);*/ _tickProcessor.NextBar (); UpdateDataSeries (); //UpdateSupply (); /*if ((TradeVolume[0] >= 2) && (TradeSnos[0] != 0)) Print ("14-11 H T=" + Time[0] + " CB=" + CurrentBar + //" TP=" + TickPrice[0] + " TV=" + TickVolume[0] + " V=" + Volume[0] + " TN=" + TickNumber[0] + " TRV=" + TradeVolume[0] + " SN=" + TradeSnos[0] + " TR=" + Trade[0]); // + " BIP=" + BarsInProgress);*/ //string PrLow = TickVolume[1].ToString (); /*DrawText ("HA " + drawCount.ToString (), true, PrLow.ToString (), //.Substring (4, 1), _tickProcessor.AskVolume 1, 1.00004 * Close[1], 0, Color.Black, new Font (FontFamily.GenericSansSerif, 8.0F, FontStyle.Bold), StringAlignment.Center, Color.Transparent, Color.White, 0);*/ /*DrawText ("HB " + drawCount.ToString (), true, Bid[1].ToString (), //.Substring (4, 1), _tickProcessor.BidVolume 1, 1.00004 * Close[1], 0, Color.Black, new Font (FontFamily.GenericSansSerif, 8.0F, FontStyle.Bold), StringAlignment.Center, Color.Transparent, Color.White, 0);*/ /*DrawText ("TRV " + drawCount.ToString (), true, TradeVolume[sdv].ToString (), //.Substring (4, 1), 0, 1.00011 * Close[0], 0, Color.Black, new Font (FontFamily.GenericSansSerif, 8.0F, FontStyle.Bold), StringAlignment.Center, Color.Transparent, Color.White, 0); DrawText ("TN " + drawCount.ToString (), true, TickNumber[sdv].ToString (), //.Substring (4, 1), 0, 1.00007 * Close[0], 0, Color.Black, new Font (FontFamily.GenericSansSerif, 8.0F, FontStyle.Bold), StringAlignment.Center, Color.Transparent, Color.White, 0); DrawText ("TS " + drawCount.ToString (), true, TradeSnos[sdv].ToString (), //.Substring (4, 1), 0, 0.99997 * Close[0], 0, Color.Black, new Font (FontFamily.GenericSansSerif, 8.0F, FontStyle.Bold), StringAlignment.Center, Color.Transparent, Color.White, 0); DrawText ("T " + drawCount.ToString (), true, Trade[sdv].ToString (), //.Substring (4, 1), 0, 0.99993 * Close[0], 0, Color.Black, new Font (FontFamily.GenericSansSerif, 8.0F, FontStyle.Bold), StringAlignment.Center, Color.Transparent, Color.White, 0);*/ /*DrawText ("TV " + drawCount.ToString (), true, TickVolume[sdv].ToString (), //.Substring (4, 1), 0, 0.99997 * Close[0], 0, Color.Black, new Font (FontFamily.GenericSansSerif, 8.0F, FontStyle.Bold), StringAlignment.Center, Color.Transparent, Color.White, 0);*/ /* if (RestAsk[1] != 0) DrawText ("TRA1 " + drawCount.ToString (), true, RestAsk[1].ToString (), //.Substring (4, 1), 0, 1.00003 * Close[0], 0, Color.Black, new Font (FontFamily.GenericSansSerif, 8.0F, FontStyle.Bold), StringAlignment.Center, Color.Transparent, Color.White, 0); if (RestAsk[2] != 0) DrawText ("TRA2 " + drawCount.ToString (), true, RestAsk[2].ToString (), //.Substring (4, 1), 0, 1.00007 * Close[0], 0, Color.Black, new Font (FontFamily.GenericSansSerif, 8.0F, FontStyle.Bold), StringAlignment.Center, Color.Transparent, Color.White, 0); if (RestAsk[3] != 0) DrawText ("TRA3 " + drawCount.ToString (), true, RestAsk[3].ToString (), //.Substring (4, 1), 0, 1.00011 * Close[0], 0, Color.Black, new Font (FontFamily.GenericSansSerif, 8.0F, FontStyle.Bold), StringAlignment.Center, Color.Transparent, Color.White, 0); if (RestBid[1] != 0) DrawText ("TRB1 " + drawCount.ToString (), true, RestBid[1].ToString (), //.Substring (4, 1), 0, 0.99997 * Close[0], 0, Color.Black, new Font (FontFamily.GenericSansSerif, 8.0F, FontStyle.Bold), StringAlignment.Center, Color.Transparent, Color.White, 0); if (RestBid[2] != 0) DrawText ("TRB2 " + drawCount.ToString (), true, RestBid[2].ToString (), //.Substring (4, 1), 0, 0.99993 * Close[0], 0, Color.Black, new Font (FontFamily.GenericSansSerif, 8.0F, FontStyle.Bold), StringAlignment.Center, Color.Transparent, Color.White, 0); if (RestBid[3] != 0) DrawText ("TRB3 " + drawCount.ToString (), true, RestBid[3].ToString (), //.Substring (4, 1), 0, 0.99989 * Close[0], 0, Color.Black, new Font (FontFamily.GenericSansSerif, 8.0F, FontStyle.Bold), StringAlignment.Center, Color.Transparent, Color.White, 0); */ return; } if (_lastBar != CurrentBar) { _lastBar = CurrentBar; _tickProcessor.NextBar (); UpdateDataSeries (); //UpdateSupply (); /*if ((TradeVolume[0] >= 2) && (TradeSnos[0] != 0)) Print ("14-11 R T=" + Time[0] + " CB=" + CurrentBar + //" TP=" + TickPrice[0] + " TV=" + TickVolume[0] + " V=" + Volume[0] + " TN=" + TickNumber[0] + " TRV=" + TradeVolume[0] + " SN=" + TradeSnos[0] + " TR=" + Trade[0]); // + " BIP=" + BarsInProgress);*/ //string PrUp = Ask[2].ToString (); //string PrLow = Ask[1].ToString (); /*DrawText ("RA1 " + drawCount.ToString (), true, PrUp, //.Substring (4, 1), _tickProcessor.AskVolume 1, 1.00009 * Close[1], 0, Color.Black, new Font (FontFamily.GenericSansSerif, 8.0F, FontStyle.Bold), StringAlignment.Center, Color.Transparent, Color.White, 0); DrawText ("RA " + drawCount.ToString (), true, PrLow, //.Substring (4, 1), _tickProcessor.AskVolume 1, 1.00004 * Close[1], 0, Color.Black, new Font (FontFamily.GenericSansSerif, 8.0F, FontStyle.Bold), StringAlignment.Center, Color.Transparent, Color.White, 0);*/ /*DrawText ("RB " + drawCount.ToString (), true, Bid[1].ToString (), //.Substring (4, 1), _tickProcessor.BidVolume 1, 1.00004 * Close[1], 0, Color.Black, new Font (FontFamily.GenericSansSerif, 8.0F, FontStyle.Bold), StringAlignment.Center, Color.Transparent, Color.White, 0);*/ /*DrawText ("TV " + drawCount.ToString (), true, TickVolume[sdv].ToString (), //.Substring (4, 1), 0, 0.99997 * Close[0], 0, Color.Black, new Font (FontFamily.GenericSansSerif, 8.0F, FontStyle.Bold), StringAlignment.Center, Color.Transparent, Color.White, 0);*/ /*DrawText ("TRA1 " + drawCount.ToString (), true, RestAsk[1].ToString (), //.Substring (4, 1), 0, 1.00003 * Close[0], 0, Color.Black, new Font (FontFamily.GenericSansSerif, 8.0F, FontStyle.Bold), StringAlignment.Center, Color.Transparent, Color.White, 0); DrawText ("TRA2 " + drawCount.ToString (), true, RestAsk[2].ToString (), //.Substring (4, 1), 0, 1.00007 * Close[0], 0, Color.Black, new Font (FontFamily.GenericSansSerif, 8.0F, FontStyle.Bold), StringAlignment.Center, Color.Transparent, Color.White, 0); DrawText ("TRB1 " + drawCount.ToString (), true, RestBid[1].ToString (), //.Substring (4, 1), 0, 0.99997 * Close[0], 0, Color.Black, new Font (FontFamily.GenericSansSerif, 8.0F, FontStyle.Bold), StringAlignment.Center, Color.Transparent, Color.White, 0); DrawText ("TRB2 " + drawCount.ToString (), true, RestBid[2].ToString (), //.Substring (4, 1), 0, 0.99993 * Close[0], 0, Color.Black, new Font (FontFamily.GenericSansSerif, 8.0F, FontStyle.Bold), StringAlignment.Center, Color.Transparent, Color.White, 0);*/ } } protected override void OnMarketData ( MarketDataEventArgs e ) { // Print(string.Format("{0}: {1} {2} {3}", e.Time, e.MarketDataType, e.Price, e.Volume)); _tickProcessor.MarketData (e.Time, (TickProcSm09.MarketDataType) e.MarketDataType, e.Price, e.Volume); UpdateDataSeries (); //ChartControl.ChartPanel.Invalidate (); } protected override void OnMarketDepth ( MarketDepthEventArgs e ) { // Print(string.Format("{0} {1} {2} {3} {4} {5}", e.Time, e.MarketDataType, e.Operation, // e.Position, e.Price, e.Volume)); if (!_tickProcessor.IsMarketDepthInitialized) { for (int i = 0; i < e.MarketDepth.Ask.Count; i++) { _tickProcessor.MarketDepth (e.Time, (TickProcSm09.MarketDataType) MarketDataType.Ask, (TickProcSm09.Operation) Operation.Insert, i, e.MarketDepth.Ask[i].Price, e.MarketDepth.Ask[i].Volume); } for (int i = 0; i < e.MarketDepth.Bid.Count; i++) { _tickProcessor.MarketDepth (e.Time, (TickProcSm09.MarketDataType) MarketDataType.Bid, (TickProcSm09.Operation) Operation.Insert, i, e.MarketDepth.Bid[i].Price, e.MarketDepth.Bid[i].Volume); } } _tickProcessor.MarketDepth (e.Time, (TickProcSm09.MarketDataType) e.MarketDataType, (TickProcSm09.Operation) e.Operation, e.Position, e.Price, e.Volume); // for (int i = e.MarketDepth.Ask.Count - 1; i >= 0; i--) { // Print(string.Format("Ask {0} {1}", e.MarketDepth.Ask[i].Price, e.MarketDepth.Ask[i].Volume)); // } // for (int i = 0; i < e.MarketDepth.Bid.Count; i++) { // Print(string.Format("Bid {0} {1}", e.MarketDepth.Bid[i].Price, e.MarketDepth.Bid[i].Volume)); // } } private void UpdateDataSeries () { //Print("i25m01s UpdateDataSeries" + (ii).ToString()); Bid.Set (_tickProcessor.BidVolume); Ask.Set (_tickProcessor.AskVolume); /*BidPrice.Set (_tickProcessor.BidPrice); AskPrice.Set (_tickProcessor.AskPrice); TickPrice.Set (_tickProcessor.TickPrice);*/ //double Vol1 = Math.Max (_tickProcessor.BidVolume, _tickProcessor.AskVolume); TradeAskBid.Set (_tickProcessor.TradeAskBid); PrevTradeAskBid.Set (_tickProcessor.PrevTradeAskBid); TradeVolume.Set (_tickProcessor.TradeVolume); TickVolume.Set (_tickProcessor.TickVolume); //if (TradeVolume[0] >= 2) // Print ("14-7 TV=" + TradeVolume[0] + " TPTV=" + _tickProcessor.TradeVolume); RemainingBid.Set (_tickProcessor.ComulatedRemainingBidVolume); RemainingAsk.Set (_tickProcessor.ComulatedRemainingAskVolume); RB.Set (_tickProcessor.CRBV); RA.Set (_tickProcessor.CRAV); bD.Set (_tickProcessor.bD); aD.Set (_tickProcessor.aD); bDR.Set (_tickProcessor.bDR); aDR.Set (_tickProcessor.aDR); //if ((RemainingBid[0] > 40) || (RemainingAsk[0] > 40)) // Print ("14-12 RemB=" + RemainingBid[0] + " RemA=" + RemainingAsk[0]); //RestBidVolume.Set (_tickProcessor.RestBidVolume); //RestAskVolume.Set (_tickProcessor.RestAskVolume); RestBid.Set (_tickProcessor.ComulatedRemainingBidVolume - _tickProcessor.BidVolume); RestAsk.Set (_tickProcessor.ComulatedRemainingAskVolume - _tickProcessor.AskVolume); //if ((RestBid[0] > 40) || (RestAsk[0] > 40)) // Print ("14-12 RB=" + RestBid[0] + " RA=" + RestAsk[0]); //Print ("14-7 UDS time=" + Time[0] + " RB0=" + RestBid[0]); //Print ("14-7 UDS time=" + Time[0] + " RA0=" + RestAsk[0]); int sdv = 0; if (TickNumber[sdv] == Close[sdv]) TickNumber[sdv] = 0; if (TradeSnos[sdv] == Close[sdv]) TradeSnos[sdv] = 0; if (Trade[sdv] == Close[sdv]) Trade[sdv] = 0; if (aDR[sdv] == Close[sdv]) aDR[sdv] = 0; if (bDR[sdv] == Close[sdv]) bDR[sdv] = 0; //if (TradeN[sdv] == Close[sdv]) TradeN[sdv] = 0; if (_tickProcessor.TradeSnos != 0) { TradeSnos.Set (Math.Round (_tickProcessor.TradeSnos / TickSize, 0)); //TradeSnos.Set (Math.Round (_tickProcessor.TradeSnos * 100, 0)); } if ((_tickProcessor.TickNumber == 0) || (_tickProcessor.TickNumber == 1)) { TickNumber.Set (0); Trade.Set (0); TradeVolume.Set (0); //TradeN.Set (0); if (TickNumber[1] == 0) { aD.Set (1, 0); bD.Set (1, 0); aDR.Set (1, 0); bDR.Set (1, 0); } } if (_tickProcessor.TickNumber == 2) { TickNumber.Set (1, 1); Trade.Set (1, 1); //bD.Set (1, _tickProcessor.PbD); //aD.Set (1, _tickProcessor.PaD); } if (_tickProcessor.TickNumber >= 2) { TickNumber.Set (_tickProcessor.TickNumber); Trade.Set (1); Trade.Set (1, 0); //TradeN.Set (1); //TradeN.Set (1, 0); } //if((BegNumber[1] == 1) && (BegNumber[0] == 1)) // BegNumber[1] = 0; //if ((RemainingBid[0] > 1.2F*Bid[0]) || (RemainingAsk[0] > 1.2F*Ask[0])) // Print("14 RBid=" + RemainingBid[0] + " Bid=" + Bid[0] + " RAsk=" + RemainingAsk[0] + " Ask=" + Ask[0]); //if (RemainingBid[0] > Bid[0]) // Print("RBid " + RemainingBid[0].ToString() + " " + Bid[0].ToString()); //if (RemainingAsk[0] > Ask[0]) // Print("RAsk " + RemainingAsk[0].ToString() + " " + Ask[0].ToString()); if (RemainingBid.Count > 1) { RemainingBid[1] = _tickProcessor.PreviousComulatedRemainingBidVolume; PrevRestBid.Set (RemainingBid[1]); } if (RB.Count > 1) { RB[1] = _tickProcessor.PCRBV; } /*if (bD.Count > 1) { bD[1] = _tickProcessor.PbD; }*/ //if (RestBidVolume.Count > 1) // RestBidVolume[1] = _tickProcessor.RestBidVolume; if (RestBid.Count > 1) { RestBid[1] = _tickProcessor.PreviousComulatedRemainingBidVolume - Bid[1]; //PrevRestBid.Set (_tickProcessor.PreviousComulatedRemainingBidVolume - Bid[1]); } //Print ("14-7 UDS time=" + Time[0] + " RB1=" + RestBid[1]); if (RemainingAsk.Count > 1) { RemainingAsk[1] = _tickProcessor.PreviousComulatedRemainingAskVolume; PrevRestAsk.Set (RemainingAsk[1]); } if (RA.Count > 1) { RA[1] = _tickProcessor.PCRAV; } /*if (aD.Count > 1) { aD[1] = _tickProcessor.PaD; }*/ //if (RestAskVolume.Count > 1) // RestAskVolume[1] = _tickProcessor.RestAskVolume; if (RestAsk.Count > 1) { RestAsk[1] = _tickProcessor.PreviousComulatedRemainingAskVolume - Ask[1]; //PrevRestAsk.Set (_tickProcessor.PreviousComulatedRemainingAskVolume - Ask[1]); } //Print ("14-7 UDS time=" + Time[0] + " RA1=" + RestAsk[1]); //if ((RemainingBid[1] > 40) || (RemainingAsk[1] > 40)) // Print ("14-12 RemB1=" + RemainingBid[1] + " RemA1=" + RemainingAsk[1]); //if ((PrevRestBid[0] > 40) || (PrevRestAsk[0] > 40)) //Print ("14-12 RB1P=" + PrevRestBid[0] + " RA1P=" + PrevRestAsk[0]); //if ((PrevRestBid[0] > 200) || (PrevRestAsk[0] > 200)) // Print ("14-12 UDS time=" + Time[0] + " PRB1P=" + PrevRestBid[0] + " PRA1P=" + PrevRestAsk[0]); } private void UpdatePreviousDataSeries () { if (Bid.Count > 1) { Bid[1] = _tickProcessor.BidVolume; //BidPrice[1] = _tickProcessor.BidPrice; //TickPrice[1] = _tickProcessor.TickPrice; } if (Ask.Count > 1) { Ask[1] = _tickProcessor.AskVolume; //AskPrice[1] = _tickProcessor.AskPrice; //TickPrice[1] = _tickProcessor.TickPrice; } /*if (TickVolume.Count > 1) { TickVolume[1] = _tickProcessor.TickVolume; } if (PrevTickVolume.Count > 1) { PrevTickVolume[1] = _tickProcessor.PrevTickVolume; }*/ /*if (TradeVolume.Count > 1) { TradeVolume[1] = _tickProcessor.TradeVolume; // --- }*/ /*if (TradeAskBid.Count > 1) { TradeAskBid[1] = _tickProcessor.TradeAskBid; } if (TradeSnos.Count > 1) { TradeSnos[1] = Math.Round (_tickProcessor.TradeSnos * 100, 0); } if (TickNumber.Count > 1) { if (_tickProcessor.TickNumber == 0) { TickNumber[1] = 0; if (Trade.Count > 1) Trade[1] = 0; //TradeN.Set (0); } if (_tickProcessor.TickNumber == 2) { if (TickNumber.Count > 2) TickNumber[2] = 1; // 1 if (Trade.Count > 2) Trade[2] = 1; } if (_tickProcessor.TickNumber >= 2) { TickNumber[1] = _tickProcessor.TickNumber; if (Trade.Count > 1) Trade[1] = 1; if (Trade.Count > 2) Trade[2] = 0; //TradeN.Set (1); //TradeN.Set (1, 0); } }*/ if (RemainingBid.Count > 1) { RemainingBid[1] = _tickProcessor.ComulatedRemainingBidVolume; PrevRestBid.Set (RemainingBid[1]); } if (RB.Count > 1) { RB[1] = _tickProcessor.CRBV; } /*if (bD.Count > 1) { bD[1] = _tickProcessor.bD; }*/ //if (RestBidVolume.Count > 1) // RestBidVolume[1] = _tickProcessor.RestBidVolume; if (RestBid.Count > 1) { RestBid[1] = _tickProcessor.ComulatedRemainingBidVolume - _tickProcessor.BidVolume; //PrevRestBid.Set (_tickProcessor.ComulatedRemainingBidVolume - _tickProcessor.BidVolume); } //Print ("14-7 UPDS RB1=" + RestBid[1]); if (RemainingAsk.Count > 1) { RemainingAsk[1] = _tickProcessor.ComulatedRemainingAskVolume; PrevRestAsk.Set (RemainingAsk[1]); } if (RA.Count > 1) { RA[1] = _tickProcessor.CRAV; } /*if (aD.Count > 1) { aD[1] = _tickProcessor.aD; }*/ //if (RestAskVolume.Count > 1) // RestAskVolume[1] = _tickProcessor.RestAskVolume; if (RestAsk.Count > 1) { RestAsk[1] = _tickProcessor.ComulatedRemainingAskVolume - _tickProcessor.AskVolume; //PrevRestAsk.Set (_tickProcessor.ComulatedRemainingAskVolume - _tickProcessor.AskVolume); } //Print ("14-7 UPDS RA1=" + RestAsk[1]); //if ((RemainingBid[1] > 40) || (RemainingAsk[1] > 40)) // Print ("14-12 RemB1P=" + RemainingBid[1] + " RemA1P=" + RemainingAsk[1]); if (RemainingBid.Count > 2) { RemainingBid[2] = _tickProcessor.PreviousComulatedRemainingBidVolume; PrevRestBid[1] = RemainingBid[2]; //if ((RemainingBid[2] > 40) || (RemainingAsk[2] > 40)) // Print ("14-12 RemB2P=" + RemainingBid[2] + " RemA2P=" + RemainingAsk[2]); } if (RB.Count > 2) { RB[2] = _tickProcessor.PCRBV; //if ((RemainingBid[2] > 40) || (RemainingAsk[2] > 40)) // Print ("14-12 RemB2P=" + RemainingBid[2] + " RemA2P=" + RemainingAsk[2]); } /*if (bD.Count > 2) { bD[2] = _tickProcessor.PbD; }*/ //if (RestBidVolume.Count > 2) // RestBidVolume[2] = _tickProcessor.RestBidVolume; if (RestBid.Count > 2) { //RestBid[2] = _tickProcessor.PreviousComulatedRemainingBidVolume - _tickProcessor.PrevBidVolume; ; RestBid[2] = _tickProcessor.PreviousComulatedRemainingBidVolume - Bid[2]; } //Print ("14-7 UPDS RB2=" + RestBid[2]); if (RemainingAsk.Count > 2) { RemainingAsk[2] = _tickProcessor.PreviousComulatedRemainingAskVolume; PrevRestAsk[1] = RemainingAsk[2]; //if ((RemainingBid[2] > 40) || (RemainingAsk[2] > 40)) // Print ("14-12 RemB2P=" + RemainingBid[2] + " RemA2P=" + RemainingAsk[2]); } if (RA.Count > 2) { RA[2] = _tickProcessor.PCRAV; //if ((RemainingBid[2] > 40) || (RemainingAsk[2] > 40)) // Print ("14-12 RemB2P=" + RemainingBid[2] + " RemA2P=" + RemainingAsk[2]); } /*if (aD.Count > 2) { aD[2] = _tickProcessor.PaD; }*/ //if (RestAskVolume.Count > 2) // RestAskVolume[2] = _tickProcessor.RestAskVolume; if (RestAsk.Count > 2) //RestAsk[2] = _tickProcessor.PreviousComulatedRemainingAskVolume - _tickProcessor.PrevAskVolume; RestAsk[2] = _tickProcessor.PreviousComulatedRemainingAskVolume - Ask[2]; //Print ("14-7 UPDS RA2=" + RestAsk[2]); //if ((PrevRestBid[0] > 200) || (PrevRestAsk[0] > 200)) // Print ("14-12 UPDS time=" + Time[0] + " PRB1P=" + PrevRestBid[0] + " PRA1P=" + PrevRestAsk[0]); } /*private void UpdateSupply () { double? supply = _tickProcessor.GetSupply (); if (supply.HasValue) Supply.Set (supply.Value); }*/ #region Properties [Browsable (false)] [XmlIgnore ()] public DataSeries Bid { get { return Values[0]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries Ask { get { return Values[1]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries Supply { get { return Values[2]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries RemainingBid { get { return Values[3]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries RemainingAsk { get { return Values[4]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries RestBid { get { return Values[5]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries RestAsk { get { return Values[6]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries TickNumber { get { return Values[7]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries TradeSnos { get { return Values[8]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries TradeVolume { get { return Values[9]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries Trade { get { return Values[10]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries PrevTradeAskBid { get { return Values[11]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries TickVolume { get { return Values[12]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries TradeAskBid { get { return Values[13]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries PrevTickVolume { get { return Values[14]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries PrevRestBid { get { return Values[15]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries PrevRestAsk { get { return Values[16]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries RB { get { return Values[17]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries RA { get { return Values[18]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries bD { get { return Values[19]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries aD { get { return Values[20]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries bDR { get { return Values[21]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries aDR { get { return Values[22]; } } [GridCategory ("Parameters")] [Gui.Design.DisplayNameAttribute ("Период")] [Description ("Период")] public int Period { get { return _tickProcessor.SupplyPeriod; } set { _tickProcessor.SupplyPeriod = Math.Max (1, value); } } [GridCategory ("Parameters")] [Gui.Design.DisplayNameAttribute ("Шаг")] [Description ("Шаг")] public int Step { get { return _tickProcessor.SupplyStep; } set { _tickProcessor.SupplyStep = Math.Max (1, value); } } #region Properties Not Use /*[Browsable (false)] [XmlIgnore ()] public DataSeries TradeN { get { return Values[11]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries RestBidVolume { get { return Values[12]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries RestAskVolume { get { return Values[13]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries BidPrice { get { return Values[12]; } } [Browsable (false)] [XmlIgnore ()] public DataSeries AskPrice { get { return Values[13]; } } [GridCategory ("Parameters")] [Gui.Design.DisplayNameAttribute ("Отображение заявок (1-да, 0-нет)")] [Description ("Отображения заявок модифицированное")] public int Otobr { get { return otobr; } set { otobr = Math.Max (0, value); } }*/ #endregion #endregion } } #region NinjaScript generated code. Neither change nor remove. // This namespace holds all indicators and is required. Do not change it. namespace NinjaTrader.Indicator { public partial class Indicator:IndicatorBase { private i14m16s[] cachei14m16s = null; private static i14m16s checki14m16s = new i14m16s (); /// /// Enter the description of your new custom indicator here /// /// public i14m16s i14m16s ( int period, int step ) { return i14m16s (Input, period, step); } /// /// Enter the description of your new custom indicator here /// /// public i14m16s i14m16s ( Data.IDataSeries input, int period, int step ) { if (cachei14m16s != null) for (int idx = 0; idx < cachei14m16s.Length; idx++) if (cachei14m16s[idx].Period == period && cachei14m16s[idx].Step == step && cachei14m16s[idx].EqualsInput (input)) return cachei14m16s[idx]; lock (checki14m16s) { checki14m16s.Period = period; period = checki14m16s.Period; checki14m16s.Step = step; step = checki14m16s.Step; if (cachei14m16s != null) for (int idx = 0; idx < cachei14m16s.Length; idx++) if (cachei14m16s[idx].Period == period && cachei14m16s[idx].Step == step && cachei14m16s[idx].EqualsInput (input)) return cachei14m16s[idx]; i14m16s indicator = new i14m16s (); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.Period = period; indicator.Step = step; Indicators.Add (indicator); indicator.SetUp (); i14m16s[] tmp = new i14m16s[cachei14m16s == null ? 1 : cachei14m16s.Length + 1]; if (cachei14m16s != null) cachei14m16s.CopyTo (tmp, 0); tmp[tmp.Length - 1] = indicator; cachei14m16s = tmp; return indicator; } } } } // This namespace holds all market analyzer column definitions and is required. Do not change it. namespace NinjaTrader.MarketAnalyzer { public partial class Column:ColumnBase { /// /// Enter the description of your new custom indicator here /// /// [Gui.Design.WizardCondition ("Indicator")] public Indicator.i14m16s i14m16s ( int period, int step ) { return _indicator.i14m16s (Input, period, step); } /// /// Enter the description of your new custom indicator here /// /// public Indicator.i14m16s i14m16s ( Data.IDataSeries input, int period, int step ) { return _indicator.i14m16s (input, period, step); } } } // This namespace holds all strategies and is required. Do not change it. namespace NinjaTrader.Strategy { public partial class Strategy:StrategyBase { /// /// Enter the description of your new custom indicator here /// /// [Gui.Design.WizardCondition ("Indicator")] public Indicator.i14m16s i14m16s ( int period, int step ) { return _indicator.i14m16s (Input, period, step); } /// /// Enter the description of your new custom indicator here /// /// public Indicator.i14m16s i14m16s ( Data.IDataSeries input, int period, int step ) { if (InInitialize && input == null) throw new ArgumentException ("You only can access an indicator with the default input/bar series from within the 'Initialize()' method"); return _indicator.i14m16s (input, period, step); } } } #endregion