-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_Engulfing_GCI.mq4
124 lines (103 loc) · 3.27 KB
/
_Engulfing_GCI.mq4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//+------------------------------------------------------------------+
#property copyright ""
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Blue
input int MAPeriod=14; // Period
input int BodyCoef=1;
double BodyStatBuffer[];
double Up[],Dn[];
int MAShift=-2; // Shift
//+------------------------------------------------------------------+
int init()
{
IndicatorDigits(Digits);
SetIndexShift(2,MAShift);
SetIndexBuffer(0,Up);
SetIndexBuffer(1,Dn);
SetIndexBuffer(2,BodyStatBuffer);
SetIndexDrawBegin(2,MAShift+MAPeriod);
SetIndexStyle(0,DRAW_ARROW,EMPTY,3);
SetIndexStyle(1,DRAW_ARROW,EMPTY,3);
SetIndexStyle(2,DRAW_LINE, EMPTY,3);
SetIndexLabel(0,"Example");
SetIndexArrow(0,233);
SetIndexArrow(1,234);
return(0);
}
//+------------------------------------------------------------------+
int start()
{
int i,j,CountBars=Bars-1;
double BodyTotal;
double BodyAverage;
double BodyStat;
for(i=0; i<CountBars; i++)
{
BodyTotal = 0.0;
BodyAverage = 0.0;
BodyStat = 0.0;
Up[i]=0.0; Dn[i]=0.0;//init array
//get average pips between open and close prices for the past periods.
for(j=0; j<MAPeriod; j++)
{
BodyTotal += MathAbs(Open[j+1] - Close[j+1]);
}
BodyAverage = BodyTotal/MAPeriod;
//BodyStat is the Stat2PreValue
BodyStat = iMA(NULL,0,MAPeriod,0,MODE_SMA,PRICE_CLOSE,i);
//graphical representation of Stat2PreValue
//BodyStatBuffer[i]=iMA(NULL,0,MAPeriod,0,MODE_SMA,PRICE_CLOSE,i);
//Bullish Signal
if(
Close[i+2] < Open[i+2] &&
Close[i+1] - Open[i+1] > BodyCoef * BodyAverage &&
Close[i+1] > Open[i+2] &&
(Open[i+1] - Close[i+1])/2 < BodyStat &&
Open[i+1] <= MathMax(Close[i+2], Low[i+2])
)
{
//Up[i]= Low[i] - (High[i] - Low[i]);
Up[i]= Open[i] - Point;
}
//Bearish Signal
if(
Close[i+2] > Open[i+2]
&& Close[i+1] - Open[i+1] < BodyCoef * BodyAverage
&& Close[i+1] < Open[i+2]
&& (Open[i+1] + Close[i+1])/2 > BodyStat
&& Open[i+1] >= MathMin(Close[i+2], High[i+2])
)
{
Dn[i]= Open[i] + Point;
}
//Traditional Signal without use of MA
/*
if(
Close[i+2]<Open[i+2] //first bar being bearish
&& Close[i+1]>Open[i+1] //second bar being bullish
&& Open[i+2]<=Close[i+1] //open of first bar <= than close of second bar
&& Close[i+2]>=Open[i+1] //close of first bar >= than open of second bar
)
{
Up[i]= Low[i] - (High[i] - Low[i]);
}
//Bearish Signal
if(
Close[i+2]>Open[i+2]
&&Close[i+1]<Open[i+1]
&& Open[i+2]>=Close[i+1]
&& Close[i+2]<=Open[i+1]
)
{
Dn[i]= High[i] + (High[i] - Low[i]);
}
*/
}
return(0);
}
//+------------------------------------------------------------------+
int deinit() { return(0); }
//+------------------------------------------------------------------+