Exemple #1
0
        public void Calculate(PriceActionSwingClass priceActionSwingClass)
        {
            currentCalculationData = OnCalculationRequest(priceActionSwingClass);

            if (currentCalculationData.isNewMatrixPoints)
            {
                AddOrUpdateIfNewMatrixPoints(currentCalculationData);
            }
        }
 protected override CalculationData OnCalculationRequest(PriceActionSwingClass priceActionSwingClass)
 {
     /*
      * MatrixPoints matrixPoints = new MatrixPoints(MatrixPoints.WhichGraphicPatternType.Trend);
      *
      * bool isNewMatrixPoints = true;
      *
      * if(priceActionSwingClass.GetPoint(3) == null)
      * {
      *  return new CalculationData(false);
      * }
      *
      * matrixPoints.AddPoint(priceActionSwingClass.GetPoint(0));
      * matrixPoints.AddPoint(priceActionSwingClass.GetPoint(1));
      * matrixPoints.AddPoint(priceActionSwingClass.GetPoint(2));
      * matrixPoints.AddPoint(priceActionSwingClass.GetPoint(3));
      *
      * if (matrixPoints.PointsList[3].CurrentSideSwing == Point.SidePoint.Low)
      * {
      *  isNewMatrixPoints = matrixPoints.PointsList[3].Price < matrixPoints.PointsList[1].Price &&
      *                      matrixPoints.PointsList[2].Price < matrixPoints.PointsList[0].Price;
      * }
      * else if(matrixPoints.PointsList[3].CurrentSideSwing == Point.SidePoint.High)
      * {
      *  isNewMatrixPoints = matrixPoints.PointsList[3].Price > matrixPoints.PointsList[1].Price &&
      *                      matrixPoints.PointsList[2].Price > matrixPoints.PointsList[0].Price;
      * }
      *
      * if (isNewMatrixPoints)
      * {
      *  if (matrixPoints.PointsList[3].CurrentSideSwing == Point.SidePoint.Low)
      *  {
      *      matrixPoints.TrendSideSignal = MatrixPoints.WhichTrendSideSignal.Bullish;
      *  }
      *  else if (matrixPoints.PointsList[3].CurrentSideSwing == Point.SidePoint.High)
      *  {
      *      matrixPoints.TrendSideSignal = MatrixPoints.WhichTrendSideSignal.Bearish;
      *  }
      * }
      *
      * return isNewMatrixPoints == true ? new CalculationData(true, matrixPoints) : new CalculationData(false);
      */
     return(new CalculationData());
 }
Exemple #3
0
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description              = @"Enter the description for your new custom Indicator here.";
                Name                     = "Price Action Swing";
                Calculate                = Calculate.OnEachTick;
                IsOverlay                = true;
                DisplayInDataBox         = true;
                DrawOnPricePanel         = true;
                DrawHorizontalGridLines  = false;
                DrawVerticalGridLines    = false;
                PaintPriceMarkers        = true;
                ScaleJustification       = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                IsSuspendedWhileInactive = true;

                CalculationType = CalculationTypeList.SwingForward;
                Strength        = 2;
                UseHighLow      = true;
                ShowPoints      = true;
                ShowLines       = true;

                DotParameters = new DotExpandableParameters()
                {
                    IsDotAutoScale      = true,
                    UpDotColor          = Brushes.Green,
                    DowDotColor         = Brushes.Red,
                    UpDotOutlineColor   = Brushes.Green,
                    DownDotOutlineColor = Brushes.Red
                };
            }
            else if (State == State.Configure)
            {
                drawingProperties = new DrawingProperties(DotParameters.IsDotAutoScale, DotParameters.UpDotColor, DotParameters.DowDotColor, DotParameters.UpDotOutlineColor, DotParameters.DownDotOutlineColor,
                                                          true, 15, Brushes.White, new Gui.Tools.SimpleFont("Arial", 11), TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 100,
                                                          true, Brushes.White, Gui.DashStyleHelper.Solid, 1);
                priceActionSwing = new PriceActionSwingClass(this, drawingProperties, CalculationType, Strength, UseHighLow, ShowPoints, ShowLines);


                // Everytime the F5 key is pressed automatically will clear the output window.
                // LogPrinter.ResetOuputTabs();
            }
        }
