<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: HloniTheCoder</title>
    <description>The latest articles on DEV Community by HloniTheCoder (@hlonithecoder).</description>
    <link>https://dev.to/hlonithecoder</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1124618%2F1a81afe5-6f3f-4dfa-840e-910e5137ba21.png</url>
      <title>DEV Community: HloniTheCoder</title>
      <link>https://dev.to/hlonithecoder</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hlonithecoder"/>
    <language>en</language>
    <item>
      <title>Support And Resistance Identification System Using MQL5</title>
      <dc:creator>HloniTheCoder</dc:creator>
      <pubDate>Mon, 25 Sep 2023 10:37:46 +0000</pubDate>
      <link>https://dev.to/hlonithecoder/support-and-resistance-identification-system-using-mql5-5e5p</link>
      <guid>https://dev.to/hlonithecoder/support-and-resistance-identification-system-using-mql5-5e5p</guid>
      <description>&lt;h2&gt;
  
  
  Identify Support and Resistance Using Significant High and Low Levels
&lt;/h2&gt;

&lt;p&gt;The Support and Resistance Identification System is used to identify levels of significance using significant high and low levels.&lt;/p&gt;

&lt;p&gt;A level of significance is a level in price that can be used to enter or exit positions, or set position stops.&lt;/p&gt;

&lt;p&gt;A significant high and low level is identified using the highest and lowest prices within price ranges.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XvfXYj1J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r5xl8vdh13yt2lnj8cov.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XvfXYj1J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r5xl8vdh13yt2lnj8cov.png" alt="Support and Resistance Identification System" width="800" height="396"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Description
&lt;/h2&gt;

&lt;p&gt;Significant highs and lows ae identified using price ranges.&lt;br&gt;
Price ranges are identified using start indexes and end indexes to identify the highest and lowest price between those indexes.&lt;/p&gt;

&lt;p&gt;We will be using a total of 100 candles for our identification.&lt;br&gt;
The total values can be changed to suite the needs of the strategy.&lt;/p&gt;
&lt;h2&gt;
  
  
  Program Description
&lt;/h2&gt;

&lt;p&gt;Resistance levels will be drawn based on high levels and will be drawn Blue.&lt;/p&gt;

&lt;p&gt;Support levels will be drawn based on low levels and will be drawn Red.&lt;/p&gt;
&lt;h2&gt;
  
  
  Code Description
&lt;/h2&gt;

&lt;p&gt;At the top of our file we will include the following code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
#include &amp;lt;IncludeHighLowData/HighLowData.mqh&amp;gt;

#include &amp;lt;IncludeLineObjects/LineSystems.mqh&amp;gt;

HLowHigh MyHighLowData;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;code&gt;#include&lt;/code&gt; is used to get the necessary data classes for our high and low identification, and drawing line types.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;HLowHigh MyHighLowData&lt;/code&gt; we define a high and low data object, this object will be used to get high and low values.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;HLowHigh&lt;/code&gt; is a class with the necessary methods for our system.&lt;br&gt;
&lt;code&gt;MyHighLowData&lt;/code&gt; is an object used to access the class methods.&lt;/p&gt;

