Skip to content

Instantly share code, notes, and snippets.

@samuelbreezey
Last active August 28, 2019 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samuelbreezey/adb395214508d9e22b831f5001e5c0bc to your computer and use it in GitHub Desktop.
Save samuelbreezey/adb395214508d9e22b831f5001e5c0bc to your computer and use it in GitHub Desktop.
Inside Bar Pattern Indicator
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
public class InsideBarPatternRecognition : Indicator
{
[Output("Up Point", LineColor = "#FFA500", PlotType = PlotType.Points, Thickness = 5)]
public IndicatorDataSeries UpPoint { get; set; }
[Output("Down Point", LineColor = "#FFA500", PlotType = PlotType.Points, Thickness = 5)]
public IndicatorDataSeries DownPoint { get; set; }
public override void Calculate(int index)
{
var motherCandleHigh = MarketSeries.High.Last(2);
var motherCandleLow = MarketSeries.Low.Last(2);
var motherCandleOpen = MarketSeries.Open.Last(2);
var motherCandleClose = MarketSeries.Close.Last(2);
var childCandleHigh = MarketSeries.High.Last(1);
var childCandleLow = MarketSeries.Low.Last(1);
var childCandleOpen = MarketSeries.Open.Last(1);
var childCandleClose = MarketSeries.Close.Last(1);
if (childCandleHigh < motherCandleHigh && childCandleLow > motherCandleLow && Math.Abs(motherCandleOpen - motherCandleClose) > Math.Abs(childCandleOpen - childCandleClose))
DrawPoint(index);
}
// Draws a point next to the parent bar
private void DrawPoint(int index)
{
UpPoint[index - 1] = MarketSeries.High[index - 1] + 0.0005;
DownPoint[index - 1] = MarketSeries.Low[index - 1] - 0.0005;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment