Exemplo n.º 1
0
 protected override void OnStateChange()
 {
     if (State == State.SetDefaults)
     {
         Description             = @"Enter the description for your new custom Indicator here.";
         Name                    = "A Mission";
         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;
         TopMessage      = @"Success: rules, limits, control, humility  .";
         BottomMessage   = "Failure: following feelings, intuition, no loss limit, huberis   .";
         TextColor       = Brushes.Red;
         TopTextColor    = Brushes.DodgerBlue;
         BackGroundCOlor = Brushes.WhiteSmoke;
         NoteFont        = new SimpleFont("Arial", 14);
     }
     else if (State == State.Configure)
     {
         timer = new System.Timers.Timer();
     }
 }
 protected override void OnStateChange()
 {
     if (State == State.SetDefaults)
     {
         Description              = @"Enter the description for your new custom Indicator here.";
         Name                     = "A Text On Chart";
         Calculate                = Calculate.OnBarClose;
         IsOverlay                = true;
         DisplayInDataBox         = true;
         DrawOnPricePanel         = true;
         DrawHorizontalGridLines  = true;
         DrawVerticalGridLines    = true;
         PaintPriceMarkers        = true;
         ScaleJustification       = NinjaTrader.Gui.Chart.ScaleJustification.Right;
         IsSuspendedWhileInactive = true;
         Line1                    = @"one";
         Line2                    = @"two";
         Line3                    = @"three";
         Line4                    = @"four";
         Line5                    = @"fivee";
         Line6                    = @"six";
         Line7                    = @"seven";
         Line8                    = @"eight";
         BackgroundOpacity        = 70;
         NoteLocation             = TextPosition.TopLeft;
         BackgroundColor          = Brushes.RoyalBlue;
         FontColor                = Brushes.White;
         OutlineColor             = Brushes.DimGray;
         NoteFont                 = new SimpleFont("Arial", 10);
     }
     else if (State == State.Configure)
     {
     }
 }
Exemplo n.º 3
0
        private void DrawString(string text, SimpleFont font, DXMediaBrush brush, double pointX, double pointY, DXMediaBrush areaBrush)
        {
            SharpDX.DirectWrite.TextFormat textFormat = font.ToDirectWriteTextFormat();
            SharpDX.DirectWrite.TextLayout textLayout =
                new SharpDX.DirectWrite.TextLayout(NinjaTrader.Core.Globals.DirectWriteFactory,
                                                   text, textFormat, ChartPanel.X + ChartPanel.W,
                                                   textFormat.FontSize);

            float newW = textLayout.Metrics.Width;
            float newH = textLayout.Metrics.Height;

            SharpDX.Vector2 TextPlotPoint = new System.Windows.Point(pointX - newW, pointY - textLayout.Metrics.Height / 2 - 1).ToVector2();

            SharpDX.RectangleF PLBoundRect = new SharpDX.RectangleF((float)pointX - newW - 4, (float)pointY - textLayout.Metrics.Height / 2 - 1, newW + 6, newH + 2);

            SharpDX.Direct2D1.RoundedRectangle PLRoundedRect = new SharpDX.Direct2D1.RoundedRectangle();

            PLRoundedRect.RadiusX = newW / 4;
            PLRoundedRect.RadiusY = newH / 4;
            PLRoundedRect.Rect    = PLBoundRect;

            RenderTarget.FillRoundedRectangle(PLRoundedRect, areaBrush.DxBrush);

            RenderTarget.DrawTextLayout(TextPlotPoint, textLayout, brush.DxBrush, SharpDX.Direct2D1.DrawTextOptions.NoSnap);

            textLayout.Dispose();
            textLayout = null;
            textFormat.Dispose();
            textFormat = null;
        }
Exemplo n.º 4
0
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description             = @"Enter the description for your new custom Indicator here.";
                Name                    = "EdsLevel2";
                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;
                HistogramOpacity         = 60;
                HistogramAskBarColor     = Brushes.Plum;
                HistogramBidBarColor     = Brushes.LightGreen;
                TextColor  = Brushes.White;
                TextColor2 = Brushes.LightGray;

                dxmBrushes = new Dictionary <string, DXMediaMap>();

                foreach (string brushName in new string[] { "HistogramAskBarBrush", "HistogramBidBarBrush", "TextBrush", "TextBrush2", "TransparentBrush" })
                {
                    dxmBrushes.Add(brushName, new DXMediaMap());
                }
            }
            else if (State == State.DataLoaded)
            {
                askRows       = new List <DOMRow>();
                bidRows       = new List <DOMRow>();
                oneDOMRow     = null;
                askRowsSorted = new Dictionary <double, int>();
                bidRowsSorted = new Dictionary <double, int>();

                textFont = new SimpleFont("GenericSansSerif", 9);

                HistogramAskBarBrush = HistogramAskBarColor;
                HistogramBidBarBrush = HistogramBidBarColor;
                TextBrush            = TextColor;
                TextBrush2           = TextColor2;
                TransparentBrush     = Brushes.Transparent;
            }
            else if (State == State.Terminated)
            {
                foreach (KeyValuePair <string, DXMediaMap> item in dxmBrushes)
                {
                    if (item.Value.DxBrush != null)
                    {
                        item.Value.DxBrush.Dispose();
                    }
                }
            }
        }
        //private string message = "no message";
        /// [X] Audio alerts -- download sounds
        /// [X] Stats 7 - 9 am  if low
        /// [X] Avg Daily Gain?
        /// [X] Daily Gain Limit of 16T? Hurts Performance
        /// [X] Daily Loss Limit of 16T?
        /// [ ] Combine stats window
        /// [ ] Auto generate a chart
        /// [ ] Genetic optimize params

        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description             = @"Enter the description for your new custom Indicator here.";
                Name                    = "LT Vol Swing Cum Delta";
                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;
                AddPlot(Brushes.Orange, "TrendDir");
                AddPlot(Brushes.Orange, "CumSma");
                UpColor           = Brushes.DodgerBlue;
                DnColor           = Brushes.Red;
                ColorBars         = true;
                SetUpBars         = true;
                AudioAlerts       = true;
                StartTime         = DateTime.Parse("07:00", System.Globalization.CultureInfo.InvariantCulture);
                EndTime           = DateTime.Parse("09:00", System.Globalization.CultureInfo.InvariantCulture);
                StopTicks         = 12;
                TargetTicks       = 12;
                CalcStats         = true;
                BackgroundOpacity = 90;
                NoteLocation      = TextPosition.TopLeft;
                BackgroundColor   = Brushes.DimGray;
                FontColor         = Brushes.WhiteSmoke;
                OutlineColor      = Brushes.DimGray;
                NoteFont          = new SimpleFont("Arial", 12);
                MaxLoss           = 16;
                MaxGain           = 60;
                fastSeries        = new Series <double>(this, MaximumBarsLookBack.Infinite);
            }
            else if (State == State.Configure)
            {
                ClearOutputWindow();
                AddDataSeries(Data.BarsPeriodType.Tick, 1);
            }
            else if (State == State.DataLoaded)
            {
                LT_Swing_Trend1    = LT_Swing_Trend(Close, ltSwingTrendDeviationType.ATR, false, false, 72, 3, 5, 0.15);
                cumulativeDelta    = OrderFlowCumulativeDelta(CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Bar, 0);
                cumulativeDeltaRth = OrderFlowCumulativeDelta(CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Session, 0);
                amaDSSBressert1    = amaDSSBressert(Close, 10, 3, 7, 80, 20);
            }
        }
