Engulfing Candles free

by o6h58zs in category Other at 29/08/2022
Description

An engulfing candle pattern consists of two candles, with the current 'engulfing' the previous one. In other words, the body of the current candle is larger than the previous, such that the body of the previous candle would fit inside the current one. This pattern can indicate a sudden increase in pressure from one side of the market onto the other, especially at the end of the trend, and can be used as a confluence for a trend reversal.

This indicator draws arrows onto the chart to show when engulfing candles occur, with each arrow coloured appropriately. 

Improvements are needed on the positioning of the arrows. Initially, this was all okay on all the pairs I tested, however, due to not re-loading the indicator, it was not re-drawing as expected. I'm sure I'll fix this at some point.

Credit goes to ctid306377 for their original Candlestick Patterns DEMO indicator - code snippets were adapted from this indicator. However, the full Candlestick Patterns indicator is more comprehensive and offers all candlestick patterns plus additional information and text options, and is available for purchase from ctid306377 (have a look at the indicator page if you're interested).

Usage in cBots:

• To use with cBots, declare the EngulfingCandles indicator in your class body (class scope, outside of a method body):
private EngulfingCandles _engulfingCandles { get; set; }

• Then instantiate inside your OnStart() method:
_engulfingCandles = Indicators.GetIndicator<EngulfingCandles>();

• Finally, to reference the last engulfing candle, either in your OnTick() or OnBar() method, access the DataSeries 'PatternData' using the appropriate method calls, e.g. PatternData.LastValue or PatternData.Last(0), for instance:
var bull = PatternData.Last(0) == 1 ? true : false;

Changelog:

- 31/08/2022: Added option to store (keep) last engulfing result in PatternData. Use this if your strategy relies on looking up the last engulfing result (not necessarily on last bar close).

- 09/09/2022: Changed 'Bull' to 1 and 'Bear' to 0 inside the Enum.

Chartshot:

AUDCAD, M1

 

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
Trading Platform: cAlgocTrader
using cAlgo.API;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class EngulfingCandles : Indicator
    {
    
        // If no engulfing pattern on bar close, store last engulfing result for that bar
        [Parameter("Keep Last Engulfing Pattern?", DefaultValue = true)]
        public bool KeepLastPattern { get; set; }
        
        public IndicatorDataSeries PatternData { get; set; }

        private const VerticalAlignment vAlign = VerticalAlignment.Top;
        private const HorizontalAlignment hAlign = HorizontalAlignment.Center;

        private const string UpArrow = "▲";
        private const string DownArrow = "▼";

        private double offset;

        private enum PatternType : int {
        
            Bull = 1,
            Bear = 0,
            
        }

        protected override void Initialize() {
            
            PatternData = CreateDataSeries();
            offset = Symbol.PipSize;
            
        }
        
        private void DrawSymbol(int index, PatternType type) {
        
            var high = MarketSeries.High[index];
            var low = MarketSeries.Low[index];
 
            double bear_y = new double();
            double bull_y = new double();
        
            if (TimeFrame == TimeFrame.Minute || TimeFrame == TimeFrame.Minute2) {
                bear_y = high + offset / 9;
                bull_y = low - offset / 1.5;
            }
        
            if (TimeFrame == TimeFrame.Minute3 || TimeFrame == TimeFrame.Minute4) {
                bear_y = high + offset / 7.5;
                bull_y = low - offset * 2.8;  
            }
            
 
            if (TimeFrame == TimeFrame.Minute5 || TimeFrame == TimeFrame.Minute6 ||
                TimeFrame == TimeFrame.Minute7) {
                bear_y = high + offset / 6;
                bull_y = low - offset * 3.2;
            }
 
            if (TimeFrame == TimeFrame.Minute8 || TimeFrame == TimeFrame.Minute9 || 
                TimeFrame == TimeFrame.Minute10) {
                bear_y = high + offset / 5.5;
                bull_y = low - offset * 3.7;
            }
            
            if (TimeFrame == TimeFrame.Minute15) {
                bear_y = high + offset / 4.5;
                bull_y = low - offset * 4.1;
            }
            
            if (TimeFrame == TimeFrame.Minute20) {
                bear_y = high + offset / 4;
                bull_y = low - offset * 4.5;
            }
            
            if (TimeFrame == TimeFrame.Minute30) {
                bear_y = high + offset / 3;
                bull_y = low - offset * 6.5;
            }
            
            if (TimeFrame == TimeFrame.Minute45) {
                bear_y = high + offset / 2;
                bull_y = low - offset * 8;
            }
 
            if (TimeFrame == TimeFrame.Hour || TimeFrame == TimeFrame.Hour2) {
                bear_y = high + offset;
                bull_y = low - offset * 10;
            }
            
            if (TimeFrame == TimeFrame.Hour3) {
                bear_y = high + offset * 1.2;
                bull_y = low - offset * 12;
            }
 
            if (TimeFrame == TimeFrame.Hour4) {
                bear_y = high + offset * 1.3;
                bull_y = low - offset * 13.5;
            }
            
            if (TimeFrame == TimeFrame.Hour6) {
                bear_y = high + offset * 1.5;
                bull_y = low - offset * 16;
            }
            
            if (TimeFrame == TimeFrame.Hour8) {
                bear_y = high + offset * 1.7;
                bull_y = low - offset * 19;
            }
            
            if (TimeFrame == TimeFrame.Hour12) {
                bear_y = high + offset * 2;
                bull_y = low - offset * 21;
            }
 
            if (TimeFrame == TimeFrame.Daily) {
                bear_y = high + offset * 3.2;
                bull_y = low - offset * 34;
            }
            
            if (TimeFrame == TimeFrame.Day2) {
                bear_y = high + offset * 3.7;
                bull_y = low - offset * 45.5;
            }
            
            if (TimeFrame == TimeFrame.Day3) {
                bear_y = high + offset * 4.4;
                bull_y = low - offset * 63.5;
            }
 
            if (TimeFrame == TimeFrame.Weekly) {
                bear_y = high + offset * 5.6;
                bull_y = low - offset * 70.5;
            }
 
            if (TimeFrame == TimeFrame.Monthly) {
                bear_y = high + offset * 9.1;
                bull_y = low - offset * 167.5;
            }

            int x = index;

            string f_ObjName = string.Format("Engulfing {0}", index);

            if (type is PatternType.Bull) {
            
                ChartObjects.DrawText(f_ObjName, UpArrow, x, bull_y, vAlign, hAlign, Colors.Green);
                
            }
            else if (type is PatternType.Bear) {
            
                ChartObjects.DrawText(f_ObjName, DownArrow, x, bear_y, vAlign, hAlign, Colors.Red);
                
            }
        }

        public override void Calculate(int index) {
            
            var currentOpen = MarketSeries.Open.Last(0);
            var currentClose = MarketSeries.Close.Last(0);
            
            var previousOpen = MarketSeries.Open.Last(1);
            var previousClose = MarketSeries.Close.Last(1);
            
            // Drawing chart objects
    
            if (currentOpen <= previousClose & currentOpen < previousOpen & currentClose > previousOpen) {
            
                DrawSymbol(index, PatternType.Bull);
                
                if (KeepLastPattern) {
                    PatternData[index] = ((double) PatternType.Bull);
                }
                
            }
            else if (currentOpen >= previousClose & currentOpen > previousOpen & currentClose < previousOpen) {
            
                DrawSymbol(index, PatternType.Bear);
                
                if (KeepLastPattern) {
                    PatternData[index] = ((double) PatternType.Bear);
                }
                
            }
        }
    }
}
Comments

