public void UpTrend_Wrong_Period_Return_False() { var context = new TestCandlesContext() .WithCandleIndex(3); var upTrendPattern = new UpTrend(); var match = upTrendPattern.Match(context); Assert.False(match.Success); }
public void Is_UpTrend_Test() { var context = new TestCandlesContext() .WithUpTrend() .WithCandleIndex(3); var upTrendPattern = new UpTrend(); var match = upTrendPattern.Match(context); Assert.True(match.Success, "Candles create an UpTrend pattern"); }
public CandlePatternMatch Match(IAnalyzableContext analyzableContext) { var candle = analyzableContext.TimeBarAtIndex; if (candle.Open == candle.Close) { return(CandlePatternMatch.NoMatch); } var upTrendContext = new CandlestickContext(analyzableContext.TimeBars, analyzableContext.TimeBarIndexToAnalyze - 1); var isUptrendMatch = upTrendPatter.Match(upTrendContext); if (!isUptrendMatch.Success) { return(CandlePatternMatch.NoMatch); } var sizeFromHighToLow = candle.SizeFromHighToLow(); var isHammer = sizeFromHighToLow > RealBodyMultiplier *candle.RealBody() && candle.LowerShadow() / (Treshold + sizeFromHighToLow) < LowerWickLengthRatio; return(new CandlePatternMatch(isHammer, true)); }