Exemplo n.º 6
0
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description             = @"Enter the description for your new custom Indicator here.";
                Name                    = "Stats IB DX";
                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;
                RTHopen        = DateTime.Parse("06:31", System.Globalization.CultureInfo.InvariantCulture);
                IB             = DateTime.Parse("07:30", System.Globalization.CultureInfo.InvariantCulture);
                RTHclose       = DateTime.Parse("13:00", System.Globalization.CultureInfo.InvariantCulture);
                path           = NinjaTrader.Core.Globals.UserDataDir + "IBData.csv";
                MinIB          = 1.0;
                MinRange       = 1.0;
                CalcIB         = true;
                CalcRange      = false;
                CalcVolume     = false;
                CurrentDayOnly = true;

                BackgroundColor   = Brushes.DimGray;
                BackgroundOpacity = 90;
                FontColor         = Brushes.WhiteSmoke;
                OutlineColor      = Brushes.DimGray;
                NoteFont          = new SimpleFont("Arial", 12);
                AreaOpacity       = 80;
                AreaBrush         = System.Windows.Media.Brushes.DodgerBlue;
                textSize          = 11;
                TextBrush         = System.Windows.Media.Brushes.WhiteSmoke;
            }
            else if (State == State.Configure)
            {
                startTime = long.Parse(RTHopen.ToString("HHmmss"));
                endTime   = long.Parse(RTHclose.ToString("HHmmss"));
                ibTime    = long.Parse(IB.ToString("HHmmss"));
                AddDataSeries(Data.BarsPeriodType.Minute, 1);
                OrderFlowVWAP1 = OrderFlowVWAP(Close, NinjaTrader.NinjaScript.Indicators.VWAPResolution.Standard, Bars.TradingHours, NinjaTrader.NinjaScript.Indicators.VWAPStandardDeviations.Three, 1, 2, 3);
                ClearOutputWindow();
            }
        }
Exemplo n.º 7
0
 public CurrentPriceMarker CurrentPriceMarker(ISeries <double> input, SimpleFont font, Brush priceLineColor, Brush priceTextColor, Brush priceAreaColor, int priceLineLength, int priceLineWidth, DashStyleHelper priceLineStyle, double priceLineOpacity)
 {
     if (cacheCurrentPriceMarker != null)
     {
         for (int idx = 0; idx < cacheCurrentPriceMarker.Length; idx++)
         {
             if (cacheCurrentPriceMarker[idx] != null && cacheCurrentPriceMarker[idx].Font == font && cacheCurrentPriceMarker[idx].PriceLineColor == priceLineColor && cacheCurrentPriceMarker[idx].PriceTextColor == priceTextColor && cacheCurrentPriceMarker[idx].PriceAreaColor == priceAreaColor && cacheCurrentPriceMarker[idx].PriceLineLength == priceLineLength && cacheCurrentPriceMarker[idx].PriceLineWidth == priceLineWidth && cacheCurrentPriceMarker[idx].PriceLineStyle == priceLineStyle && cacheCurrentPriceMarker[idx].PriceLineOpacity == priceLineOpacity && cacheCurrentPriceMarker[idx].EqualsInput(input))
             {
                 return(cacheCurrentPriceMarker[idx]);
             }
         }
     }
     return(CacheIndicator <CurrentPriceMarker>(new CurrentPriceMarker()
     {
         Font = font, PriceLineColor = priceLineColor, PriceTextColor = priceTextColor, PriceAreaColor = priceAreaColor, PriceLineLength = priceLineLength, PriceLineWidth = priceLineWidth, PriceLineStyle = priceLineStyle, PriceLineOpacity = priceLineOpacity
     }, input, ref cacheCurrentPriceMarker));
 }
Exemplo n.º 8
0
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description             = @"Enter the description for your new custom Indicator here.";
                Name                    = "Cycle Counter Harmonic";
                Calculate               = Calculate.OnBarClose;
                IsOverlay               = true;
                DisplayInDataBox        = true;
                DrawOnPricePanel        = false;
                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;
                SwingStrength            = 5;
                SmallCycleMin            = 12;
                LargeCycleMin            = 90;

                NoteLocation      = TextPosition.TopLeft;
                BackgroundColor   = Brushes.DimGray;
                BackgroundOpacity = 90;
                FontColor         = Brushes.WhiteSmoke;
                OutlineColor      = Brushes.DimGray;
                NoteFont          = new SimpleFont("Arial", 12);
            }
            else if (State == State.Configure)
            {
            }
            else if (State == State.DataLoaded)
            {
                Swing1 = Swing(Close, SwingStrength);
                ClearOutputWindow();

                WTTcRSI21 = WTTcRSI2(Close, 20, 10, true, 3, 20, Brushes.DodgerBlue, Brushes.Red);
                WTTcRSI21.Plots[0].Brush = Brushes.Red;
                WTTcRSI21.Plots[1].Brush = Brushes.DodgerBlue;
                WTTcRSI21.Plots[2].Brush = Brushes.DimGray;
                WTTcRSI21.Plots[3].Brush = Brushes.DodgerBlue;
                //AddChartIndicator(WTTcRSI21);
            }
        }
Exemplo n.º 9
0
        private void DrawString(string text, SimpleFont font, string brushName, double pointX, double pointY, string areaBrushName)
        {
            SharpDX.DirectWrite.TextFormat textFormat = font.ToDirectWriteTextFormat();
            SharpDX.Vector2 TextPlotPoint             = new System.Windows.Point(pointX, pointY).ToVector2();
            SharpDX.DirectWrite.TextLayout textLayout =
                new SharpDX.DirectWrite.TextLayout(NinjaTrader.Core.Globals.DirectWriteFactory,
                                                   text, textFormat, ChartPanel.X + ChartPanel.W,
                                                   textFormat.FontSize);

            float newW = textLayout.Metrics.Width;
            float newH = textLayout.Metrics.Height;

            SharpDX.RectangleF PLBoundRect = new SharpDX.RectangleF((float)pointX + 2, (float)pointY, newW + 5, newH + 2);
            RenderTarget.FillRectangle(PLBoundRect, dxmBrushes[areaBrushName].DxBrush);

            RenderTarget.DrawTextLayout(TextPlotPoint, textLayout, dxmBrushes[brushName].DxBrush, SharpDX.Direct2D1.DrawTextOptions.NoSnap);
            textLayout.Dispose();
            textFormat.Dispose();
        }
Exemplo n.º 10
0
 protected override void OnStateChange()
 {
     if (State == State.SetDefaults)
     {
         Description              = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDescriptionNetChangeDisplay;
         Name                     = NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameNetChangeDisplay;
         Calculate                = Calculate.OnPriceChange;
         IsOverlay                = true;
         DrawOnPricePanel         = true;
         IsSuspendedWhileInactive = true;
         Unit                     = Cbi.PerformanceUnit.Percent;
         PositiveBrush            = Brushes.LimeGreen;
         NegativeBrush            = Brushes.Red;
         Location                 = NetChangePosition.TopRight;
         Font                     = new SimpleFont("Arial", 18);
     }
     else if (State == State.Configure)
     {
         instrument = Instruments[0];
     }
 }