whitecameron799 - September 03, 2022 @ 09:52

Develpers make the body of the candle that is larger than previous one. Develpers follow the different patterns of the candles. I am working with proofreading services UK  firm that help students to deliver quality academic projects on time.  

gosoc37766 - September 04, 2022 @ 23:28

I don't think anyone dislikes this website called https://agigeocommunity.com/. Everything was actually in my hands in record time. There are no regrets!

franciscodobbins68 - September 06, 2022 @ 16:07

I know how hard it is to stay focused on homework when you have some questions about it. https://domyhomework.club/algebra-homework/ a portal where people can come together and help each other with their homework. Daily, we have hundreds of new questions and answers from people who need help with their assignments.

vazquezdudley9711352 - September 07, 2022 @ 07:47

What regimen do you adhere to at this difficult time of epidemics? retro bowl is a great game to keep you occupied over the winter, I just discovered. Join me now. 

junealexis001 - September 12, 2022 @ 12:01

Interesting  site i love it keep posting more!   https://paintersfargo.com

renzkarlosantos - September 13, 2022 @ 16:47

Hello, is it possible for you guys to help me to create an indicator/signal for the following:

Timeframe: 5 mins

FOR BUY
-a "green" candle will close above the high of a previous "red" candle

FOR SELL
-a "red candle" will close below the low of a previous "green" candle

