Basing Candlesticks

Enivid

Administrator
Staff member
Nov 30, 2008
16,040
817
144
Odessa
www.earnforex.com
As basing candles indicate a period of indecision they can be used for breakout trading, trend reversal spotting, and exiting trades. However, it is a weak indicator - it shouldn't be used as the sole signal for entering or exiting positions.
 
Apr 17, 2020
2
0
6
35
Hi!

First of all, thanks for sharing this indicator!

The question i have is the following:
Is it possible in mql4 to send alerts for the basing candle only, if a basing candle is formed in a definded rectangle?

For example:
I draw a red rectangle as my trading zone where i want to look for entry signals. And i only want alerts of the forming of a basing candle in this zone.
Especially, is mql4 able to differentiate if rectangle is red or green?

I don't know if it's hard to code or if you have the time to code this, but of course i will pay for your work.

Thanks in advance for your answer!
 

Enivid

Administrator
Staff member
Nov 30, 2008
16,040
817
144
Odessa
www.earnforex.com
Currently, the Basing Candlesticks indicator cannot do that. But this can definitely be coded. However, if you expect me to do this, consider the waiting time of about 6-12 months. You may be better off hiring someone to do that modification for you.
 
Apr 17, 2020
2
0
6
35
Currently, the Basing Candlesticks indicator cannot do that. But this can definitely be coded. However, if you expect me to do this, consider the waiting time of about 6-12 months. You may be better off hiring someone to do that modification for you.
Many thanks for your prompt reply ✌

I will look if I can find someone.
 

Enivid

Administrator
Staff member
Nov 30, 2008
16,040
817
144
Odessa
www.earnforex.com
The arrow position is in the O[] buffer. Change O[i] = Open[i]; to O[i] = High[i] + <some number of pips>; and it will move to above the candle. For different colors, you either use two separate indicator buffers and plots or you rewrite it from DRAW_ARROW to DRAW_COLOR_ARROW and use a color buffer.
 
  • Like
Reactions: pkartaaa85

pkartaaa85

Trader
Oct 11, 2020
6
0
17
38
The arrow position is in the O[] buffer. Change O[i] = Open[i]; to O[i] = High[i] + <some number of pips>; and it will move to above the candle. For different colors, you either use two separate indicator buffers and plots or you rewrite it from DRAW_ARROW to DRAW_COLOR_ARROW and use a color buffer.
Thanks will try and come back..
 

Kalai05art

Trader
Dec 24, 2020
4
0
7
34
or i want include in addition to basing candle
candle height< open *0.8(some %) and body height< close*0.3(some %)
admin can you help
 

Enivid

Administrator
Staff member
Nov 30, 2008
16,040
817
144
Odessa
www.earnforex.com
How to compare the candle height with day open price for same basing candle
or i want include in addition to basing candle
candle height< open *0.8(some %) and body height< close*0.3(some %)
admin can you help
You would have to change the indicator's code to attain that.
 

Kalai05art

Trader
Dec 24, 2020
4
0
7
34
You would have to change the indicator's code to attain that.
MQL5:
//+------------------------------------------------------------------+
//|                                          Basingmod.mq5            |
//|                                   Copyright © 2019, EarnForex.com |
//|                                        https://www.earnforex.com/ |
//+------------------------------------------------------------------+
 
#property copyright "Copyright 2019, EarnForex.com"
 
#property link      "https://www.earnforex.com/metatrader-indicators/Basing-Candlesticks/"
 
#property version   "1.00"
 
 
 
#property description "Marks candlesticks with body < 50% of overall length (high-low range)."
 
 
 
#property indicator_chart_window
 
#property indicator_buffers 4
 
#property indicator_plots 1
 
#property indicator_type1 DRAW_ARROW
 
#property indicator_style1 STYLE_SOLID
 
#property indicator_color1 clrSpringGreen
 
#property indicator_width1 1
 
 
 
input int Percentage = 50; // Percentage for Basing Candle calculation.
 
input int TriggerCandle = 1; // TriggerCandle: Number of candle to check for alerts.
 
input color DisplayBullColor = clrLimeGreen;
 
input color DisplayBearColor = clrRed;
 
input int DisplayDistance = 0;
 
input ushort   code=108; // Symbol code to draw in DRAW_ARROW
 
input bool EnableNativeAlerts = false; // EnableNativeAlerts: Alert popup inside platform.
 
input bool EnableSoundAlerts = false; // EnableSoundAlerts: Play a sound on alert.
 
input bool EnableEmailAlerts = false; // EnableEmailAlerts: Send an email on alert.
 
input bool EnablePushAlerts = false; // EnablePushAlerts: Send a push notification on alert.
 
input double CandleHeightToOpen = 0.22; // candle height /candle open ratio
 
input double BodyHeightToCandleHeight = 0.30; // Body height/candle height  ratio
 
input string AlertEmailSubject = "";
 
input string AlertText = "";
 
input string SoundFileName    = "alert.wav";
 
 
double H[];
 
double L[];
 
double O[];
 
double C[];
 
 
 
datetime LastAlertTime = D'01.01.1970';
 
//--- An array to store colors
 
color colors[]={clrGreen};
 
 
 