Exemplo n.º 11
0
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description             = @"Places a marker on the chart displaying where the current price is.";
                Name                    = "CurrentPriceMarker";
                Calculate               = Calculate.OnPriceChange;
                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;

                Font             = new SimpleFont("Arial", 10);
                PriceLineColor   = Brushes.RoyalBlue;
                PriceTextColor   = Brushes.White;
                PriceAreaColor   = Brushes.Black;
                PriceLineLength  = 15;
                PriceLineWidth   = 2;
                PriceLineStyle   = DashStyleHelper.Dash;
                PriceLineOpacity = 50;
            }
            else if (State == State.Configure)
            {
                // Create our DXMediaBrushes
                PriceLineBrush = new DXMediaBrush();
                PriceTextBrush = new DXMediaBrush();
                PriceAreaBrush = new DXMediaBrush();

                // Set our DXMediaBrush properties
                PriceLineBrush.UpdateBrush(RenderTarget, PriceLineColor, PriceLineOpacity);
                PriceTextBrush.UpdateBrush(RenderTarget, PriceTextColor, PriceLineOpacity);
                PriceAreaBrush.UpdateBrush(RenderTarget, PriceAreaColor, PriceLineOpacity);
            }
        }
Exemplo n.º 12
0
 public DrawingProperties(bool isDotAutoScale, Brush upDotColor, Brush downDotColor,
                          Brush upDotOutlineColor, Brush downDotOutlineColor, bool isTextAutoScale,
                          int textYPixelOffSet, Brush textColor, SimpleFont textSimpleFont,
                          TextAlignment textAligmentPropertie, Brush textOutlineBrush, Brush textAreaBrush,
                          int textAreaOpacity, bool isLineAutoScale, Brush lineColor, DashStyleHelper lineDashStyle, int lineWidth)
 {
     IsDotAutoScale        = isDotAutoScale;
     UpDotColor            = upDotColor;
     DownDotColor          = downDotColor;
     UpDotOutlineColor     = upDotOutlineColor;
     DownDotOutlineColor   = downDotOutlineColor;
     IsTextAutoScale       = isTextAutoScale;
     TextYPixelOffSet      = textYPixelOffSet;
     TextColor             = textColor;
     TextSimpleFont        = textSimpleFont;
     TextAligmentPropertie = textAligmentPropertie;
     TextOutlineBrush      = textOutlineBrush;
     TextAreaBrush         = textAreaBrush;
     TextAreaOpacity       = textAreaOpacity;
     IsLineAutoScale       = isLineAutoScale;
     LineColor             = lineColor;
     LineDashStyle         = lineDashStyle;
     LineWidth             = lineWidth;
 }
Exemplo n.º 13
0
 public Indicators.StatsIBDX StatsIBDX(ISeries <double> input, DateTime rTHopen, DateTime iB, DateTime rTHclose, double minIB, double minRange, bool currentDayOnly, bool calcIB, bool calcRange, bool calcVolume, int textSize, Brush backgroundColor, Brush fontColor, Brush outlineColor, SimpleFont noteFont, int backgroundOpacity)
 {
     return(indicator.StatsIBDX(input, rTHopen, iB, rTHclose, minIB, minRange, currentDayOnly, calcIB, calcRange, calcVolume, textSize, backgroundColor, fontColor, outlineColor, noteFont, backgroundOpacity));
 }
Exemplo n.º 14
0
 public AMission AMission(string topMessage, string bottomMessage, Brush textColor, Brush topTextColor, Brush backGroundCOlor, SimpleFont noteFont)
 {
     return(AMission(Input, topMessage, bottomMessage, textColor, topTextColor, backGroundCOlor, noteFont));
 }
Exemplo n.º 15
0
 public CycleCounterHarmonic CycleCounterHarmonic(ISeries <double> input, int swingStrength, int smallCycleMin, int largeCycleMin, Brush backgroundColor, Brush fontColor, Brush outlineColor, SimpleFont noteFont, int backgroundOpacity, TextPosition noteLocation)
 {
     if (cacheCycleCounterHarmonic != null)
     {
         for (int idx = 0; idx < cacheCycleCounterHarmonic.Length; idx++)
         {
             if (cacheCycleCounterHarmonic[idx] != null && cacheCycleCounterHarmonic[idx].SwingStrength == swingStrength && cacheCycleCounterHarmonic[idx].SmallCycleMin == smallCycleMin && cacheCycleCounterHarmonic[idx].LargeCycleMin == largeCycleMin && cacheCycleCounterHarmonic[idx].BackgroundColor == backgroundColor && cacheCycleCounterHarmonic[idx].FontColor == fontColor && cacheCycleCounterHarmonic[idx].OutlineColor == outlineColor && cacheCycleCounterHarmonic[idx].NoteFont == noteFont && cacheCycleCounterHarmonic[idx].BackgroundOpacity == backgroundOpacity && cacheCycleCounterHarmonic[idx].NoteLocation == noteLocation && cacheCycleCounterHarmonic[idx].EqualsInput(input))
             {
                 return(cacheCycleCounterHarmonic[idx]);
             }
         }
     }
     return(CacheIndicator <CycleCounterHarmonic>(new CycleCounterHarmonic()
     {
         SwingStrength = swingStrength, SmallCycleMin = smallCycleMin, LargeCycleMin = largeCycleMin, BackgroundColor = backgroundColor, FontColor = fontColor, OutlineColor = outlineColor, NoteFont = noteFont, BackgroundOpacity = backgroundOpacity, NoteLocation = noteLocation
     }, input, ref cacheCycleCounterHarmonic));
 }
