Description
Indicators says how much distance price is there from the top bar. Pretty simple calculation (Top - Price)
But, when you add that to 100 period distance comparison you will get to know when it has hit the bottom and when it has hit the top. This will help identifying double bottom patterns even when close price is not crossing Bollinger Bands Bottom.
To make it simple:
1. Buy when Blue line of distance has just left the top green line.
2. Sell when Blue line of distance has just left the bottom red line.
I also have a similar one with Bottom Distance - which is not exactly the opposite of Top distance. I will be posting that one as well.
Combine this with BB crossing time, BB Squeeze Bulge to get better results.
Also check my other BB related indicators
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class BBTopDistance : Indicator
{
[Parameter("Period", DefaultValue = 20)]
public int Period { get; set; }
[Parameter("SD Weight Coef", DefaultValue = 2)]
public double K { get; set; }
[Parameter("MA Type", DefaultValue = MovingAverageType.Simple)]
public MovingAverageType MaType { get; set; }
[Parameter("High/Low Period", DefaultValue = 20)]
public int HighLowPeriod { get; set; }
[Parameter()]
public DataSeries Source { get; set; }
private BollingerBands _bollingerBands;
[Output("HighDistance", LineColor = "blue", Thickness = 1)]
public IndicatorDataSeries Distance { get; set; }
[Output("Low", LineColor = "red", Thickness = 3)]
public IndicatorDataSeries Low { get; set; }
[Output("High", LineColor = "green", Thickness = 3)]
public IndicatorDataSeries High { get; set; }
protected override void Initialize()
{
_bollingerBands = Indicators.BollingerBands(Source, Period, K, MaType);
}
public override void Calculate(int index)
{
Distance[index] = (_bollingerBands.Top[index] - Bars.ClosePrices[index]);
int backCalculationIndex = Math.Min(HighLowPeriod, Distance.Count);
High[index] = Low[index] = Distance[index];
for (int i = 0; i < backCalculationIndex; i++)
{
High[index] = (Distance[index - i] > High[index]) ? Distance[index - i] : High[index];
Low[index] = (Distance[index - i] < Low[index]) ? Distance[index - i] : Low[index];
}
}
}
}
voldemort
Joined on 10.07.2020
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: BBTopDistance.algo
- Rating: 0
- Installs: 1822
- Modified: 13/10/2021 09:54