In the script below I draw pivot highs in OR
protected override void OnRender(ChartControl chartControl, ChartScale chartScale) { base.OnRender(chartControl, chartScale); if (Bars == null || ChartControl == null) return; SharpDX.Direct2D1.SolidColorBrush textBrushDx = new SharpDX.Direct2D1.SolidColorBrush(RenderTarget, new SharpDX.Color(120, 123, 134, 255)); SharpDX.DirectWrite.TextFormat textFormat1 = new SharpDX.DirectWrite.TextFormat(NinjaTrader.Core.Globals.DirectWriteFactory, "Arial", FontWeight.Bold, FontStyle.Normal, (float)8); for(int barIndex = ChartBars.FromIndex; barIndex <= ChartBars.ToIndex; barIndex++) { //Pivot High if ((High.GetValueAt(barIndex - 1) >= High.GetValueAt(barIndex)) && (High.GetValueAt(barIndex - 1) > High.GetValueAt(barIndex - 2))) //swing high { int x1 = chartControl.GetXByBarIndex(ChartBars, barIndex - 1) - 8; int y1 = chartScale.GetYByValue(High.GetValueAt(barIndex - 1)) - 22; SharpDX.Vector2 TextPoint = new SharpDX.Vector2(x1, y1); SharpDX.DirectWrite.TextLayout textLayout1 = new SharpDX.DirectWrite.TextLayout(NinjaTrader.Core.Globals.DirectWriteFactory, "PH", textFormat1, 400, textFormat1.FontSize); RenderTarget.DrawTextLayout(TextPoint, textLayout1, textBrushDx, SharpDX.Direct2D1.DrawTextOptions.NoSnap); } } }
protected override void OnBarUpdate() { //Pivot High if ((High[1] >= High[0]) && (High[1] > High[2])) { int x1 = CurrentBar - 1; double y1 = High[1]; } }
Comment