Exemplo n.º 16
0
        public override void OnRender(ChartControl chartControl, ChartScale chartScale)
        {
            RenderTarget.AntialiasMode = SharpDX.Direct2D1.AntialiasMode.PerPrimitive;

            ChartPanel panel       = chartControl.ChartPanels[PanelIndex];
            Point      anchorPoint = Anchor.GetPoint(chartControl, panel, chartScale);

            Point lastEndPoint = new Point(0, 0);

            SharpDX.Direct2D1.Brush lastBrush = null;
            foreach (GannAngle gannAngle in GannAngles.Where(ga => ga.IsVisible && ga.Stroke != null).OrderBy(ga => (ga.RatioX / ga.RatioY)))
            {
                gannAngle.Stroke.RenderTarget = RenderTarget;

                double dx               = gannAngle.RatioX * chartControl.Properties.BarDistance;
                double dVal             = gannAngle.RatioY * PointsPerBar;                                //NT7, just multiple directly this is price not pixels //chartScale.GetPixelsForDistance(gannAngle.RatioY * PointsPerBar);
                Vector gannDataVector   = GetGannStepDataVector(dx, dVal);
                Point  extendedEndPoint = CalculateExtendedDataPoint(panel, chartScale, Convert.ToInt32(anchorPoint.X), Anchor.Price, gannDataVector);

                // align to full pixel to avoid unneeded aliasing
                double strokePixAdj   = ((double)(gannAngle.Stroke.Width % 2)).ApproxCompare(0) == 0 ? 0.5d : 0d;
                Vector pixelAdjustVec = new Vector(0, strokePixAdj);

                SharpDX.Direct2D1.Brush tmpBrush = IsInHitTest ? chartControl.SelectionBrush : gannAngle.Stroke.BrushDX;
                RenderTarget.DrawLine((anchorPoint + pixelAdjustVec).ToVector2(), (extendedEndPoint + pixelAdjustVec).ToVector2(), tmpBrush, gannAngle.Stroke.Width, gannAngle.Stroke.StrokeStyle);

                if (lastBrush != null)
                {
                    float oldOpacity = lastBrush.Opacity;
                    lastBrush.Opacity = PriceLevelOpacity / 100f;

                    // create geometry
                    SharpDX.Direct2D1.PathGeometry lineGeometry = new SharpDX.Direct2D1.PathGeometry(Core.Globals.D2DFactory);
                    SharpDX.Direct2D1.GeometrySink sink         = lineGeometry.Open();
                    sink.BeginFigure(lastEndPoint.ToVector2(), SharpDX.Direct2D1.FigureBegin.Filled);
                    // Does the fill color need to fill a corner?  Check and add a point
                    if (Math.Abs(lastEndPoint.Y - extendedEndPoint.Y) > 0.1 && Math.Abs(lastEndPoint.X - extendedEndPoint.X) > 0.1)
                    {
                        double boundaryX;
                        double boundaryY;

                        if (lastEndPoint.Y <= ChartPanel.Y || lastEndPoint.Y >= ChartPanel.Y + ChartPanel.H)
                        {
                            if (FanDirection == GannFanDirection.UpLeft || FanDirection == GannFanDirection.UpRight)
                            {
                                boundaryY = extendedEndPoint.Y;
                                boundaryX = lastEndPoint.X;
                            }
                            else
                            {
                                boundaryY = lastEndPoint.Y;
                                boundaryX = extendedEndPoint.X;
                            }
                        }
                        else
                        {
                            if (FanDirection == GannFanDirection.UpLeft || FanDirection == GannFanDirection.UpRight)
                            {
                                boundaryY = lastEndPoint.Y;
                                boundaryX = extendedEndPoint.X;
                            }
                            else
                            {
                                boundaryY = extendedEndPoint.Y;
                                boundaryX = lastEndPoint.X;
                            }
                        }
                        sink.AddLine(new SharpDX.Vector2((float)boundaryX, (float)boundaryY));
                    }

                    sink.AddLine(extendedEndPoint.ToVector2());
                    sink.AddLine((anchorPoint + pixelAdjustVec).ToVector2());
                    sink.AddLine((lastEndPoint).ToVector2());
                    sink.EndFigure(SharpDX.Direct2D1.FigureEnd.Closed);
                    sink.Close();
                    RenderTarget.FillGeometry(lineGeometry, lastBrush);
                    lineGeometry.Dispose();

                    lastBrush.Opacity = oldOpacity;
                }
                lastEndPoint = extendedEndPoint + pixelAdjustVec;
                lastBrush    = tmpBrush;
            }

            if (!IsTextDisplayed || IsInHitTest)
            {
                return;
            }

            foreach (GannAngle gannAngle in GannAngles.Where(ga => ga.IsVisible && ga.Stroke != null).OrderBy(ga => (ga.RatioX / ga.RatioY)))
            {
                gannAngle.Stroke.RenderTarget = RenderTarget;
                double dx               = gannAngle.RatioX * chartControl.Properties.BarDistance;
                double dVal             = gannAngle.RatioY * PointsPerBar;                                //NT7, just multiple directly this is price not pixels //chartScale.GetPixelsForDistance(gannAngle.RatioY * PointsPerBar);
                Vector gannDataVector   = GetGannStepDataVector(dx, dVal);
                Point  extendedEndPoint = CalculateExtendedDataPoint(panel, chartScale, Convert.ToInt32(anchorPoint.X), Anchor.Price, gannDataVector);

                if (!IsTextDisplayed || IsInHitTest)
                {
                    continue;
                }

                SimpleFont wpfFont = chartControl.Properties.LabelFont ?? new SimpleFont();
                SharpDX.DirectWrite.TextFormat textFormat = wpfFont.ToDirectWriteTextFormat();
                textFormat.TextAlignment = SharpDX.DirectWrite.TextAlignment.Leading;
                textFormat.WordWrapping  = SharpDX.DirectWrite.WordWrapping.NoWrap;
                SharpDX.DirectWrite.TextLayout textLayout = new SharpDX.DirectWrite.TextLayout(Core.Globals.DirectWriteFactory, gannAngle.Name, textFormat, 100, textFormat.FontSize);

                // once text is laid out, update used width to calcuated space required
                float fontHeight = textLayout.Metrics.Height;

                Point textEndPoint = new Point(extendedEndPoint.X, extendedEndPoint.Y);

                if (textEndPoint.X > panel.X + panel.W - textLayout.Metrics.Width)
                {
                    textEndPoint.X  = panel.X + panel.W - textLayout.Metrics.Width;
                    textEndPoint.Y += textLayout.Metrics.Width;
                }

                if (gannDataVector.Y > 0)
                {
                    if (textEndPoint.Y < panel.Y + (fontHeight * 0.5))
                    {
                        textEndPoint.Y = panel.Y + (fontHeight * 0.5);
                    }
                }
                else
                {
                    if (textEndPoint.Y > panel.Y + panel.H - (fontHeight * 1.5))
                    {
                        textEndPoint.Y = panel.Y + panel.H - (fontHeight * 1.5);
                    }
                }

                float?marginResource = Application.Current.FindResource("FontModalTitleMargin") as float?;
                float margin         = 2f + (marginResource.HasValue ? marginResource.Value : 3f);
                // Allow for changes in X position based on whether text is aligned to left or right edge of screen
                float marginX = FanDirection == GannFanDirection.DownLeft || FanDirection == GannFanDirection.UpLeft ? margin : -2 * margin;

                SharpDX.Vector2   endVec          = new SharpDX.Vector2((float)textEndPoint.X, (float)textEndPoint.Y);
                SharpDX.Matrix3x2 transformMatrix = SharpDX.Matrix3x2.Translation(endVec);

                RenderTarget.Transform = transformMatrix;

                RenderTarget.DrawTextLayout(new SharpDX.Vector2(marginX + margin, margin), textLayout, gannAngle.Stroke.BrushDX, SharpDX.Direct2D1.DrawTextOptions.NoSnap);

                RenderTarget.Transform = SharpDX.Matrix3x2.Identity;
                textFormat.Dispose();
                textLayout.Dispose();
            }
        }
