protected override decimal Calculate(int index) { List <int> barsOfPreviousPeriod = _pivotPointIndicator.GetBarsOfPreviousPeriod(index); if (barsOfPreviousPeriod.isEmpty()) { return(Decimals.NaN); } IBar bar = TimeSeries.GetBar(barsOfPreviousPeriod[0]); decimal high = bar.MaxPrice; decimal low = bar.MinPrice; foreach (int i in barsOfPreviousPeriod) { high = (TimeSeries.GetBar(i).MaxPrice).Max(high); low = (TimeSeries.GetBar(i).MinPrice).Min(low); } if (_fibReversalType == FibReversalType.RESISTANCE) { return(_pivotPointIndicator.GetValue(index).Plus(_fibonacciFactor.MultipliedBy(high.Minus(low)))); } return(_pivotPointIndicator.GetValue(index).Minus(_fibonacciFactor.MultipliedBy(high.Minus(low)))); }
private decimal CalculateR3(List <int> barsOfPreviousPeriod, int index) { IBar bar = TimeSeries.GetBar(barsOfPreviousPeriod[0]); decimal low = bar.MinPrice; decimal high = bar.MaxPrice; foreach (int i in barsOfPreviousPeriod) { low = (TimeSeries.GetBar(i).MinPrice).Min(low); high = (TimeSeries.GetBar(i).MaxPrice).Max(high); } return(high.Plus(Decimals.TWO.MultipliedBy((_pivotPointIndicator.GetValue(index).Minus(low))))); }