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.  

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

daniilmedvedev009 - December 09, 2022 @ 19:39

Yes, you can find candles at Dollar General. They offer a wide range of candle options, including jar candles, votive candles, tea lights, and more. In addition, you can find many different scents, as well as unscented candles.

Submit the review about the products and Store experience with management through the dg customer first customer experience survey with the receipt code.

artificialgrassindelhi - December 20, 2022 @ 13:46

Nice concept, by the way, if anyone wants help in buying home decor items, then I would suggest buying artificial grass, flowers, an artificial vertical garden, plants, and artificial bonsai. These are perfect for home decor.

alexaandr884 - December 28, 2022 @ 13:12

writers focused on racism, whiteness, nationalism, and how the general public, policymakers, and scholars have to methodology Charlottesville. online essay help

alexaandr884 - January 26, 2023 @ 14:06

. This is not it. If you are tired of writing, you can read the notes out loud to the voice detector. It will detect your voice and type the words you are saying. Make sure you don’t speak loudly, or else it will disturb the class. buy assignment online uk 

kailashtourpackages - February 04, 2023 @ 12:01

Traveling is not just sightseeing, it shows us the real world, teaches many things, it changes our way of thinking. Travel brings out the best version of ourselves. So pack your thing, you can start with religious tour packages like Kailash Mansarovar Yatra, Muktinath tour, Nepal tour package, Char Dham Yatra, or Om Parvat Yatra.

oli45641 - February 04, 2023 @ 12:20

 which one of our senior writers is going to do an in-depth review of this week. It has taken all day to get it down to a science, because it is one of those casual vampires - fun enough that you can play it all day without effort.  essay writers help

besttourpackageinindia - February 06, 2023 @ 08:20

Traveling is important in life because it will increase the horizon of your thinking. Traveling teaches us how beautiful is our world and how lucky we are. So pack up your things and start traveling. In India, there are a lot of tour operators with the best India tour packages like North India tour packages, South India tour packages, wildlife tour packages, Varanasi tour packages, and Rajasthan tour packages.

oli45641 - February 08, 2023 @ 15:26

you will need to write yourself. Here you will need to put together the introduction, the conclusions of the main part and express from this the conclusion.  Best essay writing services

5