Exemplo n.º 17
0
        private void DrawPriceText(ChartAnchor anchor, Point point, double price, ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale)
        {
            if (TextAlignment == TextLocation.Off)
            {
                return;
            }

            string    priceString;
            ChartBars chartBars = GetAttachedToChartBars();

            // bars can be null while chart is initializing
            if (chartBars == null)
            {
                return;
            }

            priceString = GetPriceString(price, chartBars);

            Stroke color;

            textleftPoint  = RiskAnchor.GetPoint(chartControl, chartPanel, chartScale).X;
            textRightPoint = EntryAnchor.GetPoint(chartControl, chartPanel, chartScale).X;

            if (anchor == RewardAnchor)
            {
                color = TargetLineStroke;
            }
            else if (anchor == RiskAnchor)
            {
                color = StopLineStroke;
            }
            else if (anchor == EntryAnchor)
            {
                color = EntryLineStroke;
            }
            else
            {
                color = AnchorLineStroke;
            }

            SimpleFont wpfFont = chartControl.Properties.LabelFont ?? new SimpleFont();

            SharpDX.DirectWrite.TextFormat textFormat = wpfFont.ToDirectWriteTextFormat();
            textFormat.TextAlignment = SharpDX.DirectWrite.TextAlignment.Leading;
            textFormat.WordWrapping  = SharpDX.DirectWrite.WordWrapping.NoWrap;
            SharpDX.DirectWrite.TextLayout textLayout = new SharpDX.DirectWrite.TextLayout(Core.Globals.DirectWriteFactory, priceString, textFormat, chartPanel.H, textFormat.FontSize);

            if (RiskAnchor.Time <= EntryAnchor.Time)
            {
                if (!IsExtendedLinesLeft && !IsExtendedLinesRight)
                {
                    switch (TextAlignment)
                    {
                    case TextLocation.InsideLeft: point.X = textleftPoint;                                                              break;

                    case TextLocation.InsideRight: point.X = textRightPoint - textLayout.Metrics.Width;  break;

                    case TextLocation.ExtremeLeft: point.X = textleftPoint;                                                              break;

                    case TextLocation.ExtremeRight: point.X = textRightPoint - textLayout.Metrics.Width;  break;
                    }
                }
                else if (IsExtendedLinesLeft && !IsExtendedLinesRight)
                {
                    switch (TextAlignment)
                    {
                    case TextLocation.InsideLeft: point.X = textleftPoint;                                                              break;

                    case TextLocation.InsideRight: point.X = textRightPoint - textLayout.Metrics.Width;  break;

                    case TextLocation.ExtremeLeft: point.X = chartPanel.X;                                                               break;

                    case TextLocation.ExtremeRight: point.X = textRightPoint - textLayout.Metrics.Width;  break;
                    }
                }
                else if (!IsExtendedLinesLeft && IsExtendedLinesRight)
                {
                    switch (TextAlignment)
                    {
                    case TextLocation.InsideLeft: point.X = textleftPoint;                                                              break;

                    case TextLocation.InsideRight: point.X = textRightPoint - textLayout.Metrics.Width;  break;

                    case TextLocation.ExtremeLeft: point.X = textleftPoint;                                                              break;

                    case TextLocation.ExtremeRight: point.X = chartPanel.W - textLayout.Metrics.Width;    break;
                    }
                }
                else if (IsExtendedLinesLeft && IsExtendedLinesRight)
                {
                    switch (TextAlignment)
                    {
                    case TextLocation.InsideLeft: point.X = textleftPoint;                                                              break;

                    case TextLocation.InsideRight: point.X = textRightPoint - textLayout.Metrics.Width;  break;

                    case TextLocation.ExtremeRight: point.X = chartPanel.W - textLayout.Metrics.Width;    break;

                    case TextLocation.ExtremeLeft: point.X = chartPanel.X;                                                               break;
                    }
                }
            }
            else if (RiskAnchor.Time >= EntryAnchor.Time)
            {
                if (!IsExtendedLinesLeft && !IsExtendedLinesRight)
                {
                    switch (TextAlignment)
                    {
                    case TextLocation.InsideLeft: point.X = textRightPoint;                                                             break;

                    case TextLocation.InsideRight: point.X = textleftPoint - textLayout.Metrics.Width;   break;

                    case TextLocation.ExtremeLeft: point.X = textRightPoint;                                                             break;

                    case TextLocation.ExtremeRight: point.X = textleftPoint - textLayout.Metrics.Width;   break;
                    }
                }
                else if (IsExtendedLinesLeft && !IsExtendedLinesRight)
                {
                    switch (TextAlignment)
                    {
                    case TextLocation.InsideLeft: point.X = textRightPoint;                                                             break;

                    case TextLocation.InsideRight: point.X = textleftPoint - textLayout.Metrics.Width;   break;

                    case TextLocation.ExtremeLeft: point.X = chartPanel.X;                                                               break;

                    case TextLocation.ExtremeRight: point.X = textleftPoint - textLayout.Metrics.Width;   break;
                    }
                }
                else if (!IsExtendedLinesLeft && IsExtendedLinesRight)
                {
                    switch (TextAlignment)
                    {
                    case TextLocation.InsideLeft: point.X = textRightPoint;                                                             break;

                    case TextLocation.InsideRight: point.X = textleftPoint - textLayout.Metrics.Width;   break;

                    case TextLocation.ExtremeLeft: point.X = textRightPoint;                                                             break;

                    case TextLocation.ExtremeRight: point.X = chartPanel.W - textLayout.Metrics.Width;    break;
                    }
                }
                else if (IsExtendedLinesLeft && IsExtendedLinesRight)
                {
                    switch (TextAlignment)
                    {
                    case TextLocation.InsideLeft: point.X = textRightPoint;                                                             break;

                    case TextLocation.InsideRight: point.X = textleftPoint - textLayout.Metrics.Width;   break;

                    case TextLocation.ExtremeRight: point.X = chartPanel.W - textLayout.Metrics.Width;    break;

                    case TextLocation.ExtremeLeft: point.X = chartPanel.X;                                                               break;
                    }
                }
            }

            RenderTarget.DrawTextLayout(new SharpDX.Vector2((float)point.X, (float)point.Y), textLayout, color.BrushDX, SharpDX.Direct2D1.DrawTextOptions.NoSnap);
        }
Exemplo n.º 18
0
 public LTVolSwingCumDelta LTVolSwingCumDelta(ISeries <double> input, Brush upColor, Brush dnColor, DateTime startTime, DateTime endTime, int stopTicks, int targetTicks, int maxLoss, int maxGain, Brush backgroundColor, Brush fontColor, Brush outlineColor, SimpleFont noteFont, int backgroundOpacity, TextPosition noteLocation)
 {
     if (cacheLTVolSwingCumDelta != null)
     {
         for (int idx = 0; idx < cacheLTVolSwingCumDelta.Length; idx++)
         {
             if (cacheLTVolSwingCumDelta[idx] != null && cacheLTVolSwingCumDelta[idx].UpColor == upColor && cacheLTVolSwingCumDelta[idx].DnColor == dnColor && cacheLTVolSwingCumDelta[idx].StartTime == startTime && cacheLTVolSwingCumDelta[idx].EndTime == endTime && cacheLTVolSwingCumDelta[idx].StopTicks == stopTicks && cacheLTVolSwingCumDelta[idx].TargetTicks == targetTicks && cacheLTVolSwingCumDelta[idx].MaxLoss == maxLoss && cacheLTVolSwingCumDelta[idx].MaxGain == maxGain && cacheLTVolSwingCumDelta[idx].BackgroundColor == backgroundColor && cacheLTVolSwingCumDelta[idx].FontColor == fontColor && cacheLTVolSwingCumDelta[idx].OutlineColor == outlineColor && cacheLTVolSwingCumDelta[idx].NoteFont == noteFont && cacheLTVolSwingCumDelta[idx].BackgroundOpacity == backgroundOpacity && cacheLTVolSwingCumDelta[idx].NoteLocation == noteLocation && cacheLTVolSwingCumDelta[idx].EqualsInput(input))
             {
                 return(cacheLTVolSwingCumDelta[idx]);
             }
         }
     }
     return(CacheIndicator <LTVolSwingCumDelta>(new LTVolSwingCumDelta()
     {
         UpColor = upColor, DnColor = dnColor, StartTime = startTime, EndTime = endTime, StopTicks = stopTicks, TargetTicks = targetTicks, MaxLoss = maxLoss, MaxGain = maxGain, BackgroundColor = backgroundColor, FontColor = fontColor, OutlineColor = outlineColor, NoteFont = noteFont, BackgroundOpacity = backgroundOpacity, NoteLocation = noteLocation
     }, input, ref cacheLTVolSwingCumDelta));
 }
