Category Oscilators  Published on 21/11/2023

DRKHASHIX Similar candle color

Description

"To download the extraordinary Dr. khashix, please visit the drkhashix.com."

"Vittaverse is the best broker for bot and traid; they support a variety of currencies, have low spreads, and most importantly, provide you with funding." 

this is link: click here for sign up Vittaverse 

indicator Explanation:

The "Similarcandlecolor" indicator is designed to identify consecutive candles of the same color (green or red) and generate buy or sell signals based on a specified count of similar candles. Here's how it works:

Buy Signal:

  • It looks for a sequence of consecutive green candles.
  • When the specified count of consecutive green candles is reached, a buy signal is generated.
  • The buy signal is marked on the chart with a white point.

Sell Signal:

  • It looks for a sequence of consecutive red candles.
  • When the specified count of consecutive red candles is reached, a sell signal is generated.
  • The sell signal is marked on the chart with a royal blue point.

How to Use:

Parameters:

  • Candles Count: This parameter determines the number of consecutive candles to consider for generating a signal.
    • For example, if set to 1, the indicator looks for three consecutive candles of the same color to generate a signal.

Interpreting Signals:

  • When a white point appears, it indicates a potential buy signal.
  • When a royal blue point appears, it indicates a potential sell signal.

Example Usage:

Suppose you have the indicator attached to your chart with the default settings. If you see three consecutive green candles, a white point will appear, suggesting a potential buy signal. Conversely, if three consecutive red candles appear, a royal blue point will indicate a potential sell signal.

Note:

  • This indicator is based on the assumption that consecutive candles of the same color may indicate a trend or momentum in the market.

Feel free to adjust the "Candles Count" parameter based on your trading strategy and preferences. Additionally, consider using this indicator in conjunction with other analysis tools for a comprehensive trading decision.

"I aim to use the Heikin Ashi indicator in my trading charts. Although I haven't achieved success yet, I hope my colleagues can reach this goal. By implementing the Heikin Ashi strategy and incorporating shadow analysis for robot, I believe we can accomplish our objectives.

 Best regards, Dr.khashix."


using System;
using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class Similarcandlecolor : Indicator
    {
        public enum Signals
        {
            None,
            Buy,
            Sell
        }

        [Parameter("Candles Count", DefaultValue = 3)]
        public int CandlesCount { get; set; }

        [Output("Buy", Color = Colors.White, Thickness = 7, PlotType = PlotType.Points)]
        public IndicatorDataSeries BuyIndicator { get; set; }

        [Output("Sell", Color = Colors.RoyalBlue, Thickness = 7, PlotType = PlotType.Points)]
        public IndicatorDataSeries SellIndicator { get; set; }

        private Signals lastSignal = Signals.None;
        private int consecutiveGreenCandles = 0;
        private int consecutiveRedCandles = 0;

        public override void Calculate(int index)
        {
            if (index < CandlesCount)
                return;

            if (IsGreenCandles(index))
            {
                consecutiveGreenCandles++;

                if (consecutiveGreenCandles == CandlesCount && lastSignal != Signals.Buy)
                {
                    BuyIndicator[index] = MarketSeries.Low[index] - Symbol.PipSize;
                    lastSignal = Signals.Buy;
                    SellIndicator[index] = double.NaN;
                }
                else
                {
                    SellIndicator[index] = double.NaN;
                }

                consecutiveRedCandles = 0;
            }
            else if (IsRedCandles(index))
            {
                consecutiveRedCandles++;

                if (consecutiveRedCandles == CandlesCount && lastSignal != Signals.Sell)
                {
                    SellIndicator[index] = MarketSeries.High[index] + Symbol.PipSize;
                    lastSignal = Signals.Sell;
                    BuyIndicator[index] = double.NaN;
                }
                else
                {
                    BuyIndicator[index] = double.NaN;
                }

                consecutiveGreenCandles = 0;
            }
            else
            {
                consecutiveGreenCandles = 0;
                consecutiveRedCandles = 0;
                BuyIndicator[index] = double.NaN;
                SellIndicator[index] = double.NaN;
            }
        }

        private bool IsGreenCandles(int index)
        {
            return MarketSeries.Close[index - 2] < MarketSeries.Close[index - 1] &&
                   MarketSeries.Close[index - 1] < MarketSeries.Close[index] &&
                   MarketSeries.Close[index - 2] > MarketSeries.Open[index - 2] &&
                   MarketSeries.Close[index - 1] > MarketSeries.Open[index - 1] &&
                   MarketSeries.Close[index] > MarketSeries.Open[index];
        }

        private bool IsRedCandles(int index)
        {
            return MarketSeries.Close[index - 2] > MarketSeries.Close[index - 1] &&
                   MarketSeries.Close[index - 1] > MarketSeries.Close[index] &&
                   MarketSeries.Close[index - 2] < MarketSeries.Open[index - 2] &&
                   MarketSeries.Close[index - 1] < MarketSeries.Open[index - 1] &&
                   MarketSeries.Close[index] < MarketSeries.Open[index];
        }
    }
}


drkhashix's avatar
drkhashix

Joined on 12.02.2023

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: Similar candle color.algo
  • Rating: 5
  • Installs: 539
  • Modified: 21/11/2023 16:49
Comments
Log in to add a comment.
No comments found.