&lt;p&gt;Within the &lt;code&gt;OnTick&lt;/code&gt; function we will add the following code.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;void OnTick(){
    MyHighLowData.Add_Array_Data();
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The &lt;code&gt;Add_Array_Data&lt;/code&gt; method is based on the &lt;code&gt;CopyBuffer&lt;/code&gt; function.&lt;br&gt;
This method is used to add the array data to the &lt;code&gt;MyHighLowData&lt;/code&gt; object.&lt;br&gt;
Without this method we cannot access current data.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
double highest_100 = MyHighLowData.High_Value(50,100);

double highest_50 = MyHighLowData.High_Value(20,50);

double highest_20 = MyHighLowData.High_Value(5,20);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Using the &lt;code&gt;High_Value(start, end)&lt;/code&gt; method we access the most significant high between the start and end index.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;highest_100&lt;/code&gt; variable stores the high value of the most significant high between the 50 and 100 index.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;highest_50&lt;/code&gt; variable stores the high value of the most significant high between the 20 and 50 index.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;highest_20&lt;/code&gt; variable stores the high value of the most significant high between the 5 and 20 index.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;double lowest_100 = MyHighLowData.Low_Value(50,100);

double lowest_50 = MyHighLowData.Low_Value(20,50);

double lowest_20 = MyHighLowData.Low_Value(5,20);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Using the &lt;code&gt;Low_Value(start,end)&lt;/code&gt; method we acess the most significant low between the start and end index.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;lowest_100&lt;/code&gt; variable stores the low values of the most significant low between the 50 and 100 index.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;lowest_50&lt;/code&gt; variable stores the low value of the most significant low between the 20 and 50 index.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;lowest_20&lt;/code&gt; variable stores the low value of the most significant low between the 5 and 20 index.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
Create_Horizontal_Line("Highest 100", highest_100, clrBlue);
Create_Horizontal_Line("Highest 0", highest_50, clrBlue);
Create_Horizontal_Line("Highest 20", highest_20, clrBlue);

Create_Horizontal_Line("Lowest 100", lowest_100, clrRed);
Create_Horizontal_Line("Lowest 50", lowest_50, clrRed);
Create_Horizontal_Line("Lowest 20", lowest_20, clrRed);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The &lt;code&gt;Create_Hprizontal_Line&lt;/code&gt; function will draw a horizontal line at a significant high and low price.&lt;/p&gt;

&lt;p&gt;High levels will be identified using a Blue horizontal line.&lt;/p&gt;

&lt;p&gt;Low levels will be identified using a Red horizontal line.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--l1Q5lRPy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/81mxa5hi4re3rao4x17e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--l1Q5lRPy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/81mxa5hi4re3rao4x17e.png" alt="Support And Resistance" width="800" height="396"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Access to the full code:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--A9-wwsHG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/HloniTheCoder"&gt;
        HloniTheCoder
      &lt;/a&gt; / &lt;a href="https://github.com/HloniTheCoder/Support-And-Resistance-Data"&gt;
        Support-And-Resistance-Data
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1 id="user-content-support-and-resistance-data"&gt;&lt;a class="heading-link" href="https://github.com/HloniTheCoder/Support-And-Resistance-Data#support-and-resistance-data"&gt;Support-And-Resistance-Data&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Within this repository we define the Support and Resistance Indicator System.&lt;/p&gt;
&lt;p&gt;The Draw Support and Resistance defines a basic implementation of the Support and Resistance System.
This system is based on identifying significant highs and lows to identify levels of support and resistance.&lt;/p&gt;
&lt;/div&gt;

  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/HloniTheCoder/Support-And-Resistance-Data"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Trend Based Signal System Using MQL5</title>
      <dc:creator>HloniTheCoder</dc:creator>
      <pubDate>Fri, 25 Aug 2023 13:12:04 +0000</pubDate>
      <link>https://dev.to/hlonithecoder/trend-based-signal-system-using-mql5-42g1</link>
      <guid>https://dev.to/hlonithecoder/trend-based-signal-system-using-mql5-42g1</guid>
      <description>&lt;h2&gt;
  
  
  Identify Bullish and Bearish Signals Using Momentum
&lt;/h2&gt;

&lt;p&gt;The Trend Based Signal System is used to identify levels of significance based on bullish and bearish momentum.&lt;br&gt;
A level of significance is a level in price that can be used to enter or exit positions, or set position stops.&lt;/p&gt;

&lt;p&gt;We identify bullish or bearish momentum using the fast and slow moving average indicator.&lt;/p&gt;

&lt;p&gt;During moments of bullish momentum, we identify bullish signals.&lt;br&gt;
During moments of bearish momentum, we identify bearish signals.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7sQ76Vkj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ajpltfspzkgux9z7394z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7sQ76Vkj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ajpltfspzkgux9z7394z.png" alt="Signal Performance" width="800" height="396"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Project Description
&lt;/h2&gt;

&lt;p&gt;When the fast moving average indicator is above the slow moving average indicator it represents bullish momentum.&lt;br&gt;
When there is bullish momentum, we identify bullish signals.&lt;br&gt;
Bullish Signals are identified using bullish candlestick patterns.&lt;/p&gt;

&lt;p&gt;When the fast moving average indicator is below the slow moving average indicator it represents bearish momentum.&lt;br&gt;
When there is bearish momentum, we identify bearish signals.&lt;br&gt;
Bearish Signals are identified using bearish candlestick patterns.&lt;/p&gt;
&lt;h2&gt;
  
  
  Program Description
&lt;/h2&gt;

&lt;p&gt;Bullish Signals are identified using a blue horizontal line.&lt;br&gt;
Bearish Signals are identified using a red horizontal line.&lt;/p&gt;

&lt;p&gt;We will be using Bullish and Bearish Harami and Engulfing Candlestick Patterns.&lt;/p&gt;
&lt;h2&gt;
  
  
  Code Description
&lt;/h2&gt;

&lt;p&gt;At the top our file we will include the following code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;IncludeTutorial/IndicatorDataClass&amp;gt;

#include &amp;lt;IncludeTutorial/PriceDataClass&amp;gt;

HSMA FastMAData;

HSMA SlowMAData;

HPriceData MyPriceData;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;code&gt;#include&lt;/code&gt; is used to get the necessary data classes for indicator types and price data.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;HSMA&lt;/code&gt; is the Simple Moving Average class used to access our moving average data.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;HPriceData&lt;/code&gt; is the Price Data Class used to access our price data.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int OnInit()
{
   FastMAData.Create_SMA_Definition(_Symbol, _Period, 50);

   SlowMAData.Create_SMA_Definition(_Symbol, _Period, 200);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Within the &lt;code&gt;OnInit&lt;/code&gt; function we will create the Moving Average Indicator Definitions.&lt;br&gt;
The &lt;code&gt;Create_SMA_Definition&lt;/code&gt; method creates the indicator definition and initializes the indicator averaging period to 50, for the fast ma, and 200, for the slow ma.&lt;/p&gt;

&lt;p&gt;Within the &lt;code&gt;OnTick&lt;/code&gt; function we will include the following code:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FastMAData.Add_Array_Data();

SlowMAData.Add_Array_Data();

MyPriceData.Add_Price_Data();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The &lt;code&gt;Add_Array_Data&lt;/code&gt; method is used to add the indicator data to the indicator array.&lt;br&gt;
This method is based on the &lt;code&gt;CopyBuffer&lt;/code&gt; function.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;double fast_ma_value = FastMAData.Get_Indicator_Value(1);

double slow_ma_value = SlowMAData.Get_Indicator_Value(1);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Get the most recent fast and slow moving average value.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bool fast_above_slow = fast_ma_value &amp;gt; slow_ma_value;

bool fast_below_slow = fast_ma_value &amp;lt; slow_ma_value;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The conditions required for determining bullish and bearish momentum.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bool bullish_engulfing = MyPriceData.Get_Is_Bullish_Engulfing(1,5);

bool bearish_engulfing = MyPriceData.Get_Is_Bearish_Engulfing(1,5);

bool bullish_harami = MyPriceData.Get_Is_Bullish_Harami(1,5);

bool bearish_harami = MyPriceData.Get_Is_Bearish_Harami(1,5);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Using the &lt;code&gt;MyPriceData&lt;/code&gt; object, we will determine the engulfing and harami candlestick type.&lt;br&gt;
We will find whether or not the most recently completed candlestick, indexed at 1, is an engulfing pattern or harami pattern.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bool bullish_signal = fast_above_slow &amp;amp;&amp;amp; (bullish_engulfing || bullish_harami);

bool bearish_signal = fast_below_slow &amp;amp;&amp;amp; (bearish_engulfing || bearish_harami);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The above code defines the Boolean variables that handle bullish and bearish signals.&lt;/p&gt;

&lt;p&gt;Bullish Signals are defined by a bullish candlestick patterns and bullish momentum, defined by the fast and slow moving average.&lt;/p&gt;

&lt;p&gt;Bearish Signals are defined by bearish candlestick patterns and bearish momentum, defined by the fast and slow moving average.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;close_value = MyPriceData.Get_Close_Value(1);

if(bullish_signal){
   ObjectCreate(0, "Bullish Signal Level", OBJ_HLINE, 0, 0, close_value);
   ObjectSetInteger(0, "Bullish Signal Level", OBJPROP_COLOR, clrBlue);
}


if(bearish_signal){
   ObjectCreate(0, "Bearish Signal Level", OBJ_HLINE, 0, 0, close_value);
   ObjectSetInteger(0, "Bearish Signal Level", OBJPROP_COLOR, clrRed);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;When we receive a bullish or bearish signal, we will draw a horizontal line to identify the price in which the signal was identified.&lt;/p&gt;

&lt;p&gt;Bullish Signals are identified using a blue horizontal line.&lt;br&gt;
Bearish Signals are identified using a red horizontal line.&lt;/p&gt;

&lt;p&gt;Access to the full code:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--A9-wwsHG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/HloniTheCoder"&gt;
        HloniTheCoder
      &lt;/a&gt; / &lt;a href="https://github.com/HloniTheCoder/Simple-Moving-Average-Data"&gt;
        Simple-Moving-Average-Data
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
Simple Moving Average Based Strategies.&lt;/h1&gt;
&lt;p&gt;Within this repository we define the Golden Cross Strategy and Trend Based Signal System.&lt;/p&gt;
&lt;p&gt;The Golden Cross Strategy is a double moving average based strategy in which bullish momentum is defined  by the fast-period moving average crossing above the slow-period moving average, and bearish momentum is defined by the fast-period moving average crossing below the slow-period moving average.&lt;/p&gt;
&lt;p&gt;The Trend Based Signal System is based on a fast and slow period moving average, bullish momentum is based on the fast-period moving average moving above the slow-period moving average and bearish momentum is based on it moving below the slow-period moving average.&lt;/p&gt;
&lt;p&gt;When we receive a bullish candlestick pattern while price has bullish momentum, a bullish signal is output
When we receicve a bearish candlestick pattern while price has bearish momentum, a bearish signal is output.&lt;/p&gt;
&lt;p&gt;The Golden Cross Strategy is based on procedural coding in…&lt;/p&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/HloniTheCoder/Simple-Moving-Average-Data"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Golden Cross Strategy Using MQL5</title>
      <dc:creator>HloniTheCoder</dc:creator>
      <pubDate>Fri, 25 Aug 2023 10:50:53 +0000</pubDate>
      <link>https://dev.to/hlonithecoder/golden-cross-strategy-using-mql5-56p4</link>
      <guid>https://dev.to/hlonithecoder/golden-cross-strategy-using-mql5-56p4</guid>
      <description>&lt;h2&gt;
  
  
  Identify Bullish And Bearish Momentum Using The Golden Cross Strategy
&lt;/h2&gt;

&lt;p&gt;The Golden Cross Strategy is a technical analysis based trading strategy that involves two moving average indicators.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Description
&lt;/h2&gt;

&lt;p&gt;This system involves a fast and slow period moving average.&lt;br&gt;
A fast-period moving average is the ma that follows the movement of price closely.&lt;br&gt;
A slow-period moving average is the ma that defines the momentum of price.&lt;/p&gt;

&lt;p&gt;When the fast-period ma crosses above the slow-period ma, it defines bullish momentum.&lt;br&gt;
When the fast-period ma crosses below the slow-period ma, it defines bearish momentum.&lt;/p&gt;

&lt;p&gt;When a signal for bullish momentum occurs, a vertical line will be drawn to index the date time value.&lt;br&gt;
When we get a signal for bearish momentum we will draw a vertical line to index its occurrence.&lt;/p&gt;
&lt;h2&gt;
  
  
  Program Description
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Vw6A89pW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ayqq5i3ixzrc24c5u94k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Vw6A89pW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ayqq5i3ixzrc24c5u94k.png" alt="Strategy Performance" width="800" height="401"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A blue vertical line will be drawn to define an up cross.&lt;br&gt;
A red vertical line will be drawn to define a down cross.&lt;/p&gt;
&lt;h2&gt;
  
  
  Code Description
&lt;/h2&gt;

&lt;p&gt;The following strategy code should be written within the &lt;code&gt;OnTick()&lt;/code&gt; function.&lt;br&gt;
The &lt;code&gt;OnTick&lt;/code&gt; function is a function that executes on every price change.&lt;/p&gt;

&lt;p&gt;Within the &lt;code&gt;OnTick&lt;/code&gt; function, we will initialize the arrays that will store the indicator data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;double fast_ma_array[];

double slow_ma_array[];

ArraySetAsSeries(fast_ma_array, true);

ArraySetAsSeries(slow_ma_array, true);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The &lt;code&gt;ArraySetAsSeries&lt;/code&gt; function sets the array index 0 to the latest MA value.&lt;br&gt;
This is a important function for the performance of the strategy.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int fast_ma_indicator = iMA(_Symbol, _Period, 50, 0, MODE_SMA, PRICE_CLOSE);

int slow_ma_indicator = iMA(_Symbol, _Period, 200, 0, MODE_SMA, PRICE_CLOSE);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The above code initializes the variables that store the indicator data.&lt;br&gt;
We initialize the fast and slow moving averages.&lt;br&gt;
The averaging period of the fast ma is 50.&lt;br&gt;
The averaging period of the slow ma is 200.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CopyBuffer(fast_ma_indicator, 0, 0, 10, fast_ma_array);

CopyBuffer(slow_ma_indicator, 0, 0, 10, slow_ma_array);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The &lt;code&gt;CopyBuffer&lt;/code&gt; function copies the indicator data to the indicator data array.&lt;br&gt;
We copy data from the index 0 to index 10.&lt;br&gt;
The index 0 represents the candle index that is currently forming.&lt;br&gt;
The index 10 represents the 10th index away from the current candle.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int curr_fast_value = fast_ma_array[1];

int prev_fast_value = slow_ma_array[2];

int curr_slow_value = slow_ma_array[1];

int prev_slow_value = slow_ma_array[2];

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We get the most recent moving average values.&lt;br&gt;
Index 1 represents the most recently completed candle.&lt;br&gt;
Index 2 represents the candle before the most recently completed candle.&lt;/p&gt;

&lt;p&gt;Index 1 is the candle before our currently forming candle.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bool curr_fast_above_slow = curr_fast_value &amp;gt; curr_slow_value;

bool prev_fast_above_slow = prev_fast_value &amp;gt; prev_slow_value;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Conditions to determine whether the fast moving average is above the slow moving average.&lt;br&gt;
A Boolean variable can only be true or false.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bool up_cross = curr_fast_above_slow &amp;amp;&amp;amp; !(prev_fast_above_slow);

bool down_cross = !(curr_fast_above_slow) &amp;amp;&amp;amp; prev_fast_above_slow;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Conditions to determine an up or down cross state.&lt;/p&gt;

&lt;p&gt;An up cross means the current fast moving average value is greater than the current slow moving average value, and the previous fast moving average value is less than the previous slow moving average value.&lt;/p&gt;

&lt;p&gt;An down cross means the current fast moving average value is less than the current slow moving average value, and the previous fast moving average value is greater than the previous slow moving average value.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;!&lt;/code&gt; operator is the not Boolean operator, if a variable is true the not operator changes the value to false, and does the opposite for false.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MqlRates price_data_array[];

ArraySetAsSeries(price_data_array, true);

CopyRates(_Symbol, _Period, 1, 2, price_data_array);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The &lt;code&gt;MqlRates&lt;/code&gt; type allows us to access price data within an array.&lt;br&gt;
The &lt;code&gt;CopyRates&lt;/code&gt; function copies price data to the price data array.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if(up_cross){
   ObjectCreate(0, "Up Cross Line", OBJ_VLINE, 0, price_data_array[1].time, 0, 0);
   ObjectSetInteger(0, "Up Cross Line", OBJPROP_COLOR, clrBlue);
}

if(down_cross){
   ObjectCreate(0, "Down Cross Line", OBJ_VLINE, 0, price_data_array[1].time, 0, 0);
   ObjectSetInteger(0, "Down Cross Line", OBJPROP_COLOR, clrRed);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;If the up cross condition is true, we will draw a vertical line at the index in which the cross occured.&lt;br&gt;
If the down cross condition is true, we will draw a vertical line at the index in which it occured.&lt;/p&gt;

&lt;p&gt;The line representing an up cross will be colored blue, whereas the down cross line will be colored red.&lt;/p&gt;

&lt;p&gt;For access to the full code:&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--A9-wwsHG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/HloniTheCoder"&gt;
        HloniTheCoder
      &lt;/a&gt; / &lt;a href="https://github.com/HloniTheCoder/Simple-Moving-Average-Data"&gt;
        Simple-Moving-Average-Data
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
Simple Moving Average Based Strategies.&lt;/h1&gt;
&lt;p&gt;Within this repository we define the Golden Cross Strategy and Trend Based Signal System.&lt;/p&gt;
&lt;p&gt;The Golden Cross Strategy is a double moving average based strategy in which bullish momentum is defined  by the fast-period moving average crossing above the slow-period moving average, and bearish momentum is defined by the fast-period moving average crossing below the slow-period moving average.&lt;/p&gt;
&lt;p&gt;The Trend Based Signal System is based on a fast and slow period moving average, bullish momentum is based on the fast-period moving average moving above the slow-period moving average and bearish momentum is based on it moving below the slow-period moving average.&lt;/p&gt;
&lt;p&gt;When we receive a bullish candlestick pattern while price has bullish momentum, a bullish signal is output
When we receicve a bearish candlestick pattern while price has bearish momentum, a bearish signal is output.&lt;/p&gt;
&lt;p&gt;The Golden Cross Strategy is based on procedural coding in…&lt;/p&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/HloniTheCoder/Simple-Moving-Average-Data"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Identify Candlestick Patterns Using OOP in MQL5</title>
      <dc:creator>HloniTheCoder</dc:creator>
      <pubDate>Fri, 18 Aug 2023 22:33:56 +0000</pubDate>
      <link>https://dev.to/hlonithecoder/identify-candlestick-patterns-using-oop-in-mql5-46ac</link>
      <guid>https://dev.to/hlonithecoder/identify-candlestick-patterns-using-oop-in-mql5-46ac</guid>
      <description>&lt;h2&gt;
  
  
  Identify Candlestick Patterns Using Object Oriented Programming
&lt;/h2&gt;

&lt;p&gt;Identify Marubozu, Hammer, Inverted Hammer, Hanging Man, Shooting Star Candlestick Patterns.&lt;/p&gt;

&lt;p&gt;Access To The Full Code At The Bottom Of The File.&lt;/p&gt;

&lt;h2&gt;
  
  
  Program Description
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eLQZi07Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vi9j72nv4pyo3h2z2gdy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eLQZi07Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vi9j72nv4pyo3h2z2gdy.png" alt="Vertical Line Output" width="800" height="376"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A vertical line will be displayed when a candle pattern occurs.&lt;/p&gt;

&lt;p&gt;Each Candlestick Pattern has a colour to identify it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Bullish Marubozu are Red.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Bullish Hammers are Blue.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Bullish Inverted Hammers are Green.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Bearish Marubozu are Yellow.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Bearish Hanging Man are Orange.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Bearish Shooting Stars are Purple.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Code Description
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Get Class Data From The PriceDataClass

#include &amp;lt;IncludeTutorial/PriceDataClass.mqh&amp;gt;


//Access Candlestick Methods Using The HPriceData Class

HPriceData MyPriceData;


//Date Time Index Of The Candle Stick Types

datetime bull_maru_index;

datetime bull_hammer_index;

datetime bull_inv_hammer_index;

datetime bear_maru_index;

datetime bear_hang_man_index;

datetime bear_shoot_star_idex;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;At the top of our file we add the code above.&lt;/p&gt;

&lt;p&gt;We include the &lt;code&gt;IncludeTutorial/PriceDataClass.mqh&lt;/code&gt; file.&lt;br&gt;
This file contains the Price Data Classes we will be using.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Include Tutorial&lt;/code&gt; folder should be stored within your MQL5 Include folder that is provided when you install MetaTrader 5.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;HPriceData&lt;/code&gt; is the class we will be using. It has the candlestick methods to identify candle types.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;HPriceData MyPriceData;&lt;/code&gt; is an instance of the class.&lt;br&gt;
&lt;code&gt;MyPriceData&lt;/code&gt; will be used to access the necessary methods.&lt;/p&gt;

&lt;p&gt;The following code block should be written within the &lt;code&gt;OnTick()&lt;/code&gt; function.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MyPriceData.Add_Price_Data();

int candle_index = 1;

int avr_range = 7;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;code&gt;MyPriceData.Add_Price_Data();&lt;/code&gt; this method adds price data to the price data array that is used within the class.&lt;br&gt;
Without this method you cannot access recent data.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;int candle_index = 1;&lt;/code&gt; the candle index variable is used to index price data.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;int avr_range = 7;&lt;/code&gt; the average number of candles that will be used to determine long or short candles.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bool is_bull_maru = MyPriceData.Get_Long_Bullish_Marubozu_Type(candle_index, avr_range);

bool is_hammer = MyPriceData.Get_Long_Hammer_Type(candle_index, avr_range);

bool is_inv_hammer = MyPriceData.Get_Long_Inverted_Hammer_Type(candle_index, avr_range);

bool is_bear_maru = MyPriceData.Get_Long_Bearish_Marubozu_Type(candle_index, avr_range);

bool is_hang = MyPriceData.Get_Long_Hanging_Man_Type(candle_index, avr_range);

bool is_star = MyPriceData.Get_Long_Shooting_Star_Type(candle_index, avr_range);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We initialize the Boolean variables that hold candlestick pattern data.&lt;/p&gt;

&lt;p&gt;The values of the variables can either be True or False.&lt;br&gt;
True indicates the indexed candle is a candlestick pattern.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;datetime curr_Time = MyPriceData.Get_DateTime_Value(candle_index);

if(is_bull_maru)
  {

   bull_maru_index = curr_Time;

  }

if(is_hammer)
  {

   bull_hammer_index = curr_Time;

  }

if(is_inv_hammer)
  {

   bull_inv_hammer_index = curr_Time;

  }

if(is_bear_maru)
  {

   bear_maru_index = curr_Time;

  }

if(is_hang)
  {

   bear_hang_man_index = curr_Time;

  }

if(is_star)
  {

   bear_shoot_star_idex = curr_Time;

  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;If the candle is a candlestick pattern, we index the time.&lt;/p&gt;

&lt;p&gt;This is necessary to draw a vertical line.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ObjectCreate(0, "Bullish Marubozu Index", OBJ_VLINE, 0, bull_maru_index, 0,0);
ObjectSetInteger(0, "Bullish Marubozu Index", OBJPROP_COLOR, clrRed);

ObjectCreate(0, "Bearish Marubozu Index", OBJ_VLINE, 0, bear_maru_index, 0,0);
ObjectSetInteger(0, "Bearish Marubozu Index", OBJPROP_COLOR, clrYellow);

ObjectCreate(0, "Hammer Index", OBJ_VLINE, 0, bull_hammer_index, 0,0);
ObjectSetInteger(0, "Hammer Index", OBJPROP_COLOR, clrBlue);

ObjectCreate(0, "Inverted Hammer Index", OBJ_VLINE, 0, bull_inv_hammer_index, 0,0);
ObjectSetInteger(0, "Inverted Hammer Index", OBJPROP_COLOR, clrGreen);

ObjectCreate(0, "Hanging Man Index", OBJ_VLINE, 0, bear_hang_man_index, 0,0);
ObjectSetInteger(0, "Hanging Man Index", OBJPROP_COLOR, clrOrange);

ObjectCreate(0, "Shooting Star Index", OBJ_VLINE, 0, bear_shoot_star_idex, 0,0);
ObjectSetInteger(0, "Shooting Star Index", OBJPROP_COLOR, clrPurple);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We create a vertical line when we receive a candlestick pattern.&lt;br&gt;
Each candle pattern type has a colour associated with it.&lt;/p&gt;

&lt;p&gt;Full Code, Comments Included:&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--A9-wwsHG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/HloniTheCoder"&gt;
        HloniTheCoder
      &lt;/a&gt; / &lt;a href="https://github.com/HloniTheCoder/Candle-Stick-Data"&gt;
        Candle-Stick-Data
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;p&gt;Identify Candlestick Patterns Using MQL5&lt;/p&gt;
&lt;p&gt;Identify The Marubozu, Hammer, Inverted Hammer, Hanging Man, Shooting Star Candlestick Patterns.&lt;/p&gt;
&lt;p&gt;A Vertical Line Will Be Output Corresponding To The Candle Pattern Type.&lt;/p&gt;
&lt;p&gt;The IncludeTutorial Folder Has The File That Contains The Price Data Classes.&lt;/p&gt;
&lt;p&gt;The Class Based Candle Stick Data File Uses The Classes Contained In The Include Folder.&lt;/p&gt;
&lt;p&gt;The Candle Stick Data File Is Independent Of The Price Data Classes.&lt;/p&gt;
&lt;/div&gt;

  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/HloniTheCoder/Candle-Stick-Data"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Identify Candlestick Patterns Using MQL5</title>
      <dc:creator>HloniTheCoder</dc:creator>
      <pubDate>Fri, 18 Aug 2023 18:04:44 +0000</pubDate>
      <link>https://dev.to/hlonithecoder/identify-candlestick-patterns-using-mql5-4bin</link>
      <guid>https://dev.to/hlonithecoder/identify-candlestick-patterns-using-mql5-4bin</guid>
      <description>&lt;h2&gt;
  
  
  Identify Candlestick Patterns
&lt;/h2&gt;

&lt;p&gt;Identify the Marubozu, Hammer, Inverted Hammer, Hanging Man, Shooting Star Candlestick patterns.&lt;/p&gt;

&lt;p&gt;The MQL5 programming language is based on the MetaTrader 5 platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  Program Description
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Wmoy06Uk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u15gorze9twxbl2tet61.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Wmoy06Uk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u15gorze9twxbl2tet61.png" alt="Program Output With Drawn Vertical Lines" width="800" height="376"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The program will output a vertical line to identify a given candlestick pattern.&lt;/p&gt;

&lt;p&gt;Bullish Marubozu will be identified using a red vertical line.&lt;/p&gt;

&lt;p&gt;Bullish Hammer and Inverted Hammer will be identified using a blue and green line respectively.&lt;/p&gt;

&lt;p&gt;Bearish Marubozu will be identified with yellow.&lt;br&gt;
Bearish Hanging Man will be identified with orange.&lt;br&gt;
Bearish Shooting Star will be identified with purple.&lt;/p&gt;
&lt;h2&gt;
  
  
  Code Description
&lt;/h2&gt;

&lt;p&gt;We will begin our project within the onTick function within the MQL editor.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RWch4hnz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ngk1blxjmyv4k8vi65xz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RWch4hnz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ngk1blxjmyv4k8vi65xz.png" alt="OnTick Function Description" width="800" height="402"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;OnTick()&lt;/code&gt; function executes on every price change.&lt;br&gt;
Within this function we will write our program logic.&lt;/p&gt;

&lt;p&gt;Within the &lt;code&gt;OnTick()&lt;/code&gt; Function we will initialize our price data array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Array To Store Price Data
MqlRates price_data_array[];

//Set The Most Recent Item To Index 0
ArraySetAsSeries(price_data_array, true);

//Copy Price Data To The Array
//Starting From 0 To 100 Price Data Items
CopyRates(_Symbol, _Period, 0, 100, price_data_array);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The first line initializes the array we will use to store price data.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;MqlRates price_data_array[];&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;ArraySetAsSeries&lt;/code&gt; function makes it so that index 0 in our &lt;code&gt;price_data_array&lt;/code&gt; is the most recent price data.&lt;/p&gt;

&lt;p&gt;This is an important function that if not included changes the functionality of the program.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ArraySetAsSeries(price_data_array, true);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;CopyBuffer&lt;/code&gt; function copies the price data of the current symbol, on the current timeframe to the &lt;code&gt;price_data_array[]&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This allows us to access the date OHLCV data of the current symbol.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;CopyBuffer(_Symbol, _Period, 0, 100, price_data_array[]);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We will copy data from index 0 to index 100.&lt;br&gt;
Index 0 is the currently forming candle.&lt;br&gt;
Index 1 is the most recently formed candle.&lt;br&gt;
Index 100 is the 100th candle away from the most recent candle.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int candle_index = 1;

double curr_close_value = price_data_array[candle_index].close;
double curr_open_value = price_data_array[candle_index].open;
double curr_low_value = price_data_array[candle_index].low;
double curr_high_value = price_data_array[candle_index].high;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We will initialize variables to store our OHLC Data of the most recent candle.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;int candle_index=1;&lt;/code&gt;&lt;br&gt;
This variable stores the index of the candle whose candle pattern type we want.&lt;br&gt;
Index 1 is the most recently completed candlestick.&lt;/p&gt;

&lt;p&gt;Next we will begin calculating average candlestick values.&lt;br&gt;
A candlestick will be considered long if it is greater than the average candle size.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int avg_range = 5; //Length Of Average

for(int i=candle_index;i&amp;lt;=avg_range;i++)
     {

      int val_index = i + 1;

      double open_value = price_data_array[val_index].open;

      double high_value = price_data_array[val_index].high;

      double low_value = price_data_array[val_index].low;

      double close_value = price_data_array[val_index].close;

      double body_size = MathAbs(open_value - close_value);

      double upper_size = 0;

      double lower_size = 0;

      //If The Currently Indexed Candle Is Bullish Or Bearish

      if(close_value &amp;gt; open_value)
        {

         upper_size = MathAbs(high_value - close_value);

         lower_size = MathAbs(open_value - low_value);

        }

      else
        {

         upper_size = MathAbs(high_value - open_value);

         lower_size = MathAbs(close_value - low_value);

        }

      avg_body_sum_value += body_size;

      avg_upper_sum_value += upper_size;

      avg_lower_sum_value += lower_size;

     }


   //Average Body, Upper, and Lower Wick Size Values

   double avg_body_size = avg_body_sum_value / avg_range;

   double avg_upper_size = avg_upper_sum_value / avg_range;

   double avg_lower_size = avg_lower_sum_value / avg_range;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In this code block we are calculating the average body size value, average upper wick size, and average lower wick size.&lt;/p&gt;

&lt;p&gt;The Body Size is calculated by subtracting the candle open value with the candle close value.&lt;/p&gt;

&lt;p&gt;The Upper Size is calculated by subtracting the candle high from the candle close if bullish, else if bearish we subtract candle high with candle open.&lt;/p&gt;

&lt;p&gt;The Lower Size is calculated by subtracting the candle open with the candle low if bullish, else if bearish we subtract candle close with candle low.&lt;/p&gt;

&lt;p&gt;The Average Candlestick Data is calculated at an average range of 5 items but this value may be easily changed.&lt;/p&gt;

&lt;p&gt;The higher average range value the more candles will be used in the calculation.&lt;/p&gt;

&lt;p&gt;Next we will calculate Candlestick Data (Body Size, Upper Wick Size, Lower Wick Size) using the most recent candle values.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;double curr_body_size = MathAbs(curr_open_value - curr_close_value);

double curr_upper_size = 0;

double curr_lower_size = 0;

//Determine Whether The Current Candle Is Bullish Or Bearish

bool curr_candle_is_bullish = curr_close_value &amp;gt; curr_open_value;

bool curr_candle_is_bearish = curr_open_value &amp;gt; curr_close_value;


if(curr_candle_is_bullish)
  {

   curr_upper_size = MathAbs(curr_high_value - curr_close_value);

   curr_lower_size = MathAbs(curr_open_value - curr_low_value);

  }

else
  {

   curr_upper_size = MathAbs(curr_high_value - curr_open_value);

   curr_lower_size = MathAbs(curr_close_value - curr_low_value);

  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In this code block we are calculating the Body Size, Upper Size, and Lower Size for the current candle.&lt;/p&gt;

&lt;p&gt;A candle is bullish if the close is greater than the open, and is bearish if the open is greater than the close.&lt;/p&gt;

&lt;p&gt;If a candle is bullish, the upper size is the difference between the high value and the close value, the lower size is the difference between the open value and the low value.&lt;/p&gt;

&lt;p&gt;If a candle is bearish, the upper size is the difference between the high value and the open value, the lower size is the difference between the close value and the low value.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Determine Whether The Candlestick Data Is Long Or Short

//Candle Data Is Long If It Is Greater Than 1.5 Times The Input

//The inp_val Will Typically Be The Average Value

bool Calculate_Is_Long(double curr_val, double inp_val){

   bool is_long = (curr_val &amp;gt;= (inp_val * 1.5));

   return(is_long);

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;At the top of our file we will create the &lt;code&gt;Calculate_Is_Long()&lt;/code&gt; function, this function is used to determine if a value is long as compared to the average.&lt;/p&gt;

&lt;p&gt;We will use the function to Calculate whether the Body Size, Upper Size, Lower Size is Long.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Determine If The Body, Upper, Lower Wick Are Long

//A Value Is Long If It Is Greater Than The Average Value Times 1.5

bool body_is_long = Calculate_Is_Long(curr_body_size, avg_body_size);

bool upper_is_long = Calculate_Is_Long(curr_upper_size, avg_upper_size);

bool lower_is_long = Calculate_Is_Long(curr_lower_size, avg_lower_size);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Within the &lt;code&gt;OnTick()&lt;/code&gt; function we will include the above code script.&lt;/p&gt;

&lt;p&gt;We initialize variables that have the values of whether or not the current Body, Upper, or Lower value is Long.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Calculate The Percentage Value

//Will Be Used To Calculate The Percentage Value Of
//The Body Size, Upper Wick, and Lower Wick Relative To
//The Total Candlestick Size

double Calculate_Percentage_Value(double curr_val, double total_val){

   double div_value = curr_val / total_val;

   double perc_value = div_value * 100;

   return(NormalizeDouble(perc_value, 5));

}


//Determine If Candle Data Is Significant

//If The Body, Upper Wick, or Lower Wick Size Is Significant
//It Means It Occupies Most Of The Candle

bool Calculate_Is_Significant(double perc_value){

   bool is_sig = (perc_value &amp;gt; 70);

   return(is_sig);

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;At the top of our file we will create two more functions.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;Calculate_Percentage_Value()&lt;/code&gt; function calculates the percentage value compared to the total value.&lt;/p&gt;

&lt;p&gt;We will use this function to calculate the body, upper, and lower wick size compared to the total candle size.&lt;/p&gt;

&lt;p&gt;The next function is &lt;code&gt;Calculate_Is_Significant()&lt;/code&gt; function which calculates whether candle data occupies most of the candle.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;double curr_candle_size = MathAbs(curr_high_value - curr_low_value);

//Calculating The Body, Upper, Lower Wick Percentage Values

//Determining The Percentage Value Of Candle Data Compared To The Candle Size

double curr_body_perc_value = Calculate_Percentage_Value(curr_body_size, curr_candle_size);

double curr_upper_perc_value = Calculate_Percentage_Value(curr_upper_size, curr_candle_size);

double curr_lower_perc_value = Calculate_Percentage_Value(curr_lower_size, curr_candle_size);


//Determine If Candle Data Is Significant

//Body, Upper, Lower Wick Values Are Significant If
//They Occupy Most Of The Candle Size

bool curr_body_is_significant = Calculate_Is_Significant(curr_body_perc_value);

bool curr_upper_is_significant = Calculate_Is_Significant(curr_upper_perc_value);

bool curr_lower_is_significant = Calculate_Is_Significant(curr_lower_perc_value);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Within the &lt;code&gt;OnTick()&lt;/code&gt; function we will write the above code.&lt;/p&gt;

&lt;p&gt;We will find the percentage value of the body size, upper size, and lower size.&lt;/p&gt;

&lt;p&gt;Once we have the percentage values, we will determine whether or not the body size, upper, lower size values are significant in the candle.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Determine If The Candle Is Of A Type

//If The Body, Upper Wick, or Lower Wick Is Both
//Long And Significant It Is A Type

bool Return_Is_Candle_Type(bool is_long, bool is_sig){

   bool is_type = is_long &amp;amp;&amp;amp; is_sig;

   return(is_type);

}


//Date Time Index Of The Candle Stick Types

datetime bull_maru_index;

datetime bull_hammer_index;

datetime bull_inv_hammer_index;

datetime bear_maru_index;

datetime bear_hang_man_index;

datetime bear_shoot_star_idex;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;At the top of our file we will add the last functions to determine the candlestick types.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Return_Is_Candle_Type()&lt;/code&gt; this function returns whether or not our candle data is a candle type.&lt;br&gt;
A candle type has a long value and the value is significant.&lt;/p&gt;

&lt;p&gt;The datetime indexes will be used to find the location of our candlestick pattern types.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Determine Whether The Body, Upper, Or Lower Wick Are Long Types

//A Long Type Is Both Significant And Long(Greater Than The Average Value)

bool body_is_long_type = Return_Is_Candle_Type(body_is_long, curr_body_is_significant);

bool upper_is_long_type = Return_Is_Candle_Type(upper_is_long, curr_upper_is_significant);

bool lower_is_long_type = Return_Is_Candle_Type(lower_is_long, curr_lower_is_significant);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Within the &lt;code&gt;OnTick()&lt;/code&gt; function we initialize variables to contain the values of whether or not our candle values are of the long type.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Determine Marubozu Type Candles

//Is Bullish Marubozu If The Candle Is Bullish And The Body Is A Long Type
bool is_bull_maru = (curr_candle_is_bullish &amp;amp;&amp;amp; body_is_long_type);

//Is Bearish Marubozu If The Candle Is Bearish And The Body Is A Long Type
bool is_bear_maru = (curr_candle_is_bearish &amp;amp;&amp;amp; body_is_long_type);


//Determine Hammer And Inverted Hammer Type Candles

//Is Bullish Hammer If The Candle Is Bullish And The Lower Is A Long Type
bool is_bull_hammer = (curr_candle_is_bullish &amp;amp;&amp;amp; lower_is_long_type);

//Is Bullish Inverted Hammer If The Candle Is Bullish And The Upper Is A Long Type
bool is_bull_inv_hammer = (curr_candle_is_bullish &amp;amp;&amp;amp; upper_is_long_type);


//Determine Hanging Man And Shooting Star Type Candles

//Is Bearish Hanging Man If The Candle Is Bearish And The Lower Is A Long Type
bool is_bear_hang_man = (curr_candle_is_bearish &amp;amp;&amp;amp; lower_is_long_type);

//Is Bearish Shooting Star If The Candle Is Bearish And The Upper Is A Long Type
bool is_bear_star = (curr_candle_is_bearish &amp;amp;&amp;amp; upper_is_long_type);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The above code block identifies the individual bullish and bearish candle types.&lt;/p&gt;

&lt;p&gt;A Bullish Marubozu has a long body type and the body is significant and the candle is bullish.&lt;/p&gt;

&lt;p&gt;A Bullish Hammer has a long lower wick type and the lower wick is significant and the candle is bullish.&lt;/p&gt;

&lt;p&gt;A Bullish Inverted Hammer has a long upper wick type and the upper wick is significant and the candle is bullish.&lt;/p&gt;

&lt;p&gt;A Bearish Marubozu has a long body type, the body is significant, and the candle is bearish.&lt;/p&gt;

&lt;p&gt;A Bearish Hanging Man Type has a long lower wick, the lower wick is significant, and the candle is bearish.&lt;/p&gt;

&lt;p&gt;A Bearish Shooting Star has a long upper wick, the upper wick is significant, and the candle is bearish.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Add Candle Type Indexes For Output

if(is_bull_maru)
  {

   bull_maru_index = price_data_array[candle_index].time;

  }

if(is_bull_hammer)
 {

  bull_hammer_index = price_data_array[candle_index].time;

 }

if(is_bull_inv_hammer)
 {

  bull_inv_hammer_index = price_data_array[candle_index].time;

 }

if(is_bear_maru)
 {

 bear_maru_index = price_data_array[candle_index].time;

 }

if(is_bear_hang_man)
 {

 bear_hang_man_index = price_data_array[candle_index].time;

}

if(is_bear_star)
  {

   bear_shoot_star_idex = price_data_array[candle_index].time;

  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The code above initializes the candlestick pattern types to the datetime indexes of those candle types.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Output Candle Type Data As A Vertical Line

//The Most Recent Candle Of Each Type Will Be Output

ObjectCreate(0, "Bullish Marubozu Index", OBJ_VLINE, 0, bull_maru_index, 0,0);

ObjectSetInteger(0, "Bullish Marubozu Index", OBJPROP_COLOR, clrRed);


ObjectCreate(0, "Bearish Marubozu Index", OBJ_VLINE, 0, bear_maru_index, 0,0);

ObjectSetInteger(0, "Bearish Marubozu Index", OBJPROP_COLOR, clrYellow);


ObjectCreate(0, "Hammer Index", OBJ_VLINE, 0, bull_hammer_index, 0,0);

ObjectSetInteger(0, "Hammer Index", OBJPROP_COLOR, clrBlue);


ObjectCreate(0, "Inverted Hammer Index", OBJ_VLINE, 0, bull_inv_hammer_index, 0,0);

ObjectSetInteger(0, "Inverted Hammer Index", OBJPROP_COLOR, clrGreen);


ObjectCreate(0, "Hanging Man Index", OBJ_VLINE, 0, bear_hang_man_index, 0,0);

ObjectSetInteger(0, "Hanging Man Index", OBJPROP_COLOR, clrOrange);


ObjectCreate(0, "Shooting Star Index", OBJ_VLINE, 0, bear_shoot_star_idex, 0,0);

ObjectSetInteger(0, "Shooting Star Index", OBJPROP_COLOR, clrPurple);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This final code block is what outputs the vertical lines corresponding to the individual candlestick pattern types.&lt;/p&gt;

&lt;p&gt;A link to the full code: &lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--A9-wwsHG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/HloniTheCoder"&gt;
        HloniTheCoder
      &lt;/a&gt; / &lt;a href="https://github.com/HloniTheCoder/Candle-Stick-Data"&gt;
        Candle-Stick-Data
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;p&gt;Identify Candlestick Patterns Using MQL5&lt;/p&gt;
&lt;p&gt;Candlestick Patterns Include Marubozu, Hammer, Inverted Hammer, Hanging Man, Shooting Star&lt;/p&gt;
&lt;p&gt;Candlstick Patterns Are Identified Using A Vertical Line Object&lt;/p&gt;
&lt;p&gt;The Implementation can be modified to include additional candlestick patterns and methods of output such as arrows, boxes, and text&lt;/p&gt;
&lt;p&gt;Red Is Used To Identify Bullish Marubozu&lt;/p&gt;
&lt;p&gt;Blue Is Used To Identify Bullish Hammers&lt;/p&gt;
&lt;p&gt;Green Is Used To Identify Bullish Inverted Hammers&lt;/p&gt;
&lt;p&gt;Yellow Is Used To Identify Bearish Marubozu&lt;/p&gt;
&lt;p&gt;Orange Is Used To Identify Bearish Hanging Man&lt;/p&gt;
&lt;p&gt;Purple Is Used To Identify Bearish Shooting Star&lt;/p&gt;
&lt;/div&gt;

  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/HloniTheCoder/Candle-Stick-Data"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