Exemplo n.º 19
0
 public Indicators.LTVolSwingCumDelta LTVolSwingCumDelta(ISeries <double> input, Brush upColor, Brush dnColor, DateTime startTime, DateTime endTime, int stopTicks, int targetTicks, int maxLoss, int maxGain, Brush backgroundColor, Brush fontColor, Brush outlineColor, SimpleFont noteFont, int backgroundOpacity, TextPosition noteLocation)
 {
     return(indicator.LTVolSwingCumDelta(input, upColor, dnColor, startTime, endTime, stopTicks, targetTicks, maxLoss, maxGain, backgroundColor, fontColor, outlineColor, noteFont, backgroundOpacity, noteLocation));
 }
Exemplo n.º 20
0
 public Indicators.CurrentPriceMarker CurrentPriceMarker(ISeries <double> input, SimpleFont font, Brush priceLineColor, Brush priceTextColor, Brush priceAreaColor, int priceLineLength, int priceLineWidth, DashStyleHelper priceLineStyle, double priceLineOpacity)
 {
     return(indicator.CurrentPriceMarker(input, font, priceLineColor, priceTextColor, priceAreaColor, priceLineLength, priceLineWidth, priceLineStyle, priceLineOpacity));
 }
Exemplo n.º 21
0
 public StatsIBDX StatsIBDX(ISeries <double> input, DateTime rTHopen, DateTime iB, DateTime rTHclose, double minIB, double minRange, bool currentDayOnly, bool calcIB, bool calcRange, bool calcVolume, int textSize, Brush backgroundColor, Brush fontColor, Brush outlineColor, SimpleFont noteFont, int backgroundOpacity)
 {
     if (cacheStatsIBDX != null)
     {
         for (int idx = 0; idx < cacheStatsIBDX.Length; idx++)
         {
             if (cacheStatsIBDX[idx] != null && cacheStatsIBDX[idx].RTHopen == rTHopen && cacheStatsIBDX[idx].IB == iB && cacheStatsIBDX[idx].RTHclose == rTHclose && cacheStatsIBDX[idx].MinIB == minIB && cacheStatsIBDX[idx].MinRange == minRange && cacheStatsIBDX[idx].CurrentDayOnly == currentDayOnly && cacheStatsIBDX[idx].CalcIB == calcIB && cacheStatsIBDX[idx].CalcRange == calcRange && cacheStatsIBDX[idx].CalcVolume == calcVolume && cacheStatsIBDX[idx].textSize == textSize && cacheStatsIBDX[idx].BackgroundColor == backgroundColor && cacheStatsIBDX[idx].FontColor == fontColor && cacheStatsIBDX[idx].OutlineColor == outlineColor && cacheStatsIBDX[idx].NoteFont == noteFont && cacheStatsIBDX[idx].BackgroundOpacity == backgroundOpacity && cacheStatsIBDX[idx].EqualsInput(input))
             {
                 return(cacheStatsIBDX[idx]);
             }
         }
     }
     return(CacheIndicator <StatsIBDX>(new StatsIBDX()
     {
         RTHopen = rTHopen, IB = iB, RTHclose = rTHclose, MinIB = minIB, MinRange = minRange, CurrentDayOnly = currentDayOnly, CalcIB = calcIB, CalcRange = calcRange, CalcVolume = calcVolume, textSize = textSize, BackgroundColor = backgroundColor, FontColor = fontColor, OutlineColor = outlineColor, NoteFont = noteFont, BackgroundOpacity = backgroundOpacity
     }, input, ref cacheStatsIBDX));
 }
Exemplo n.º 22
0
 private void DrawString(string text, SimpleFont font, string brushName, double pointX, double pointY)
 {
     DrawString(text, font, brushName, pointX, pointY, "TransparentBrush");
 }
Exemplo n.º 23
0
        private void UpdateTextLayout(ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale)
        {
            if (isTextCreated && textLayout != null && !textLayout.IsDisposed)
            {
                return;
            }

            if (textFormat != null && !textFormat.IsDisposed)
            {
                textFormat.Dispose();
            }
            if (textLayout != null && !textLayout.IsDisposed)
            {
                textLayout.Dispose();
            }

            ChartBars chartBars = GetAttachedToChartBars();

            // bars can be null while chart is initializing
            if (chartBars == null)
            {
                return;
            }

            double yDiffPrice = AttachedTo.Instrument.MasterInstrument.RoundToTickSize(EndAnchor.Price - StartAnchor.Price);
            double yDiffTicks = yDiffPrice / AttachedTo.Instrument.MasterInstrument.TickSize;

            switch (YValueDisplayUnit)
            {
            case ValueUnit.Price: yValueString = chartBars.Bars.Instrument.MasterInstrument.FormatPrice(yDiffPrice); break;

            case ValueUnit.Currency:
                yValueString = AttachedTo.Instrument.MasterInstrument.InstrumentType == InstrumentType.Forex
                                                ? Core.Globals.FormatCurrency((int)Math.Abs(yDiffTicks) * Account.All[0].ForexLotSize * (AttachedTo.Instrument.MasterInstrument.TickSize * AttachedTo.Instrument.MasterInstrument.PointValue))
                                                : Core.Globals.FormatCurrency((int)Math.Abs(yDiffTicks) * (AttachedTo.Instrument.MasterInstrument.TickSize * AttachedTo.Instrument.MasterInstrument.PointValue));
                break;

            case ValueUnit.Percent: yValueString = (yDiffPrice / AttachedTo.Instrument.MasterInstrument.RoundToTickSize(StartAnchor.Price)).ToString("P", Core.Globals.GeneralOptions.CurrentCulture); break;

            case ValueUnit.Ticks: yValueString = yDiffTicks.ToString("F0"); break;

            case ValueUnit.Pips:
                // show tenth pips (if available)
                double pips        = Math.Abs(yDiffTicks / 10);
                char   decimalChar = Char.Parse(Core.Globals.GeneralOptions.CurrentCulture.NumberFormat.NumberDecimalSeparator);
                yValueString = Int32.Parse(pips.ToString("F1").Split(decimalChar)[1]) > 0 ? pips.ToString("F1").Replace(decimalChar, '\'') : pips.ToString("F0");
                break;
            }

            TimeSpan timeDiff = EndAnchor.Time - StartAnchor.Time;

            // trim off millis/ticks, match NT7 time formatting
            timeDiff = new TimeSpan(timeDiff.Days, timeDiff.Hours, timeDiff.Minutes, timeDiff.Seconds);

            bool isMultiDay = Math.Abs(timeDiff.TotalHours) >= 24;

            if (chartBars.Bars.BarsPeriod.BarsPeriodType == BarsPeriodType.Day)
            {
                int timeDiffDay = Math.Abs(timeDiff.Days);
                timeText = timeDiffDay > 1 ? Math.Abs(timeDiff.Days) + " " + Custom.Resource.Days  : Math.Abs(timeDiff.Days) + " " + Custom.Resource.Day;
            }
            else
            {
                timeText = isMultiDay ? string.Format("{0}\n{1,25}",
                                                      string.Format(Custom.Resource.NinjaScriptDrawingToolRulerDaysFormat, Math.Abs(timeDiff.Days)),
                                                      timeDiff.Subtract(new TimeSpan(timeDiff.Days, 0, 0, 0)).Duration().ToString()) : timeDiff.Duration().ToString();
            }

            Point startPoint = StartAnchor.GetPoint(chartControl, chartPanel, chartScale);
            Point endPoint   = EndAnchor.GetPoint(chartControl, chartPanel, chartScale);
            int   startIdx   = chartBars.GetBarIdxByX(chartControl, (int)startPoint.X);
            int   endIdx     = chartBars.GetBarIdxByX(chartControl, (int)endPoint.X);
            int   numBars    = endIdx - startIdx;

            SimpleFont wpfFont = chartControl.Properties.LabelFont ?? new SimpleFont();

            textFormat = wpfFont.ToDirectWriteTextFormat();
            textFormat.TextAlignment = SharpDX.DirectWrite.TextAlignment.Leading;
            textFormat.WordWrapping  = SharpDX.DirectWrite.WordWrapping.NoWrap;
            // format text to our text rectangle bounds (it will wrap to these constraints), nt7 format
            // NOTE: Environment.NewLine doesnt work right here
            string text = string.Format("{0}\n{1,-11}{2,-11}\n{3,-11}{4,-11}\n{5,-10}{6,-10}",
                                        AttachedTo.DisplayName,
                                        Custom.Resource.NinjaScriptDrawingToolRulerNumberBarsText, numBars,
                                        Custom.Resource.NinjaScriptDrawingToolRulerTimeText, timeText,
                                        Custom.Resource.NinjaScriptDrawingToolRulerYValueText, yValueString);

            // give big values for max width/height, we will trim to actual used
            textLayout = new SharpDX.DirectWrite.TextLayout(Core.Globals.DirectWriteFactory, text, textFormat, 600, 600);
            // use measured max width/height
            textLayout.MaxWidth  = textLayout.Metrics.Width;
            textLayout.MaxHeight = textLayout.Metrics.Height;
            isTextCreated        = true;
        }