Kindly help. Let me know if you need any clarifications.

Thanks a lot!

o6h58zs - September 13, 2022 @ 18:05

Hello, is it possible for you guys to help me to create an indicator/signal for the following:

Timeframe: 5 mins

FOR BUY
-a "green" candle will close above the high of a previous "red" candle

FOR SELL
-a "red candle" will close below the low of a previous "green" candle

Kindly help. Let me know if you need any clarifications.

Thanks a lot!

- renzkarlosantos

 

Hi buddy,

Thanks for checking out my indicator first of all.

This would be quite simple to do.

The high prices of the market are represented by either MarketSeries.High (obsolete) or Bars.HighPrices - both of which are DataSeries. Replace 'High' with 'Low' in the previous and you have your low prices, 'Close' for close prices, 'Open' for open prices.

A bullish candle (green) closes above its open; a bearish candle (red) below. Use the DataSeries mentioned above to check if a previous candle is green or red by indexing the previous bar inside your Calculate() method - you could create an enum or bool to store whether it is bullish or bearish.

Depending on whether you want it to repaint, you'll need to know the previous two candles. To check the previous two candle, use index [1] for the previous candle and index [2] for the candle before that. If checking the current and previous candles, just use [0] and [1].

Then you check the prices. If previous is red and current is green and closes above the high price of the previous (i.e. Bars.ClosePrices[0] > Bars.HighPrices[1]), or vice versa, and then you draw the signal on your chart (you can use code from this indicator if you wish).

You can also ensure that a signal is not repeated by storing the last signal in a variable and checking whether the last signal is the same as the next.

I refuse to write code for people, unless it's something I intend to create myself as it's part of the learning process. If you're struggling to learn cTrader/cAlgo, just learn C# or Java - even at a basic/intermediate level - and the rest will follow. Hope that helps.

Kind regards,

o6h58zs (just one guy, lol)

renzkarlosantos - September 13, 2022 @ 18:15

Hi buddy,

Thanks for checking out my indicator first of all.

This would be quite simple to do.

The high prices of the market are represented by either MarketSeries.High (obsolete) or Bars.HighPrices - both of which are DataSeries. Replace 'High' with 'Low' in the previous and you have your low prices, 'Close' for close prices, 'Open' for open prices.

A bullish candle (green) closes above its open; a bearish candle (red) below. Use the DataSeries mentioned above to check if a previous candle is green or red by indexing the previous bar inside your Calculate() method - you could create an enum or bool to store whether it is bullish or bearish.

Depending on whether you want it to repaint, you'll need to know the previous two candles. To check the previous two candle, use index [1] for the previous candle and index [2] for the candle before that. If checking the current and previous candles, just use [0] and [1].

Then you check the prices. If previous is red and current is green and closes above the high price of the previous (i.e. Bars.ClosePrices[0] > Bars.HighPrices[1]), or vice versa, and then you draw the signal on your chart (you can use code from this indicator if you wish).

You can also ensure that a signal is not repeated by storing the last signal in a variable and checking whether the last signal is the same as the next.

I refuse to write code for people, unless it's something I intend to create myself as it's part of the learning process. If you're struggling to learn cTrader/cAlgo, just learn C# or Java - even at a basic/intermediate level - and the rest will follow. Hope that helps.

Kind regards,

o6h58zs (just one guy, lol)

Thank you sir! I will check this out if my brain cells can do it. Thank you so much even just for replying! 

moeedmuslim9 - November 17, 2022 @ 14:04

Quite fantastic good sense of sentence, I have probably experienced in your short article Honestly wonderful information for its users. Url Opener

ocianwriters - November 25, 2022 @ 13:31

 effective strategy which would actually work. In addition to that, the person would also have to make sure that nothing or no one is getting harmed or negatively affected. According to   Best coursework writing services UK

5