public static double Deviation(IEnumerable <double> Values, DeviationType CalculationType) { double SumOfValuesSquared = 0; double SumOfValues = 0; var count = Values.Count(); //Calculate the sum of all the values foreach (double item in Values) { SumOfValues += item; } //Calculate the sum of all the values squared foreach (double item in Values) { SumOfValuesSquared += Math.Pow(item, 2); } if (CalculationType == DeviationType.Sample) { return(Math.Sqrt((SumOfValuesSquared - Math.Pow(SumOfValues, 2) / count) / (count - 1))); } else { return(Math.Sqrt((SumOfValuesSquared - Math.Pow(SumOfValues, 2) / count) / count)); } }
/// <summary> /// The ZigZag indicator shows trend lines filtering out changes below a defined level. /// </summary> /// <returns></returns> public ZigZagAqueGen ZigZagAqueGen(Data.IDataSeries input, DeviationType deviationType, double deviationValue, int procentOfChangePrice, bool useHighLow) { if (cacheZigZagAqueGen != null) { for (int idx = 0; idx < cacheZigZagAqueGen.Length; idx++) { if (cacheZigZagAqueGen[idx].DeviationType == deviationType && Math.Abs(cacheZigZagAqueGen[idx].DeviationValue - deviationValue) <= double.Epsilon && cacheZigZagAqueGen[idx].ProcentOfChangePrice == procentOfChangePrice && cacheZigZagAqueGen[idx].UseHighLow == useHighLow && cacheZigZagAqueGen[idx].EqualsInput(input)) { return(cacheZigZagAqueGen[idx]); } } } lock (checkZigZagAqueGen) { checkZigZagAqueGen.DeviationType = deviationType; deviationType = checkZigZagAqueGen.DeviationType; checkZigZagAqueGen.DeviationValue = deviationValue; deviationValue = checkZigZagAqueGen.DeviationValue; checkZigZagAqueGen.ProcentOfChangePrice = procentOfChangePrice; procentOfChangePrice = checkZigZagAqueGen.ProcentOfChangePrice; checkZigZagAqueGen.UseHighLow = useHighLow; useHighLow = checkZigZagAqueGen.UseHighLow; if (cacheZigZagAqueGen != null) { for (int idx = 0; idx < cacheZigZagAqueGen.Length; idx++) { if (cacheZigZagAqueGen[idx].DeviationType == deviationType && Math.Abs(cacheZigZagAqueGen[idx].DeviationValue - deviationValue) <= double.Epsilon && cacheZigZagAqueGen[idx].ProcentOfChangePrice == procentOfChangePrice && cacheZigZagAqueGen[idx].UseHighLow == useHighLow && cacheZigZagAqueGen[idx].EqualsInput(input)) { return(cacheZigZagAqueGen[idx]); } } } ZigZagAqueGen indicator = new ZigZagAqueGen(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.DeviationType = deviationType; indicator.DeviationValue = deviationValue; indicator.ProcentOfChangePrice = procentOfChangePrice; indicator.UseHighLow = useHighLow; Indicators.Add(indicator); indicator.SetUp(); ZigZagAqueGen[] tmp = new ZigZagAqueGen[cacheZigZagAqueGen == null ? 1 : cacheZigZagAqueGen.Length + 1]; if (cacheZigZagAqueGen != null) { cacheZigZagAqueGen.CopyTo(tmp, 0); } tmp[tmp.Length - 1] = indicator; cacheZigZagAqueGen = tmp; return(indicator); } }
public static double Deviation(double[] Values, DeviationType CalculationType, int pNumValues) { double SumOfValuesSquared = 0; double SumOfValues = 0; //Calculate the sum of all the values // foreach (double item in Values) for(int lIndex = 0; lIndex < pNumValues; lIndex++) SumOfValues += Values[lIndex]; //Calculate the sum of all the values squared // foreach (double item in Values) for (int lIndex = 0; lIndex < pNumValues; lIndex++) SumOfValuesSquared += Math.Pow(Values[lIndex], 2); double lSquareRootSum = 0; if (CalculationType == DeviationType.Sample) { lSquareRootSum = (SumOfValuesSquared - Math.Pow(SumOfValues, 2) / pNumValues) / (pNumValues - 1); } else { lSquareRootSum = (SumOfValuesSquared - Math.Pow(SumOfValues, 2) / pNumValues) / pNumValues; } if (lSquareRootSum < ProjectCommon.ProjectConstants.REAL_SMALL_DOUBLE_VALUE) return 0; else if (lSquareRootSum < ProjectCommon.ProjectConstants.SMALL_DOUBLE_VALUE) return ProjectCommon.ProjectConstants.SMALL_DOUBLE_VALUE; else return Math.Sqrt(lSquareRootSum); }
/// <summary> /// Extends the ZigZag indicator by showing the high, low lines and adds in a 38.2% plot above the low and below the top. /// </summary> /// <returns></returns> public Indicator.ZigZagFib ZigZagFib(Data.IDataSeries input, DeviationType deviationType, double deviationValue, bool useHighLow) { 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.ZigZagFib(input, deviationType, deviationValue, useHighLow)); }
/// <summary> /// The ZZZigZagDebug indicator shows trend lines filtering out changes below a defined level. /// </summary> /// <returns></returns> public ZZZigZagDebug ZZZigZagDebug(Data.IDataSeries input, DeviationType deviationType, double deviationValue, bool useHighLow) { if (cacheZZZigZagDebug != null) { for (int idx = 0; idx < cacheZZZigZagDebug.Length; idx++) { if (cacheZZZigZagDebug[idx].DeviationType == deviationType && Math.Abs(cacheZZZigZagDebug[idx].DeviationValue - deviationValue) <= double.Epsilon && cacheZZZigZagDebug[idx].UseHighLow == useHighLow && cacheZZZigZagDebug[idx].EqualsInput(input)) { return(cacheZZZigZagDebug[idx]); } } } lock (checkZZZigZagDebug) { checkZZZigZagDebug.DeviationType = deviationType; deviationType = checkZZZigZagDebug.DeviationType; checkZZZigZagDebug.DeviationValue = deviationValue; deviationValue = checkZZZigZagDebug.DeviationValue; checkZZZigZagDebug.UseHighLow = useHighLow; useHighLow = checkZZZigZagDebug.UseHighLow; if (cacheZZZigZagDebug != null) { for (int idx = 0; idx < cacheZZZigZagDebug.Length; idx++) { if (cacheZZZigZagDebug[idx].DeviationType == deviationType && Math.Abs(cacheZZZigZagDebug[idx].DeviationValue - deviationValue) <= double.Epsilon && cacheZZZigZagDebug[idx].UseHighLow == useHighLow && cacheZZZigZagDebug[idx].EqualsInput(input)) { return(cacheZZZigZagDebug[idx]); } } } ZZZigZagDebug indicator = new ZZZigZagDebug(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.DeviationType = deviationType; indicator.DeviationValue = deviationValue; indicator.UseHighLow = useHighLow; Indicators.Add(indicator); indicator.SetUp(); ZZZigZagDebug[] tmp = new ZZZigZagDebug[cacheZZZigZagDebug == null ? 1 : cacheZZZigZagDebug.Length + 1]; if (cacheZZZigZagDebug != null) { cacheZZZigZagDebug.CopyTo(tmp, 0); } tmp[tmp.Length - 1] = indicator; cacheZZZigZagDebug = tmp; return(indicator); } }
public ZigZag(double tickSize, DataSeries zigZagHighZigZags, DataSeries zigZagLowZigZags, DataSeries zigZagHighSeries, DataSeries zigZagLowSeries , DeviationType deviationType, double deviationValue, bool useHighLow) { _tickSize = tickSize; _zigZagHighZigZags = zigZagHighZigZags; _zigZagLowZigZags = zigZagLowZigZags; _zigZagHighSeries = zigZagHighSeries; _zigZagLowSeries = zigZagLowSeries; _deviationType = deviationType; _deviationValue = deviationValue; _useHighLow = useHighLow; }
public ZigZag ZigZag(ISeries <double> input, DeviationType deviationType, double deviationValue, bool useHighLow) { if (cacheZigZag != null) { for (int idx = 0; idx < cacheZigZag.Length; idx++) { if (cacheZigZag[idx] != null && cacheZigZag[idx].DeviationType == deviationType && cacheZigZag[idx].DeviationValue == deviationValue && cacheZigZag[idx].UseHighLow == useHighLow && cacheZigZag[idx].EqualsInput(input)) { return(cacheZigZag[idx]); } } } return(CacheIndicator <ZigZag>(new ZigZag() { DeviationType = deviationType, DeviationValue = deviationValue, UseHighLow = useHighLow }, input, ref cacheZigZag)); }
public static double Deviation(double[] Values, DeviationType CalculationType, int pNumValues) { double SumOfValuesSquared = 0; double SumOfValues = 0; //Calculate the sum of all the values // foreach (double item in Values) for (int lIndex = 0; lIndex < pNumValues; lIndex++) { SumOfValues += Values[lIndex]; } //Calculate the sum of all the values squared // foreach (double item in Values) for (int lIndex = 0; lIndex < pNumValues; lIndex++) { SumOfValuesSquared += Math.Pow(Values[lIndex], 2); } double lSquareRootSum = 0; if (CalculationType == DeviationType.Sample) { lSquareRootSum = (SumOfValuesSquared - Math.Pow(SumOfValues, 2) / pNumValues) / (pNumValues - 1); } else { lSquareRootSum = (SumOfValuesSquared - Math.Pow(SumOfValues, 2) / pNumValues) / pNumValues; } if (lSquareRootSum < ProjectCommon.ProjectConstants.REAL_SMALL_DOUBLE_VALUE) { return(0); } else if (lSquareRootSum < ProjectCommon.ProjectConstants.SMALL_DOUBLE_VALUE) { return(ProjectCommon.ProjectConstants.SMALL_DOUBLE_VALUE); } else { return(Math.Sqrt(lSquareRootSum)); } }
public override IEnumerable <Argument> GetArguments() { List <Argument> args = new List <Argument>(); args.Add(ArgumentHelper.ArgumentFactory(nameof(GroupMean), GroupMean)); args.Add(ArgumentHelper.ArgumentFactory(nameof(DeviationType), DeviationType.ToString())); args.Add(ArgumentHelper.ArgumentFactory(nameof(StandardDeviation), StandardDeviation)); args.Add(ArgumentHelper.ArgumentFactory(nameof(Variance), Variance)); args.Add(ArgumentHelper.ArgumentFactory(nameof(Significance), Significance)); args.Add(ArgumentHelper.ArgumentFactory(nameof(ChangeType), ChangeType.ToString())); args.Add(ArgumentHelper.ArgumentFactory(nameof(PercentChange), PercentChange)); args.Add(ArgumentHelper.ArgumentFactory(nameof(AbsoluteChange), AbsoluteChange)); args.Add(ArgumentHelper.ArgumentFactory(nameof(PlottingRangeType), PlottingRangeType.ToString())); args.Add(ArgumentHelper.ArgumentFactory(nameof(SampleSizeFrom), SampleSizeFrom)); args.Add(ArgumentHelper.ArgumentFactory(nameof(SampleSizeTo), SampleSizeTo)); args.Add(ArgumentHelper.ArgumentFactory(nameof(PowerFrom), PowerFrom)); args.Add(ArgumentHelper.ArgumentFactory(nameof(PowerTo), PowerTo)); args.Add(ArgumentHelper.ArgumentFactory(nameof(GraphTitle), GraphTitle)); return(args); }
public static double Deviation(double[] Values, DeviationType CalculationType) { double SumOfValuesSquared = 0; double SumOfValues = 0; //Calculate the sum of all the values foreach (double item in Values) { SumOfValues += item; } //Calculate the sum of all the values squared foreach (double item in Values) { SumOfValuesSquared += Math.Pow(item, 2); } if (CalculationType == DeviationType.Sample) { return(Math.Sqrt((SumOfValuesSquared - Math.Pow(SumOfValues, 2) / Values.Length) / (Values.Length - 1))); } else { return(Math.Sqrt((SumOfValuesSquared - Math.Pow(SumOfValues, 2) / Values.Length) / Values.Length)); } }
public Indicator.ZigZagAqueGen ZigZagAqueGen(DeviationType deviationType, double deviationValue, int procentOfChangePrice, bool useHighLow) { return(_indicator.ZigZagAqueGen(Input, deviationType, deviationValue, procentOfChangePrice, useHighLow)); }
/// <summary> /// Filters the surges in a sequence whose absolute values deviate from the specified positive value by a /// positive factor specified. /// </summary> /// <typeparam name="T">The type of elements in the incoming sequence.</typeparam> /// <typeparam name="C">The calculator for the sequence elements type.</typeparam> /// <param name="sequence">A calling sequence object.</param> /// <param name="centerValue">A nonnegative value. Sequence elements that deviate from this value by more than <paramref name="allowedDeviationFactor"/> will be filtered out.</param> /// <param name="allowedDeviationFactor">The allowed factor of absolute deviation.</param> /// <param name="deviationType"> /// If deviation type is Downwards, values which are smaller than <paramref name="centerValue"/> /// by a factor of <paramref name="allowedDeviationFactor"/> will be filtered. /// If deviation type is Upwards, values which are bigger than <paramref name="centerValue"/> /// by a factor of <paramref name="allowedDeviationFactor"/> will be filtered. /// If deviation type is EitherSide, all values that differ from the <paramref name="centerValue"/> /// by a factor of <paramref name="allowedDeviationFactor"/> will be filtered. /// </param> /// <param name="filteredValues">A reference to a collection to store the filtered values. May be null.</param> /// <returns>The list containing all incoming values except for the filtered ones.</returns> public static List <T> filterSurgesByAbsoluteFactorDeviationFromValue <T, C>(this IEnumerable <T> sequence, T centerValue, double allowedDeviationFactor, DeviationType deviationType = DeviationType.EitherSide, ICollection <T> filteredValues = null) where C : ICalc <T>, new() { ICalc <T> calc = Numeric <T, C> .Calculator; (centerValue > Numeric <T, C> .Zero).Assert(new ArgumentException("The center value specified should be positive.")); (allowedDeviationFactor > 0).Assert(new ArgumentException("The allowed deviation factor should be positive.")); List <T> result = new List <T>(); foreach (Numeric <T, C> current in sequence) { Numeric <T, C> absCurrent = WhiteMath <T, C> .Abs(current); Numeric <T, C> multipliedValue = (Numeric <T, C>)allowedDeviationFactor * centerValue; Numeric <T, C> multipliedCurrent = (Numeric <T, C>)allowedDeviationFactor * absCurrent; if (deviationType == DeviationType.EitherSide && (absCurrent > multipliedValue || multipliedCurrent < centerValue) || deviationType == DeviationType.Upwards && absCurrent > multipliedValue || deviationType == DeviationType.Downwards && multipliedCurrent < centerValue) { // Filter the surge. if (filteredValues != null) { filteredValues.Add(current); } } else { result.Add(current); } } return(result); }
/// <summary> /// Enter the description of your new custom indicator here /// </summary> /// <returns></returns> public AqueGenNinjaBot AqueGenNinjaBot(Data.IDataSeries input, int dayOfSMAValot, DeviationType deviationType, double deviationValue, bool isDiapasoned, int leftZigZag, int procentFromMiddleValot, double profitTarget, int rightZigZag, int sMAPeriod, double stopLoss, int updateAfterChangeZigZagProcent, bool useHighLow) { if (cacheAqueGenNinjaBot != null) { for (int idx = 0; idx < cacheAqueGenNinjaBot.Length; idx++) { if (cacheAqueGenNinjaBot[idx].DayOfSMAValot == dayOfSMAValot && cacheAqueGenNinjaBot[idx].DeviationType == deviationType && Math.Abs(cacheAqueGenNinjaBot[idx].DeviationValue - deviationValue) <= double.Epsilon && cacheAqueGenNinjaBot[idx].IsDiapasoned == isDiapasoned && cacheAqueGenNinjaBot[idx].LeftZigZag == leftZigZag && cacheAqueGenNinjaBot[idx].ProcentFromMiddleValot == procentFromMiddleValot && Math.Abs(cacheAqueGenNinjaBot[idx].ProfitTarget - profitTarget) <= double.Epsilon && cacheAqueGenNinjaBot[idx].RightZigZag == rightZigZag && cacheAqueGenNinjaBot[idx].SMAPeriod == sMAPeriod && Math.Abs(cacheAqueGenNinjaBot[idx].StopLoss - stopLoss) <= double.Epsilon && cacheAqueGenNinjaBot[idx].UpdateAfterChangeZigZagProcent == updateAfterChangeZigZagProcent && cacheAqueGenNinjaBot[idx].UseHighLow == useHighLow && cacheAqueGenNinjaBot[idx].EqualsInput(input)) { return(cacheAqueGenNinjaBot[idx]); } } } lock (checkAqueGenNinjaBot) { checkAqueGenNinjaBot.DayOfSMAValot = dayOfSMAValot; dayOfSMAValot = checkAqueGenNinjaBot.DayOfSMAValot; checkAqueGenNinjaBot.DeviationType = deviationType; deviationType = checkAqueGenNinjaBot.DeviationType; checkAqueGenNinjaBot.DeviationValue = deviationValue; deviationValue = checkAqueGenNinjaBot.DeviationValue; checkAqueGenNinjaBot.IsDiapasoned = isDiapasoned; isDiapasoned = checkAqueGenNinjaBot.IsDiapasoned; checkAqueGenNinjaBot.LeftZigZag = leftZigZag; leftZigZag = checkAqueGenNinjaBot.LeftZigZag; checkAqueGenNinjaBot.ProcentFromMiddleValot = procentFromMiddleValot; procentFromMiddleValot = checkAqueGenNinjaBot.ProcentFromMiddleValot; checkAqueGenNinjaBot.ProfitTarget = profitTarget; profitTarget = checkAqueGenNinjaBot.ProfitTarget; checkAqueGenNinjaBot.RightZigZag = rightZigZag; rightZigZag = checkAqueGenNinjaBot.RightZigZag; checkAqueGenNinjaBot.SMAPeriod = sMAPeriod; sMAPeriod = checkAqueGenNinjaBot.SMAPeriod; checkAqueGenNinjaBot.StopLoss = stopLoss; stopLoss = checkAqueGenNinjaBot.StopLoss; checkAqueGenNinjaBot.UpdateAfterChangeZigZagProcent = updateAfterChangeZigZagProcent; updateAfterChangeZigZagProcent = checkAqueGenNinjaBot.UpdateAfterChangeZigZagProcent; checkAqueGenNinjaBot.UseHighLow = useHighLow; useHighLow = checkAqueGenNinjaBot.UseHighLow; if (cacheAqueGenNinjaBot != null) { for (int idx = 0; idx < cacheAqueGenNinjaBot.Length; idx++) { if (cacheAqueGenNinjaBot[idx].DayOfSMAValot == dayOfSMAValot && cacheAqueGenNinjaBot[idx].DeviationType == deviationType && Math.Abs(cacheAqueGenNinjaBot[idx].DeviationValue - deviationValue) <= double.Epsilon && cacheAqueGenNinjaBot[idx].IsDiapasoned == isDiapasoned && cacheAqueGenNinjaBot[idx].LeftZigZag == leftZigZag && cacheAqueGenNinjaBot[idx].ProcentFromMiddleValot == procentFromMiddleValot && Math.Abs(cacheAqueGenNinjaBot[idx].ProfitTarget - profitTarget) <= double.Epsilon && cacheAqueGenNinjaBot[idx].RightZigZag == rightZigZag && cacheAqueGenNinjaBot[idx].SMAPeriod == sMAPeriod && Math.Abs(cacheAqueGenNinjaBot[idx].StopLoss - stopLoss) <= double.Epsilon && cacheAqueGenNinjaBot[idx].UpdateAfterChangeZigZagProcent == updateAfterChangeZigZagProcent && cacheAqueGenNinjaBot[idx].UseHighLow == useHighLow && cacheAqueGenNinjaBot[idx].EqualsInput(input)) { return(cacheAqueGenNinjaBot[idx]); } } } AqueGenNinjaBot indicator = new AqueGenNinjaBot(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.DayOfSMAValot = dayOfSMAValot; indicator.DeviationType = deviationType; indicator.DeviationValue = deviationValue; indicator.IsDiapasoned = isDiapasoned; indicator.LeftZigZag = leftZigZag; indicator.ProcentFromMiddleValot = procentFromMiddleValot; indicator.ProfitTarget = profitTarget; indicator.RightZigZag = rightZigZag; indicator.SMAPeriod = sMAPeriod; indicator.StopLoss = stopLoss; indicator.UpdateAfterChangeZigZagProcent = updateAfterChangeZigZagProcent; indicator.UseHighLow = useHighLow; Indicators.Add(indicator); indicator.SetUp(); AqueGenNinjaBot[] tmp = new AqueGenNinjaBot[cacheAqueGenNinjaBot == null ? 1 : cacheAqueGenNinjaBot.Length + 1]; if (cacheAqueGenNinjaBot != null) { cacheAqueGenNinjaBot.CopyTo(tmp, 0); } tmp[tmp.Length - 1] = indicator; cacheAqueGenNinjaBot = tmp; return(indicator); } }
/// <summary> /// Enter the description of your new custom indicator here /// </summary> /// <returns></returns> public AqueGenNinjaBot AqueGenNinjaBot(int dayOfSMAValot, DeviationType deviationType, double deviationValue, bool isDiapasoned, int leftZigZag, int procentFromMiddleValot, double profitTarget, int rightZigZag, int sMAPeriod, double stopLoss, int updateAfterChangeZigZagProcent, bool useHighLow) { return(AqueGenNinjaBot(Input, dayOfSMAValot, deviationType, deviationValue, isDiapasoned, leftZigZag, procentFromMiddleValot, profitTarget, rightZigZag, sMAPeriod, stopLoss, updateAfterChangeZigZagProcent, useHighLow)); }
/// <summary> /// Enter the description of your new custom indicator here /// </summary> /// <returns></returns> public Indicator.AqueGenNinjaBot AqueGenNinjaBot(Data.IDataSeries input, int dayOfSMAValot, DeviationType deviationType, double deviationValue, bool isDiapasoned, int leftZigZag, int procentFromMiddleValot, double profitTarget, int rightZigZag, int sMAPeriod, double stopLoss, int updateAfterChangeZigZagProcent, bool useHighLow) { 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.AqueGenNinjaBot(input, dayOfSMAValot, deviationType, deviationValue, isDiapasoned, leftZigZag, procentFromMiddleValot, profitTarget, rightZigZag, sMAPeriod, stopLoss, updateAfterChangeZigZagProcent, useHighLow)); }
/// <summary> /// Extends the ZigZag indicator by showing the high, low lines and adds in a 38.2% plot above the low and below the top. /// </summary> /// <returns></returns> public ZigZagFib ZigZagFib(DeviationType deviationType, double deviationValue, bool useHighLow) { return(ZigZagFib(Input, deviationType, deviationValue, useHighLow)); }
/// <summary> /// The ZZZigZagDebug indicator shows trend lines filtering out changes below a defined level. /// </summary> /// <returns></returns> public ZZZigZagDebug ZZZigZagDebug(Data.IDataSeries input, DeviationType deviationType, double deviationValue, bool useHighLow) { if (cacheZZZigZagDebug != null) for (int idx = 0; idx < cacheZZZigZagDebug.Length; idx++) if (cacheZZZigZagDebug[idx].DeviationType == deviationType && Math.Abs(cacheZZZigZagDebug[idx].DeviationValue - deviationValue) <= double.Epsilon && cacheZZZigZagDebug[idx].UseHighLow == useHighLow && cacheZZZigZagDebug[idx].EqualsInput(input)) return cacheZZZigZagDebug[idx]; lock (checkZZZigZagDebug) { checkZZZigZagDebug.DeviationType = deviationType; deviationType = checkZZZigZagDebug.DeviationType; checkZZZigZagDebug.DeviationValue = deviationValue; deviationValue = checkZZZigZagDebug.DeviationValue; checkZZZigZagDebug.UseHighLow = useHighLow; useHighLow = checkZZZigZagDebug.UseHighLow; if (cacheZZZigZagDebug != null) for (int idx = 0; idx < cacheZZZigZagDebug.Length; idx++) if (cacheZZZigZagDebug[idx].DeviationType == deviationType && Math.Abs(cacheZZZigZagDebug[idx].DeviationValue - deviationValue) <= double.Epsilon && cacheZZZigZagDebug[idx].UseHighLow == useHighLow && cacheZZZigZagDebug[idx].EqualsInput(input)) return cacheZZZigZagDebug[idx]; ZZZigZagDebug indicator = new ZZZigZagDebug(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.DeviationType = deviationType; indicator.DeviationValue = deviationValue; indicator.UseHighLow = useHighLow; Indicators.Add(indicator); indicator.SetUp(); ZZZigZagDebug[] tmp = new ZZZigZagDebug[cacheZZZigZagDebug == null ? 1 : cacheZZZigZagDebug.Length + 1]; if (cacheZZZigZagDebug != null) cacheZZZigZagDebug.CopyTo(tmp, 0); tmp[tmp.Length - 1] = indicator; cacheZZZigZagDebug = tmp; return indicator; } }
public Indicator.ZZZigZagDebug ZZZigZagDebug(DeviationType deviationType, double deviationValue, bool useHighLow) { return(_indicator.ZZZigZagDebug(Input, deviationType, deviationValue, useHighLow)); }
public Indicator.ZigZagFib ZigZagFib(DeviationType deviationType, double deviationValue, bool useHighLow) { return(_indicator.ZigZagFib(Input, deviationType, deviationValue, useHighLow)); }
public Indicators.ZigZag ZigZag(ISeries <double> input, DeviationType deviationType, double deviationValue, bool useHighLow) { return(indicator.ZigZag(input, deviationType, deviationValue, useHighLow)); }
/// <summary> /// Filters the surges in a sequence whose absolute values deviate from the specified positive value by a /// nonnegative value specified. /// </summary> /// <typeparam name="T">The type of elements in the incoming sequence.</typeparam> /// <typeparam name="C">The calculator for the sequence elements type.</typeparam> /// <param name="sequence">A calling sequence object.</param> /// <param name="centerValue">Some value. Sequence elements that deviate from this value by more than <paramref name="allowedEpsilon"/> will be filtered out.</param> /// <param name="allowedEpsilon">The allowed nonnegative value of deviation from <paramref name="centerValue"/>.</param> /// <param name="deviationType"> /// If deviation type is Downwards, values which are smaller than <paramref name="centerValue"/> /// by <paramref name="allowedEpsilon"/> will be filtered. /// If deviation type is Upwards, values which are bigger than <paramref name="centerValue"/> /// by <paramref name="allowedEpsilon"/> will be filtered. /// If deviation type is EitherSide, all values that differ from the <paramref name="centerValue"/> /// by <paramref name="allowedEpsilon"/> will be filtered. /// </param> /// <param name="filteredValues">A reference to a collection to store the filtered values. May be null.</param> /// <returns>The list containing all incoming values except for the filtered ones.</returns> public static List <T> filterSurgesByEpsilonDeviationFromValue <T, C>(this IEnumerable <T> sequence, T centerValue, T allowedEpsilon, DeviationType deviationType = DeviationType.EitherSide, ICollection <T> filteredValues = null) where C : ICalc <T>, new() { ICalc <T> calc = Numeric <T, C> .Calculator; (allowedEpsilon >= Numeric <T, C> .Zero).Assert(new ArgumentException("Allowed deviation epsilon should be a non-negative value.")); List <T> result = new List <T>(); foreach (Numeric <T, C> current in sequence) { if (deviationType == DeviationType.EitherSide && WhiteMath <T, C> .Abs(centerValue - current) < (Numeric <T, C>)allowedEpsilon || deviationType == DeviationType.Downwards && centerValue - current < allowedEpsilon || deviationType == DeviationType.Upwards && current - centerValue < allowedEpsilon) { result.Add(current); } else if (filteredValues != null) { filteredValues.Add(current); } } return(result); }
/// <summary> /// The ZZZigZagDebug indicator shows trend lines filtering out changes below a defined level. /// </summary> /// <returns></returns> public Indicator.ZZZigZagDebug ZZZigZagDebug(Data.IDataSeries input, DeviationType deviationType, double deviationValue, bool useHighLow) { return _indicator.ZZZigZagDebug(input, deviationType, deviationValue, useHighLow); }
/// <summary> /// The ZigZag indicator shows trend lines filtering out changes below a defined level. /// </summary> /// <returns></returns> public ZigZag ZigZag(DeviationType deviationType, double deviationValue, bool useHighLow) { return ZigZag(Input, deviationType, deviationValue, useHighLow); }
/// <summary> /// Extends the ZigZag indicator by showing the high, low lines and adds in a 38.2% plot above the low and below the top. /// </summary> /// <returns></returns> public Indicator.ZigZagFib ZigZagFib(Data.IDataSeries input, DeviationType deviationType, double deviationValue, bool useHighLow) { return(_indicator.ZigZagFib(input, deviationType, deviationValue, useHighLow)); }
public Indicator.ZZZigZagDebug ZZZigZagDebug(DeviationType deviationType, double deviationValue, bool useHighLow) { return _indicator.ZZZigZagDebug(Input, deviationType, deviationValue, useHighLow); }
/// <summary> /// The ZZZigZagDebug indicator shows trend lines filtering out changes below a defined level. /// </summary> /// <returns></returns> public Indicator.ZZZigZagDebug ZZZigZagDebug(Data.IDataSeries input, DeviationType deviationType, double deviationValue, bool useHighLow) { 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.ZZZigZagDebug(input, deviationType, deviationValue, useHighLow); }
/// <summary> /// Adds relative (factor) surges from a symmetric distribution random generator to each value of a numeric sequence /// and returns the nosiy sequence in the form of a list. /// </summary> /// <typeparam name="T">The type of elements in the numeric sequence.</typeparam> /// <typeparam name="C">The calculator for the <typeparamref name="T"/> type.</typeparam> /// <param name="sequence">The calling numeric sequence object.</param> /// <param name="symmetricDistributionGenerator">A random generator providing values of some symmetric distribution.</param> /// <param name="deviationType">Which deviations (positive, negative or both) should be added to the sequence.</param> /// <returns></returns> public static List <T> addRelativeSurgesFromSymmetricDistribution <T, C>(this IEnumerable <T> sequence, IRandomUnbounded <T> symmetricDistributionGenerator, DeviationType deviationType) where C : ICalc <T>, new() { List <T> result = new List <T>(sequence.Count()); foreach (Numeric <T, C> value in sequence) { if (deviationType == DeviationType.EitherSide) { result.Add(value + value * symmetricDistributionGenerator.Next()); } else if (deviationType == DeviationType.Downwards) { result.Add(value - WhiteMath <T, C> .Abs(value * symmetricDistributionGenerator.Next())); } else { result.Add(value + WhiteMath <T, C> .Abs(value * symmetricDistributionGenerator.Next())); } } return(result); }