Exemplo n.º 24
0
 public Indicators.CycleCounterHarmonic CycleCounterHarmonic(ISeries <double> input, int swingStrength, int smallCycleMin, int largeCycleMin, Brush backgroundColor, Brush fontColor, Brush outlineColor, SimpleFont noteFont, int backgroundOpacity, TextPosition noteLocation)
 {
     return(indicator.CycleCounterHarmonic(input, swingStrength, smallCycleMin, largeCycleMin, backgroundColor, fontColor, outlineColor, noteFont, backgroundOpacity, noteLocation));
 }
Exemplo n.º 25
0
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description             = @"Enter the description for your new custom Indicator here.";
                Name                    = "dDrawABC";
                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;

                AdjustableFib    = 1.786;
                FibABRets        = 3;
                FibBCRets        = 1;
                FibABExtends     = 5;
                FibBCExtends     = 4;
                FibMMReverse     = 5;
                FibMMRets        = 4;
                FibMMExtends     = 5;
                FibABTextToRight = false;
                FibBCTextToRight = true;
                FibMMTextToRight = false;


                APDate = DateTime.Parse("1:46 PM");
                APVal  = 1;
                BPDate = DateTime.Parse("1:47 PM");
                BPVal  = 1;
                CPDate = DateTime.Parse("1:47 PM");
                CPVal  = 1;


                SwingColorUp = Brushes.Green;
                SwingColorDn = Brushes.Red;
                FibABColor   = Brushes.Gray;
                FibBCColor   = Brushes.RoyalBlue;

                FibPct = new double[14];
                FibVal = new double[14];

                FibPct[0] = AdjustableFib;                      //!0 = show this level

                FibPct[1] = 2.0;
                FibPct[2] = 1.618;
                FibPct[3] = 1.272;                      //continuation extentions

                FibPct[4] = 1.0;                        // 100% of move
                //these are backwards for proper display, cause of later math.
                FibPct[5]  = 0.764;                     //not quite accurate, but close enough
                FibPct[6]  = 0.618;
                FibPct[7]  = 0.5;
                FibPct[8]  = 0.382;
                FibPct[9]  = 0.236;
                FibPct[10] = 0.0;                       //reference point, low for up, hi for down.

                FibPct[11] = -0.272;                    //retractions
                FibPct[12] = -0.618;
                FibPct[13] = -1.0;

                textFont      = new SimpleFont("Courier", 9);
                textFontLabel = new SimpleFont("Courier", 12);
            }
            else if (State == State.DataLoaded)
            {
                if (ChartControl != null)
                {
                    ChartPanel.MouseDown += new System.Windows.Input.MouseButtonEventHandler(ChartControl_MouseDown);
                    ChartPanel.MouseMove += new System.Windows.Input.MouseEventHandler(ChartControl_MouseMove);
                }
            }
            else if (State == State.Terminated)
            {
                if (ChartControl != null)
                {
                    ChartPanel.MouseDown -= new System.Windows.Input.MouseButtonEventHandler(ChartControl_MouseDown);
                    ChartPanel.MouseMove -= new System.Windows.Input.MouseEventHandler(ChartControl_MouseMove);
                }
                ClearOutputWindow();
            }
        }
Exemplo n.º 26
0
 public Indicators.CycleCounterDX CycleCounterDX(int swingStrength, int smallCycleMin, int largeCycleMin, Brush backgroundColor, Brush fontColor, Brush outlineColor, SimpleFont noteFont, int backgroundOpacity, TextPosition noteLocation, int textSize)
 {
     return(indicator.CycleCounterDX(Input, swingStrength, smallCycleMin, largeCycleMin, backgroundColor, fontColor, outlineColor, noteFont, backgroundOpacity, noteLocation, textSize));
 }
Exemplo n.º 27
0
 public Indicators.AMission AMission(ISeries <double> input, string topMessage, string bottomMessage, Brush textColor, Brush topTextColor, Brush backGroundCOlor, SimpleFont noteFont)
 {
     return(indicator.AMission(input, topMessage, bottomMessage, textColor, topTextColor, backGroundCOlor, noteFont));
 }
Exemplo n.º 28
0
 public AMission AMission(ISeries <double> input, string topMessage, string bottomMessage, Brush textColor, Brush topTextColor, Brush backGroundCOlor, SimpleFont noteFont)
 {
     if (cacheAMission != null)
     {
         for (int idx = 0; idx < cacheAMission.Length; idx++)
         {
             if (cacheAMission[idx] != null && cacheAMission[idx].TopMessage == topMessage && cacheAMission[idx].BottomMessage == bottomMessage && cacheAMission[idx].TextColor == textColor && cacheAMission[idx].TopTextColor == topTextColor && cacheAMission[idx].BackGroundCOlor == backGroundCOlor && cacheAMission[idx].NoteFont == noteFont && cacheAMission[idx].EqualsInput(input))
             {
                 return(cacheAMission[idx]);
             }
         }
     }
     return(CacheIndicator <AMission>(new AMission()
     {
         TopMessage = topMessage, BottomMessage = bottomMessage, TextColor = textColor, TopTextColor = topTextColor, BackGroundCOlor = backGroundCOlor, NoteFont = noteFont
     }, input, ref cacheAMission));
 }
