-
Notifications
You must be signed in to change notification settings - Fork 2
/
visual-macd.mq4
118 lines (104 loc) · 3.76 KB
/
visual-macd.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
//+------------------------------------------------------------------+
//| ytg_DveMashki_ind.mq4 |
//| Yuriy Tokman |
//| [email protected] |
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman"
#property link "[email protected]"
// Äîïîëíåíèÿ [email protected]
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 DarkSlateBlue
#property indicator_color2 Maroon
#property indicator_color3 Yellow
#property indicator_color4 MediumTurquoise
#property indicator_width1 6
#property indicator_width2 6
#property indicator_width3 1
#property indicator_width4 1
//----
extern int ma_1 = 28;
extern int ma_2 = 144;
extern int method = 3;
extern int price = 0;
extern int signal = 14;
extern int s_method = 0;
extern int signal2 = 70;
extern int s_method2 = 0;
extern color color1 = DarkSlateBlue;
extern color color2 = Maroon;
extern color color3 = Yellow;
extern color color4 = MediumTurquoise;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double MACD_Map[];
double SignalLine[];
double SignalLine2[];
double SignalMap2[];
double SignalMap[];
//----
int ExtCountedBars=0;
//\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
int init()
{
//---- indicators
IndicatorBuffers(7);
SetIndexStyle(0,DRAW_HISTOGRAM, 0, 6, color1);
SetIndexBuffer(0, ExtMapBuffer1);
SetIndexStyle(1,DRAW_HISTOGRAM, 0, 6, color2);
SetIndexBuffer(1, ExtMapBuffer2);
SetIndexStyle(2,DRAW_LINE, 0, 1, color3);
SetIndexBuffer(2, SignalLine);
SetIndexStyle(3,DRAW_LINE, 0, 1, color4);
SetIndexBuffer(3, SignalLine2);
SetIndexBuffer(4,MACD_Map);
SetIndexStyle(4,DRAW_NONE);
SetIndexBuffer(5,SignalMap);
SetIndexStyle(5,DRAW_NONE);
SetIndexBuffer(6,SignalMap2);
SetIndexStyle(6,DRAW_NONE);
IndicatorShortName("[email protected]");
SetIndexLabel(0,"[email protected]");
SetIndexLabel(1,"[email protected]");
SetIndexLabel(2,"[email protected]");
SetIndexLabel(3,"[email protected]");
//----
SetIndexDrawBegin(0,10);
SetIndexDrawBegin(1,10);
SetIndexDrawBegin(2,signal);
SetIndexDrawBegin(3,signal2);
//---- indicator buffers mapping
Comment("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n [email protected]");
return(0);
}
//\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
int start()
{
if(Bars<=10) return(0);
ExtCountedBars=IndicatorCounted();
//---- check for possible errors
if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
if (ExtCountedBars>0) ExtCountedBars--;
int pos=Bars-ExtCountedBars-1;
while(pos>=0)
{
ExtMapBuffer1[pos]=iMA(Symbol(),0,ma_1,0,method,price,pos);
ExtMapBuffer2[pos]=iMA(Symbol(),0,ma_2,0,method,price,pos);
MACD_Map[pos]=ExtMapBuffer1[pos]-ExtMapBuffer2[pos];
pos--;
}
// ñèãíàëüíûå ëèíèè
pos=Bars-ExtCountedBars-1;
while(pos>=0)
{
SignalMap[pos]= iMAOnArray(MACD_Map,0,signal,0,s_method,pos);
SignalLine[pos]= NormalizeDouble(ExtMapBuffer2[pos]+SignalMap[pos],Digits);
SignalMap2[pos]= iMAOnArray(MACD_Map,0,signal2,0,s_method2,pos);
SignalLine2[pos]= NormalizeDouble(SignalMap2[pos]+ExtMapBuffer2[pos],Digits);
pos--;
}
return(0);
}
//\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n