//+------------------------------------------------------------------+
 
//| Custom indicator initialization function                         |
 
//+------------------------------------------------------------------+
 
int OnInit()
 
{
 
   SetIndexBuffer(0, O, INDICATOR_DATA);
 
   SetIndexBuffer(1, H, INDICATOR_DATA);
 
   SetIndexBuffer(2, L, INDICATOR_DATA);
 
   SetIndexBuffer(3, C, INDICATOR_DATA);
 
 
 
   //--- Define the symbol code for drawing in PLOT_ARROW
 
   PlotIndexSetInteger(0,PLOT_ARROW,171);
 
 
 
   //--- Set the vertical shift of arrows in pixels
 
   PlotIndexSetInteger(0,PLOT_ARROW_SHIFT,-20);
 
 
 
   ArraySetAsSeries(O, true);
 
   ArraySetAsSeries(H, true);
 
   ArraySetAsSeries(L, true);
 
   ArraySetAsSeries(C, true);
 
 
 
   LastAlertTime = iTime(Symbol(), Period(), 0);
 
 
 
   return(INIT_SUCCEEDED);
 
}
 
 
 
//+------------------------------------------------------------------+
 
//| Custom indicator main iteration function                         |
 
//+------------------------------------------------------------------+
 
int OnCalculate(const int rates_total,
 
                const int prev_calculated,
 
                const datetime &Time[],
 
                const double &Open[],
 
                const double &High[],
 
                const double &Low[],
 
                const double &Close[],
 
                const long &tick_volume[],
 
                const long &volume[],
 
                const int &spread[])
 
 {
 
   ArraySetAsSeries(Open, true);
 
   ArraySetAsSeries(High, true);
 
   ArraySetAsSeries(Low, true);
 
   ArraySetAsSeries(Close, true);
 
   ArraySetAsSeries(Time, true);
 
 
 
   int counted_bars = prev_calculated;
 
   if (counted_bars < 0) return(-1);
 
   if (counted_bars > 0) counted_bars--;
 
   int i = rates_total - counted_bars - 1;
 
   if (i == 0) i++;
 
 
 
   while(i >= 0)
 
   {
 
      double length = High[i] - Low[i];
 
      double body = MathAbs(Open[i] - Close[i]);
 
      double percentage = (double)Percentage / 100.0;
 
      if ((length != 0) && (body / length <= percentage))
 
      {
     if( length-open[i]<= open[i] * CandleHeightToOpen
 
       {   
        if( body <= length) * BodyHeightToCandleHeight
 
 
         H[i] = High[i];
 
         L[i] = Low[i];
 
         O[i] = High[i]+1/8;
 
         C[i] = Close[i];
 
          }
 
      else
 
      {
 
         H[i] = EMPTY_VALUE;
 
         L[i] = EMPTY_VALUE;
 
         O[i] = EMPTY_VALUE;
 
         C[i] = EMPTY_VALUE;
 
 
 
 
 
      }
 
        i--;
 
   }
 
 
 
 
 
   if (Time[0] > LastAlertTime)
 
    {
 
       string Text;
 
       // Basing Candle Alert
 
       if (H[TriggerCandle] != EMPTY_VALUE)
 
       {
 
           Text = AlertText + "Basing Candle Alert: " + Symbol() + " - " + TF2Str(Period()) + ".";
 
           if (EnableNativeAlerts) Alert(Text);
 
           if (EnableEmailAlerts) SendMail(AlertEmailSubject + "Basing Candle Alert", Text);
 
           if (EnableSoundAlerts) PlaySound(SoundFileName);
 
           if (EnablePushAlerts) SendNotification(Text);
 
           LastAlertTime = Time[0];
 
 
 
 
 
       }
 
   }
 
 
 
   return(rates_total);
 
}
 
 
 
//+------------------------------------------------------------------+
 
//| Converts Period() to normal string value.                        |
 
//+------------------------------------------------------------------+
 
string TF2Str(int period)
 
{
 
   switch(period)
 
   {
 
      case PERIOD_M1: return("M1");
 
      case PERIOD_M2: return("M2");
 
      case PERIOD_M3: return("M3");
 
      case PERIOD_M4: return("M4");
 
      case PERIOD_M5: return("M5");
 
      case PERIOD_M6: return("M6");
 
      case PERIOD_M10: return("M10");
 
      case PERIOD_M12: return("M12");
 
      case PERIOD_M15: return("M15");
 
      case PERIOD_M20: return("M20");
 
      case PERIOD_M30: return("M30");
 
      case PERIOD_H1: return("H1");
 
      case PERIOD_H2: return("H2");
 
      case PERIOD_H3: return("H3");
 
      case PERIOD_H4: return("H4");
 
      case PERIOD_H6: return("H6");
 
      case PERIOD_H8: return("H8");
 
      case PERIOD_H12: return("H12");
 
      case PERIOD_D1: return("D1");
 
      case PERIOD_W1: return("W1");
 
      case PERIOD_MN1: return("MN");
 
      default: return("Unknown");
 
   }
 
   return(EnumToString((ENUM_TIMEFRAMES)Period()));
 
  }
 
//+-------------------------