Exemplo n.º 29
0
        public override void OnRender(ChartControl chartControl, ChartScale chartScale)
        {
            if (firstTime && DrawingState == DrawingState.Normal)
            {
                firstTime = false;
                Cbi.License.Log("Path");
            }

            RenderTarget.AntialiasMode = SharpDX.Direct2D1.AntialiasMode.PerPrimitive;
            Stroke outlineStroke = OutlineStroke;

            outlineStroke.RenderTarget = RenderTarget;
            ChartPanel chartPanel      = chartControl.ChartPanels[PanelIndex];
            double     strokePixAdjust = outlineStroke.Width % 2 == 0 ? 0.5d : 0d;
            Vector     pixelAdjustVec  = new Vector(strokePixAdjust, strokePixAdjust);

            SharpDX.Direct2D1.PathGeometry polyGeo  = CreatePathGeometry(chartControl, chartPanel, chartScale, strokePixAdjust);
            SharpDX.Direct2D1.Brush        tmpBrush = IsInHitTest ? chartControl.SelectionBrush : outlineStroke.BrushDX;

            RenderTarget.DrawGeometry(polyGeo, tmpBrush, outlineStroke.Width, outlineStroke.StrokeStyle);
            polyGeo.Dispose();

            if (PathBegin == PathToolCapMode.Arrow || PathEnd == PathToolCapMode.Arrow)
            {
                Point[] points = GetPathAnchorPoints(chartControl, chartScale);

                if (points.Length > 1)
                {
                    if (arrowPathGeometry == null)
                    {
                        arrowPathGeometry = new SharpDX.Direct2D1.PathGeometry(Core.Globals.D2DFactory);
                        SharpDX.Direct2D1.GeometrySink geometrySink = arrowPathGeometry.Open();
                        float           arrowWidth = 6f;
                        SharpDX.Vector2 top        = new SharpDX.Vector2(0, outlineStroke.Width * 0.5f);

                        geometrySink.BeginFigure(top, SharpDX.Direct2D1.FigureBegin.Filled);
                        geometrySink.AddLine(new SharpDX.Vector2(arrowWidth, -arrowWidth));
                        geometrySink.AddLine(new SharpDX.Vector2(-arrowWidth, -arrowWidth));
                        geometrySink.AddLine(top);                        // cap off figure
                        geometrySink.EndFigure(SharpDX.Direct2D1.FigureEnd.Closed);
                        geometrySink.Close();
                    }

                    if (PathBegin == PathToolCapMode.Arrow)
                    {
                        Vector lineVector = points[0] - points[1];

                        lineVector.Normalize();

                        Point             pointAdjusted    = points[0] + pixelAdjustVec;
                        SharpDX.Vector2   pointVec         = pointAdjusted.ToVector2();
                        float             vectorAngle      = -(float)Math.Atan2(lineVector.X, lineVector.Y);
                        Vector            adjustVector     = lineVector * 5;
                        SharpDX.Vector2   arrowPointVec    = new SharpDX.Vector2((float)(pointVec.X + adjustVector.X), (float)(pointVec.Y + adjustVector.Y));
                        SharpDX.Matrix3x2 transformMatrix2 = SharpDX.Matrix3x2.Rotation(vectorAngle, SharpDX.Vector2.Zero) * SharpDX.Matrix3x2.Scaling((float)Math.Max(1.0f, outlineStroke.Width * .45) + 0.25f) * SharpDX.Matrix3x2.Translation(arrowPointVec);
                        RenderTarget.Transform = transformMatrix2;

                        RenderTarget.FillGeometry(arrowPathGeometry, tmpBrush);
                        RenderTarget.Transform = SharpDX.Matrix3x2.Identity;
                    }

                    if (PathEnd == PathToolCapMode.Arrow)
                    {
                        Vector lineVector = points[points.Length - 1] - points[points.Length - 2];

                        lineVector.Normalize();

                        Point             pointAdjusted    = points[points.Length - 1] + pixelAdjustVec;
                        SharpDX.Vector2   pointVec         = pointAdjusted.ToVector2();
                        float             vectorAngle      = -(float)Math.Atan2(lineVector.X, lineVector.Y);
                        Vector            adjustVector     = lineVector * 5;
                        SharpDX.Vector2   arrowPointVec    = new SharpDX.Vector2((float)(pointVec.X + adjustVector.X), (float)(pointVec.Y + adjustVector.Y));
                        SharpDX.Matrix3x2 transformMatrix2 = SharpDX.Matrix3x2.Rotation(vectorAngle, SharpDX.Vector2.Zero) * SharpDX.Matrix3x2.Scaling((float)Math.Max(1.0f, outlineStroke.Width * .45) + 0.25f) * SharpDX.Matrix3x2.Translation(arrowPointVec);
                        RenderTarget.Transform = transformMatrix2;

                        RenderTarget.FillGeometry(arrowPathGeometry, tmpBrush);

                        RenderTarget.Transform = SharpDX.Matrix3x2.Identity;
                    }
                }
            }

            if (ShowCount)
            {
                SimpleFont wpfFont = chartControl.Properties.LabelFont ?? new SimpleFont();
                SharpDX.DirectWrite.TextFormat textFormat = wpfFont.ToDirectWriteTextFormat();
                textFormat.TextAlignment = SharpDX.DirectWrite.TextAlignment.Leading;
                textFormat.WordWrapping  = SharpDX.DirectWrite.WordWrapping.NoWrap;

                for (int i = 1; i < ChartAnchors.Count; i++)
                {
                    Point p  = ChartAnchors[i - 1].GetPoint(chartControl, chartPanel, chartScale);
                    Point p1 = ChartAnchors[i].GetPoint(chartControl, chartPanel, chartScale);

                    if (i + 1 < ChartAnchors.Count)
                    {
                        Point  p2 = ChartAnchors[i + 1].GetPoint(chartControl, chartPanel, chartScale);
                        Vector v1 = p - p1;

                        v1.Normalize();

                        Vector v2 = p2 - p1;

                        v2.Normalize();

                        Vector vector = v1 + v2;

                        vector.Normalize();

                        SharpDX.DirectWrite.TextLayout textLayout = new SharpDX.DirectWrite.TextLayout(Core.Globals.DirectWriteFactory, i.ToString(), textFormat, 250, textFormat.FontSize);
                        Point textPoint = p1 - vector * textFormat.FontSize;
                        textPoint.X -= textLayout.Metrics.Width / 2f;
                        textPoint.Y -= textLayout.Metrics.Height / 2f;

                        RenderTarget.DrawTextLayout((textPoint + pixelAdjustVec).ToVector2(), textLayout, outlineStroke.BrushDX, SharpDX.Direct2D1.DrawTextOptions.NoSnap);
                        textLayout.Dispose();
                    }
                    else
                    {
                        SharpDX.DirectWrite.TextLayout textLayout = new SharpDX.DirectWrite.TextLayout(Core.Globals.DirectWriteFactory, i.ToString(), textFormat, 250, textFormat.FontSize);
                        Vector vector = (p - p1);

                        vector.Normalize();

                        Point textPoint = p1 - vector * textFormat.FontSize;
                        textPoint.X -= textLayout.Metrics.Width / 2f;
                        textPoint.Y -= textLayout.Metrics.Height / 2f;

                        RenderTarget.DrawTextLayout((textPoint + pixelAdjustVec).ToVector2(), textLayout, outlineStroke.BrushDX, SharpDX.Direct2D1.DrawTextOptions.NoSnap);
                        textLayout.Dispose();
                    }
                }

                textFormat.Dispose();
            }
        }
Exemplo n.º 30
0
 public CurrentPriceMarker CurrentPriceMarker(SimpleFont font, Brush priceLineColor, Brush priceTextColor, Brush priceAreaColor, int priceLineLength, int priceLineWidth, DashStyleHelper priceLineStyle, double priceLineOpacity)
 {
     return(CurrentPriceMarker(Input, font, priceLineColor, priceTextColor, priceAreaColor, priceLineLength, priceLineWidth, priceLineStyle, priceLineOpacity));
 }