public static bool isCandleOver(this MarketSeries marketSeries, int index, double frontier) { int count = marketSeries.Bars(); if (index >= 0 && index < count) { return(frontier.between(marketSeries.Low[count - 1 - index], marketSeries.High[count - 1 - index])); } else { throw new ArgumentException(string.Format("Valeur de l'indice {0} en dehors des valeurs permises", index)); } }
public static bool isCandleBelow(this MarketSeries marketSeries, int index, double limit) { int count = marketSeries.Bars(); if (index >= 0 && index < count) { return(marketSeries.High[count - 1 - index] <= limit); } else { throw new ArgumentException(string.Format("Valeur de l'indice {0} en dehors des valeurs permises", index)); } }
/// <summary> /// S = S0 + V0t +(at^2)/2 a = (2*(S-S0))/t^2. /// v = v0 +at /// </summary> /// <param name="index"></param> public override void Calculate(int index) { double high = MarketSeries.High[index]; double previewHigh = MarketSeries.High[index - NumberOfCandle]; double actualPriceOrHigh = (MarketSeries.Bars() - 1) == index?Symbol.Mid() : high; double low = MarketSeries.Low[index]; double previewLow = MarketSeries.Low[index - NumberOfCandle]; double actualPriceOrLow = (MarketSeries.Bars() - 1) == index?Symbol.Mid() : low; double highAcceleration = (2 * (high - previewHigh) / Math.Pow(_elapsedTime, 2)) * Math.Pow(10, 2 * Symbol.Digits); double lowAcceleration = (2 * (low - previewLow) / Math.Pow(_elapsedTime, 2)) * Math.Pow(10, 2 * Symbol.Digits); HighAccelerationSeries[index] = highAcceleration; LowAccelerationSeries[index] = lowAcceleration; MovingAverageSeries[index] = _movingAverage.Result[index]; // Print("{0} {1} {2} {3} {4}",highAcceleration, lowAcceleration, elapsedTime, MarketSeries.Bars()-1, index); }
public static bool?isBullCandle(this MarketSeries marketSeries, int index) { int count = marketSeries.Bars(); if (index >= 0 && index < count) { double open = marketSeries.Open[index]; double close = marketSeries.Close[index]; double median = marketSeries.Median[index]; double variation; if (double.IsNaN(close)) { variation = median - open; } else { variation = close - open; } if (variation > 0) { return(true); } else if (variation < 0) { return(false); } else { return(null); } } else { throw new ArgumentException(string.Format("Valeur de l'indice {0} en dehors des valeurs permises", index)); } }
private string GetBreak(int index) { string br = null; int sub = 0; int initmax = 0; int t1 = 0; int t2 = 0; int t3 = 0; int t4 = 0; int t5 = 0; int bars = MarketSeries.Bars(); int per = AveragePeriods * 10; if (bars < AveragePeriods * 10) { per = bars; } double maxbar = _mas.Result.Maximum(per); double minbar = _mas.Result.Minimum(per); double getmax = Math.Round(maxbar > Math.Abs(minbar) ? maxbar : Math.Abs(minbar)); if (getmax < 100) { sub = 10; initmax = 100; } else if (getmax < 150) { sub = 15; initmax = 150; } else if (getmax < 200) { sub = 20; initmax = 200; } else if (getmax < 250) { sub = 25; initmax = 250; } else if (getmax < 300) { sub = 30; initmax = 300; } else if (getmax < 350) { sub = 35; initmax = 350; } else if (getmax < 400) { sub = 40; initmax = 400; } else { sub = 50; initmax = 500; } for (int i = ((bars > AveragePeriods * 10) ? (bars - AveragePeriods * 10) : 0); i < bars; i++) { var sr = Math.Abs(_mas.Result[i]); if (sr > initmax - sub * 0) { t5++; t4++; t3++; t2++; t1++; continue; } if (sr > initmax - sub * 1) { t4++; t3++; t2++; t1++; continue; } if (sr > initmax - sub * 2) { t3++; t2++; t1++; continue; } if (sr > initmax - sub * 3) { t2++; t1++; continue; } if (sr > initmax - sub * 4) { t1++; continue; } } br = "(" + Math.Round(150 / getmax, 3).ToString() + "-" + per.ToString() + "-" + getmax.ToString() + ")_(" + initmax.ToString() + "-" + sub.ToString() + ")_(" + (initmax - sub * 4).ToString() + "-" + t1.ToString() + ")_(" + (initmax - sub * 3).ToString() + "-" + t2.ToString() + ")_(" + (initmax - sub * 2).ToString() + "-" + t3.ToString() + ")_(" + (initmax - sub * 1).ToString() + "-" + t4.ToString() + ")_(" + (initmax - sub * 0).ToString() + "-" + t5.ToString() + ")"; return(br); }