Exemple #4
0
        // Initialization

        public DowTheoryClass(NinjaScriptBase owner, DrawingProperties drawingProperties, CalculationTypeListDowTheory calculationTypeListDT,
                              CalculationTypeList calculationTypeListPCW, double strength, bool useHighLow, bool showPoints, bool showLines,
                              double maxPercentOfPivotRetraction, double minPercentOfPivotRetraction)
        {
            this.owner             = owner;
            this.drawingProperties = drawingProperties;
            CalculationType        = calculationTypeListDT;

            priceActionSwingClass = new PriceActionSwingClass(owner, drawingProperties, calculationTypeListPCW, strength,
                                                              useHighLow, showPoints, showLines);
            trendCalculation = new TrendCalculation(owner);
            pivotCalculation = new PivotCalculation(owner, maxPercentOfPivotRetraction, minPercentOfPivotRetraction);

            /*
             * if (!ShowLog)
             * {
             *  logPrinter.SetIndicatorAsInvisible(owner);
             * }
             */
        }
Exemple #5
0
        // Protected (methods)

        protected abstract CalculationData OnCalculationRequest(PriceActionSwingClass priceActionSwingClass);
        protected override CalculationData OnCalculationRequest(PriceActionSwingClass priceActionSwingClass)
        {
            if (priceActionSwingClass.GetPoint(3) == null)
            {
                return(new CalculationData());
            }

            pointsList.Clear();
            isNewPivot = false;

            //----Bearish----|---Bullish---
            //----3----------|----------0--
            //-----\---1-----|-----2---/---
            //------\-/-\----|----/-\-/----
            //-------2---\---|---/---1-----
            //------------0--|--3----------

            pointsList.Add(priceActionSwingClass.GetPoint(0)); // Last point or   pointsList[0]
            pointsList.Add(priceActionSwingClass.GetPoint(1)); // 1 point ago or  pointsList[1]
            pointsList.Add(priceActionSwingClass.GetPoint(2)); // 2 points ago or pointsList[2]
            pointsList.Add(priceActionSwingClass.GetPoint(3)); // 3 points ago or pointsList[3]

            // Test a long pivot
            if ((pointsList[3].CurrentSideSwing == Point.SidePoint.Low && whichTrend != MatrixPoints.WhichTrendSideSignal.Bullish) ||
                (pointsList[3].CurrentSideSwing == Point.SidePoint.Low && IsNewMatrixTheSameTheLastOne(pointsList)))
            {
                bool isLongPivot = pointsList[3].Price < pointsList[1].Price &&
                                   pointsList[2].Price < pointsList[0].Price;

                bool isBetweenLongPercentRetracement = IsLowerThanMaxPercentPivotRetracement(pointsList,
                                                                                             maxPercentOfPivotRetraction,
                                                                                             MatrixPoints.WhichTrendSideSignal.Bullish) &&
                                                       IsHigherThanMinPercentPivotRetracement(pointsList,
                                                                                              minPercentOfPivotRetraction,
                                                                                              MatrixPoints.WhichTrendSideSignal.Bullish);

                isNewPivot = isLongPivot && isBetweenLongPercentRetracement;

                if (isNewPivot)
                {
                    whichTrend = MatrixPoints.WhichTrendSideSignal.Bullish;
                }
            }
            // Test a short pivot
            else if ((pointsList[3].CurrentSideSwing == Point.SidePoint.High && whichTrend != MatrixPoints.WhichTrendSideSignal.Bearish) ||
                     (pointsList[3].CurrentSideSwing == Point.SidePoint.High && IsNewMatrixTheSameTheLastOne(pointsList)))
            {
                bool isShortPivot = pointsList[3].Price > pointsList[1].Price &&
                                    pointsList[2].Price > pointsList[0].Price;

                bool isBetweenShortPercentRetracement = IsLowerThanMaxPercentPivotRetracement(pointsList,
                                                                                              maxPercentOfPivotRetraction,
                                                                                              MatrixPoints.WhichTrendSideSignal.Bearish) &&
                                                        IsHigherThanMinPercentPivotRetracement(pointsList,
                                                                                               minPercentOfPivotRetraction,
                                                                                               MatrixPoints.WhichTrendSideSignal.Bearish);

                isNewPivot = isShortPivot && isBetweenShortPercentRetracement;

                if (isNewPivot)
                {
                    whichTrend = MatrixPoints.WhichTrendSideSignal.Bearish;
                }
            }

            return(isNewPivot == true ? new CalculationData(pointsList, whichTrend, MatrixPoints.WhichGraphicPatternType.Pivot) :
                   new CalculationData());
        }