Category Trend  Published on 01/12/2023

DRKHASHIX Hammer

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 

Hammer Pattern: The Hammer pattern is a candlestick pattern that is typically observed at the end of a downtrend or price decline, indicating a potential shift from a bearish to a bullish market. The Bullish Hammer pattern occurs at the end of a downtrend, while the Bearish Hammer pattern occurs at the end of an uptrend.

Bullish Hammer:

  • Candle opens higher.
  • The candle's high is equal to the highest point it opened.
  • The difference between the high and low of the current candle compared to past candles is more than 1.618 times the difference between the close and open of past candles.

Bearish Hammer:

  • Candle opens lower.
  • The candle's low is equal to the lowest point it opened.
  • The difference between the high and low of the current candle compared to past candles is more than 1.618 times the difference between the open and close of past candles.

If these patterns appear on your chart, they might indicate a potential reversal in market direction. A Bullish Hammer could signal the start of an uptrend, while a Bearish Hammer could signal the beginning of a downtrend.

 Best regards, Dr.khashix. I LOVE YOU ALL


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

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class drkhashixHammer : Indicator
    {
        [Parameter("Bullish Hammer Symbol", DefaultValue = "▲", Group = "Symbols")]
        public string BullishHammerSymbol { get; set; }

        [Parameter("Bearish Hammer Symbol", DefaultValue = "▼", Group = "Symbols")]
        public string BearishHammerSymbol { get; set; }

        [Parameter("Bullish Hammer Color", DefaultValue = Colors.White, Group = "Colors")]
        public Colors BullishHammerColor { get; set; }

        [Parameter("Bearish Hammer Color", DefaultValue = Colors.White, Group = "Colors")]
        public Colors BearishHammerColor { get; set; }

        [Parameter("Min Candle Height", DefaultValue = 0.00003, Group = "Settings")]
        public double MinCandleHeight { get; set; }

        private const double Offset = 0.0005;

        private struct Candle
        {
            public double High;
            public double Close;
            public double Open;
            public double Low;

            public bool IsFallCandle()
            {
                return Close < Open;
            }

            public bool IsRiseCandle()
            {
                return Open < Close;
            }

            public double Median()
            {
                return (High + Low) / 2;
            }
        }

        protected override void Initialize()
        {
            // Initialization logic goes here
        }

        private void DrawHammer(int index, bool isBearish)
        {
            var high = MarketSeries.High[index];
            var low = MarketSeries.Low[index];
            var x = index;

            double h_y = isBearish ? high + Offset : low - Offset;

            if (TimeFrame == TimeFrame.Minute)
            {
                h_y = isBearish ? high + Offset / 2 : low - Offset / 2;
            }

            if (TimeFrame == TimeFrame.Hour)
            {
                h_y = isBearish ? high + Offset : low - Offset;
            }

            ChartObjects.DrawText($"Hammer {index}", isBearish ? BearishHammerSymbol : BullishHammerSymbol, x, h_y, VerticalAlignment.Top, HorizontalAlignment.Center, GetColor(isBearish));
        }

        private Candle GetCandle(int index)
        {
            return new Candle
            {
                High = MarketSeries.High[index],
                Open = MarketSeries.Open[index],
                Close = MarketSeries.Close[index],
                Low = MarketSeries.Low[index]
            };
        }

        private Colors GetColor(bool isBearish)
        {
            return isBearish ? BearishHammerColor : BullishHammerColor;
        }

        public override void Calculate(int index)
        {
            var candle = GetCandle(index);

            // Check Min Candle Height
            if ((candle.High - candle.Low) < MinCandleHeight)
                return;

            // Bearish Hammer
            if (candle.IsFallCandle() && (candle.Close == candle.Low))
            {
                if ((candle.Median() > candle.Open) && (candle.Median() > candle.Close))
                {
                    if ((candle.Median() - candle.Low) > 1.618 * (candle.Open - candle.Close))
                    {
                        DrawHammer(index, true);
                        return;
                    }
                }
            }

            // Bullish Hammer
            if (candle.IsRiseCandle() && (candle.Close == candle.High))
            {
                if ((candle.Median() < candle.Open) && (candle.Median() < candle.Close))
                {
                    if ((candle.High - candle.Median()) > 1.618 * (candle.Close - candle.Open))
                    {
                        DrawHammer(index, false);
                        return;
                    }
                }
            }
        }
    }
}


drkhashix's avatar
drkhashix

Joined on 12.02.2023

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: drkhashix hamer.algo
  • Rating: 5
  • Installs: 530
  • Modified: 01/12/2023 15:45
Comments
Log in to add a comment.
No comments found.