private void DC_PropertyChanged(object sender, PropertyChangedEventArgs e) { Task.Run(() => { var DC = sender as ViewModel; switch (e.PropertyName) { case "BaseFontSize": BaseFontSize = DC.BaseFontSize; break; case "FontBrush": FontBrush = DC.FontBrush; break; case "TickSize": { TickSize = DC.TickSize; TickPriceFormat = TickSize.ToString().Replace('1', '0').Replace(',', '.'); Digits = TickPriceFormat.ToCharArray().Length - 2; } break; case "NewCandles": { if (DC.NewCandles != null && DC.NewCandles.Count > 0) { CandlesModule.NewCandles(DC.NewCandles); } } break; } }); }
protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"The Value Area is the price range where 70% of yesterdays volume traded. See Larry Levin www.secretsoftraders.com/ for more info"; Name = "CalculateValueArea"; Calculate = Calculate.OnBarClose; IsOverlay = true; DisplayInDataBox = true; DrawOnPricePanel = true; DrawHorizontalGridLines = true; DrawVerticalGridLines = true; PaintPriceMarkers = true; ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right; //Disable this property if your indicator requires custom values that cumulate with each new market data event. //See Help Guide for additional information. IsSuspendedWhileInactive = true; InclWeekendVol = false; ProfileType = @"VWTPO"; PctOfVolumeInVA = 0.7; OpenHour = 8; OpenMinute = 30; SessionLengthInHours = 6.75; AddPlot(new Stroke(Brushes.Yellow, 1), PlotStyle.Dot, "VAt"); AddPlot(new Stroke(Brushes.Pink, 1), PlotStyle.Dot, "VAb"); AddPlot(new Stroke(Brushes.Green, 1), PlotStyle.Line, "POC"); } else if (State == State.DataLoaded) { if (TickSize.ToString().Length <= 2) { FormatString = "0"; } if (TickSize.ToString().Length == 3) { FormatString = "0.0"; } if (TickSize.ToString().Length == 4) { FormatString = "0.00"; } if (TickSize.ToString().Length == 5) { FormatString = "0.000"; } if (TickSize.ToString().Length == 6) { FormatString = "0.0000"; } } }
protected override void OnStartUp() { if (TickSize.ToString().Length <= 2) { FormatString = "0"; } if (TickSize.ToString().Length == 3) { FormatString = "0.0"; } if (TickSize.ToString().Length == 4) { FormatString = "0.00"; } if (TickSize.ToString().Length == 5) { FormatString = "0.000"; } if (TickSize.ToString().Length == 6) { FormatString = "0.0000"; } }
protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Indicator here."; Name = "SqaureOfNine"; Calculate = Calculate.OnBarClose; IsOverlay = true; DisplayInDataBox = true; DrawOnPricePanel = true; DrawHorizontalGridLines = true; DrawVerticalGridLines = true; PaintPriceMarkers = true; ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right; //Disable this property if your indicator requires custom values that cumulate with each new market data event. //See Help Guide for additional information. IsSuspendedWhileInactive = true; MultiplierForPriceScale = 1; InitialPrice = 1; pOrT = PriceOrTime.Price; DisplayCountDown = true; //NT7, when you set the Date, it will default to midnight, while NT8 will reflect that date plus the current time.. //Thus, the NT7 version of this indicator will have its time plots drawn slightly off from the NT8 one. //The line below forces the time associated with the date entered, to midnight. Using this to conform to NT7 figures. //Might be best to be able to specify a time as well as date. ZuluTime = DateTime.Now.AddMinutes(-DateTime.Now.Minute).AddHours(-DateTime.Now.Hour).AddSeconds(-DateTime.Now.Second); Angle000Flag = true; Angle090Flag = true; Angle180Flag = true; Angle270Flag = true; xColor0x = xColor0.Red; xColor90x = xColor90.Blue; xColor180x = xColor180.Lime; xColor270x = xColor270.Purple; NumberOfLines = 10; } else if (State == State.Configure) { ZuluBar = -1; ; } else if (State == State.DataLoaded) { PriceDigits = Math.Max(0, TickSize.ToString().Length - 2); #region xColor0xSwitch switch (xColor0x) { case xColor0.Blue: { Color0 = (SolidColorBrush)Brushes.Blue; break; } case xColor0.Red: { Color0 = (SolidColorBrush)Brushes.Red; break; } case xColor0.Yellow: { Color0 = (SolidColorBrush)Brushes.Yellow; break; } case xColor0.Lime: { Color0 = (SolidColorBrush)Brushes.Lime; break; } case xColor0.Orange: { Color0 = (SolidColorBrush)Brushes.Orange; break; } case xColor0.Purple: { Color0 = (SolidColorBrush)Brushes.Purple; break; } case xColor0.Gray: { Color0 = (SolidColorBrush)Brushes.Gray; break; } } #endregion #region xColor90xSwitch switch (xColor90x) { case xColor90.Blue: { Color90 = (SolidColorBrush)Brushes.Blue; break; } case xColor90.Red: { Color90 = (SolidColorBrush)Brushes.Red; break; } case xColor90.Yellow: { Print("Picked Yellow"); Color90 = (SolidColorBrush)Brushes.Yellow; break; } case xColor90.Lime: { Color90 = (SolidColorBrush)Brushes.Lime; break; } case xColor90.Orange: { Color90 = (SolidColorBrush)Brushes.Orange; break; } case xColor90.Purple: { Color90 = (SolidColorBrush)Brushes.Purple; break; } case xColor90.Gray: { Color90 = (SolidColorBrush)Brushes.Gray; break; } } #endregion #region xColor180xSwitch switch (xColor180x) { case xColor180.Blue: { Color180 = (SolidColorBrush)Brushes.Blue; break; } case xColor180.Red: { Color180 = (SolidColorBrush)Brushes.Red; break; } case xColor180.Yellow: { Color180 = (SolidColorBrush)Brushes.Yellow; break; } case xColor180.Lime: { Color180 = (SolidColorBrush)Brushes.Lime; break; } case xColor180.Orange: { Color180 = (SolidColorBrush)Brushes.Orange; break; } case xColor180.Purple: { Color180 = (SolidColorBrush)Brushes.Purple; break; } case xColor180.Gray: { Color180 = (SolidColorBrush)Brushes.Gray; break; } } #endregion #region xColor270xSwitch switch (xColor270x) { case xColor270.Blue: { Color270 = (SolidColorBrush)Brushes.Blue; break; } case xColor270.Red: { Color270 = (SolidColorBrush)Brushes.Red; break; } case xColor270.Yellow: { Color270 = (SolidColorBrush)Brushes.Yellow; break; } case xColor270.Lime: { Color270 = (SolidColorBrush)Brushes.Lime; break; } case xColor270.Orange: { Color270 = (SolidColorBrush)Brushes.Orange; break; } case xColor270.Purple: { Color270 = (SolidColorBrush)Brushes.Purple; break; } case xColor270.Gray: { Color270 = (SolidColorBrush)Brushes.Gray; break; } } #endregion } }
protected override void OnStartUp() { if (ChartControl == null) { return; } if (m1 == null) { m1 = new ToolStripMenuItem("Start from here"); } if (m2 == null) { m2 = new ToolStripMenuItem("Finish here"); } if (mSeparator == null) { mSeparator = new ToolStripSeparator(); } m1.Name = "Start from here"; m2.Name = "Finish here"; m1.Click += OnStartMenu; m2.Click += OnFinishMenu; mSeparator.Name = "MySeparatorName"; ChartControl.ChartPanel.MouseDown += OnMouseClick; if (!ChartControl.ContextMenuStrip.Items.ContainsKey("MySeparatorName")) { ChartControl.ContextMenuStrip.Items.Insert(0, mSeparator); } if (!ChartControl.ContextMenuStrip.Items.ContainsKey("Finish here")) { ChartControl.ContextMenuStrip.Items.Insert(0, m2); } if (!ChartControl.ContextMenuStrip.Items.ContainsKey("Start from here")) { ChartControl.ContextMenuStrip.Items.Insert(0, m1); } for (int i = 0; i < Plots.Length; i++) { pens[i] = Plots[i].Pen; if (showlabels) { brushes[i] = new SolidBrush(Plots[i].Pen.Color); } } prices = new [] { price1, price2, price3, price4, price5, price6, price7, price8, price9, price10, price11, price12, price13, price14, price15, price16, price17, price18, price19, price20 }; Levels = new double[20]; if (TickSize.ToString("0.#########").Length <= 2) { fs = "0"; } else { switch (TickSize.ToString("0.#########").Length) { case 3: fs = "0.0"; break; case 4: fs = "0.00"; break; case 5: fs = "0.000"; break; case 6: fs = "0.0000"; break; case 7: fs = "0.00000"; break; default: fs = "0.000000"; break; } } }
/// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { int j; String beginMessage = Instrument.FullName + " - Ray Line Price Triggered on "; // Determine the Period Value switch (BarsPeriod.Id) { case PeriodType.Minute: beginMessage += BarsPeriod.Value + "M Timeframe @ "; break; case PeriodType.Day: beginMessage += BarsPeriod.Value + "D Timeframe @ "; break; case PeriodType.Week: beginMessage += BarsPeriod.Value + "W Timeframe @ "; break; case PeriodType.Month: beginMessage += BarsPeriod.Value + "MO Timeframe @ "; break; case PeriodType.Year: beginMessage += BarsPeriod.Value + "Y Timeframe @ "; break; case PeriodType.Tick: beginMessage += BarsPeriod.Value + "Tick Bar @ "; break; case PeriodType.Range: beginMessage += BarsPeriod.Value + "Range Bar @ "; break; case PeriodType.Volume: beginMessage += BarsPeriod.Value + "Volume Bar @ "; break; } // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. if (!_init) { _init = true; int Digits = 0; if (TickSize.ToString().StartsWith("1E-")) { Digits = Convert.ToInt32(TickSize.ToString().Substring(3)); } else if (TickSize.ToString().IndexOf(".") > 0) { Digits = TickSize.ToString().Substring(TickSize.ToString().IndexOf("."), TickSize.ToString().Length - 1).Length - 1; } _priceFormat = string.Format("F{0}", Digits); // Build a larger font size largerFont = new Font(ChartControl.Font.Name, fontSize, FontStyle.Bold); } // Check to see if Alerts are enabled if (enableAlert) { // Step through each one of the lines for (j = 0; j < lineInfoArray.Count; j++) { LineInfo lineInfo = (LineInfo)lineInfoArray[j]; if (Historical || lineInfo.lineTriggered) { continue; } if ((lineInfo.lineGreaterThan && Input[0] >= lineInfo.linePrice - (TickSize * 0.5)) || (!lineInfo.lineGreaterThan && Input[0] <= lineInfo.linePrice + (TickSize * 0.5))) { lineInfo.lineTriggered = true; Alert(DateTime.Now.Millisecond.ToString(), NinjaTrader.Cbi.Priority.Medium, beginMessage + lineInfo.linePrice.ToString(_priceFormat), Cbi.Core.InstallDir + @"\sounds\" + alertFileName, 0, Color.Yellow, Color.Black); lineInfoArray[j] = lineInfo; } } } }