Download MetaTrader 5
To add comments, please log in or register
Do you have questions to the application's developer - ask them in Comments section
Linton
6
Linton 2014.04.12 08:03 
Hi everyone,

I'm currently modifying a candlestick pattern indicator downloaded from the internet.

I've added the additional conditions under the *Bearish engulfing pattern* that the range of the current bar (H-L) must be greater than the range of previous 6 candles.

The additional code is:((H - L) > (H1 - L1) && (H2 - L2) && (H3 - L3) && (H4 - L4) && (H5 - L5) && (H6 - L6)))

Of course if I add this, I have to declare the additional H4, H5, H6, L4, L5 L6 variables (which I did: double O, O1, O2, C, C1, C2, L, L1, L2, L3, L4, L5, L6, H, H1, H2, H3, H4, H5, H6; )

Also, I have also added int shift3; int shift4; etc

However, why doesn't the indicator register the condition: range of the current bar (H-L) must be greater than the range of previous 6 candles.

(I have attached the original mq4 file as well)


#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Black
#property indicator_color2 Black
//----
extern bool Show_Alert = true;
extern bool Display_Bearish_Engulfing = true;
extern bool Display_Three_Outside_Down = false;
extern bool Display_Three_Inside_Down = false;
extern bool Display_Dark_Cloud_Cover = false;
extern bool Display_Three_Black_Crows = false;
extern bool Display_Bullish_Engulfing = true;
extern bool Display_Three_Outside_Up = false;
extern bool Display_Three_Inside_Up = false;
extern bool Display_Piercing_Line = false;
extern bool Display_Three_White_Soldiers = false;
extern bool Display_Stars = false;
extern bool Display_Harami = false;
extern bool Inside_Bar_Bull = false;
extern bool Inside_Bar_Bear = false;
//---- buffers
double upArrow[];
double downArrow[];
string PatternText[5000];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0, DRAW_ARROW, 0, 1);
SetIndexArrow(0, 242);
SetIndexBuffer(0, downArrow);
//----
SetIndexStyle(1, DRAW_ARROW, 0, 1);
SetIndexArrow(1, 241);
SetIndexBuffer(1, upArrow);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
ObjectsDeleteAll(0, OBJ_TEXT);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double Range, AvgRange;
int counter, setalert;
static datetime prevtime = 0;
int shift;
int shift1;
int shift2;
int shift3;
int shift4;
int shift5;
int shift6;
int shift7;
string pattern, period;
int setPattern = 0;
int alert = 0;
int arrowShift;
int textShift;
double O, O1, O2, C, C1, C2, L, L1, L2, L3, L4, L5, L6, H, H1, H2, H3, H4, H5, H6;
//----
if(prevtime == Time[0])
{
return(0);
}
prevtime = Time[0];
//----
switch(Period())
{
case 1: period = "M1"; break;
case 5: period = "M5"; break;
case 15: period = "M15"; break;
case 30: period = "M30"; break;
case 60: period = "H1"; break;
case 240: period = "H4"; break;
case 1440: period = "D1"; break;
case 10080: period = "W1"; break;
case 43200: period = "MN"; break;
}
//----
for(int j = 0; j < Bars; j++)
{
PatternText[j] = "pattern-" + j;
}
//----
for(shift = 0; shift < Bars; shift++)
{
setalert = 0;
counter = shift;
Range = 0;
AvgRange = 0;
for(counter = shift; counter <= shift + 13; counter++)
{
AvgRange = AvgRange + MathAbs(High[counter] - Low[counter]);
}
Range = AvgRange / 10;
shift1 = shift + 1;
shift2 = shift + 2;
shift3 = shift + 3;
shift4 = shift + 4;
shift5 = shift + 5;
shift6 = shift + 6;
shift7 = shift + 7;
O = Open[shift1];
O1 = Open[shift2];
O2 = Open[shift3];
H = High[shift1];
H1 = High[shift2];
H2 = High[shift3];
H3 = High[shift3+1];
H4 = High[shift3+2];
H5 = High[shift3+3];
H6 = High[shift3+4];
L = Low[shift1];
L1 = Low[shift2];
L2 = Low[shift3];
L3 = Low[shift3+1];
L4 = Low[shift3+2];
L5 = Low[shift3+3];
L6 = Low[shift3+4];
C = Close[shift1];
C1 = Close[shift2];
C2 = Close[shift3];
// Bearish patterns
// Bearish Engulfing pattern
if((C1 > O1) && (O > C) && (O1 >= C) && (H > H1) && (L < L1) && ((O - C) > (C1 - O1)) && ((H - L) > (H1 - L1) && (H2 - L2) && (H3 - L3) && (H4 - L4) && (H5 - L5) && (H6 - L6)))
{
if(Display_Bearish_Engulfing == true)
{
ObjectCreate(PatternText[shift], OBJ_TEXT, 0, Time[shift1],
High[shift1] + Range*1.5);
ObjectSetText(PatternText[shift], "Bearish Engulfing pattern", 10,
"Arial", Black);
downArrow[shift1] = High[shift1] + Range*0.5;
}
if(setalert == 0 && Show_Alert == true)
{
pattern = "Bearish Engulfing pattern";
setalert = 1;
}
}

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.04.12 08:04  

Please use SRC ...

qjol
3243
qjol 2014.04.13 00:07  
&& (H2 - L2) > (H - L) && (H3 - L3) > (H - L) && ...
/
To add comments, please log in or register