-
Notifications
You must be signed in to change notification settings - Fork 0
/
KursInfo.mq4
210 lines (173 loc) · 5.81 KB
/
KursInfo.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
//+------------------------------------------------------------------+
//| KursInfo.mq4 |
//| Dominik Liehr |
//| http://www.idragon.de |
//+------------------------------------------------------------------+
// Version 1.2
#property copyright "Dominik Liehr"
#property link "http://www.idragon.de"
int globalFontSize = 25;
int globalDistanceX1 = 20;
int globalDistanceX2 = 150;
int init() {
// Objekte erzeugen
ObjectCreate("label_ask1", OBJ_LABEL, 0, 0, 0, 0, 0, 0, 0);
ObjectSetText("label_ask1", "Ask:", globalFontSize, "Arial", DeepSkyBlue);
ObjectSet("label_ask1", OBJPROP_XDISTANCE, globalDistanceX1);
ObjectSet("label_ask1", OBJPROP_YDISTANCE, 100);
ObjectCreate("label_bid1", OBJ_LABEL, 0, 0, 0, 0, 0, 0, 0);
ObjectSetText("label_bid1", "Bid:", globalFontSize, "Arial", Red);
ObjectSet("label_bid1", OBJPROP_XDISTANCE, globalDistanceX1);
ObjectSet("label_bid1", OBJPROP_YDISTANCE, 130);
ObjectCreate("label_spread1", OBJ_LABEL, 0, 0, 0, 0, 0, 0, 0);
ObjectSetText("label_spread1", "Spread:", globalFontSize, "Arial", LawnGreen);
ObjectSet("label_spread1", OBJPROP_XDISTANCE, globalDistanceX1);
ObjectSet("label_spread1", OBJPROP_YDISTANCE, 160);
ObjectCreate("label_ask2", OBJ_LABEL, 0, 0, 0, 0, 0, 0, 0);
ObjectSetText("label_ask2", ".", globalFontSize, "Arial", DeepSkyBlue);
ObjectSet("label_ask2", OBJPROP_XDISTANCE, globalDistanceX2);
ObjectSet("label_ask2", OBJPROP_YDISTANCE, 100);
ObjectCreate("label_bid2", OBJ_LABEL, 0, 0, 0, 0, 0, 0, 0);
ObjectSetText("label_bid2", ".", globalFontSize, "Arial", Red);
ObjectSet("label_bid2", OBJPROP_XDISTANCE, globalDistanceX2);
ObjectSet("label_bid2", OBJPROP_YDISTANCE, 130);
ObjectCreate("label_spread2", OBJ_LABEL, 0, 0, 0, 0, 0, 0, 0);
ObjectSetText("label_spread2", ".", globalFontSize, "Arial", LawnGreen);
ObjectSet("label_spread2", OBJPROP_XDISTANCE, 233);
ObjectSet("label_spread2", OBJPROP_YDISTANCE, 160);
return(0);
}
// arrow code
// 225 / 233 / 241 - oben
// 226 / 234 / 242 - unten
double lastValue;
double valuesFive[5];
int zeiger=0;
int start() {
double val = Ask - Bid;
double spread = MarketInfo(Symbol(), MODE_SPREAD);
spread = spread / 10.0;
Comment("Spread: " + DoubleToStr(spread, 1) + " (" + DoubleToStr(val, 5) + ")");
// bool ObjectCreate(string name, int type, int window, datetime time1, double price1, datetime time2=0, double price2=0, datetime time3=0, double price3=0)
ObjectSetText("label_ask2", DoubleToStr(Ask, 5), globalFontSize, "Arial", DeepSkyBlue);
ObjectSetText("label_bid2", DoubleToStr(Bid, 5), globalFontSize, "Arial", Red);
ObjectSetText("label_spread2", "" + DoubleToStr(MarketInfo("EURUSD", MODE_SPREAD), 0), globalFontSize, "Arial", LawnGreen);
/*
// set current value
valuesFive[zeiger] = Ask;
analyzeLast();
analyzeLastFive();
// change zeiger
zeiger = zeiger + 1;
if(zeiger > 4) { zeiger =0; }
*/
return(0);
}
void analyzeLast() {
// analyze last
if(zeiger == 0) {
if(Ask > valuesFive[4]) {
ObjectSet("arrow1", OBJPROP_ARROWCODE, 233);
} else if(Ask < valuesFive[4]) {
ObjectSet("arrow1", OBJPROP_ARROWCODE, 234);
} else {
ObjectSet("arrow1", OBJPROP_ARROWCODE, 167);
}
} else {
if(Ask > valuesFive[zeiger-1]) {
ObjectSet("arrow1", OBJPROP_ARROWCODE, 233);
} else if(Ask < valuesFive[zeiger-1]) {
ObjectSet("arrow1", OBJPROP_ARROWCODE, 234);
} else {
ObjectSet("arrow1", OBJPROP_ARROWCODE, 167);
}
}
}
void analyzeLastFive() {
// analyze last 5
double tempValues[5];
if(zeiger == 0) {
tempValues[0] = valuesFive[zeiger];
int j=1;
for(int i=4;i >= 1;i--) {
tempValues[j] = valuesFive[i];
j++;
}
} else if(zeiger == 4) {
int k=0;
for(int l=4;l >= 0;l--) {
tempValues[k] = valuesFive[l];
k++;
}
} else {
int t=0;
for(int f=zeiger;f >= 0;f--) {
tempValues[t] = valuesFive[f];
t++;
}
for(int g=4;g >= (zeiger+1);g--) {
tempValues[t] = valuesFive[g];
t++;
}
}
// analyzing
double mw = mittelwert(tempValues);
if(tempValues[0] < mw) {
ObjectSet("arrow2", OBJPROP_ARROWCODE, 234);
} else if(tempValues[0] == mw) {
ObjectSet("arrow2", OBJPROP_ARROWCODE, 167);
} else {
ObjectSet("arrow2", OBJPROP_ARROWCODE, 233);
}
}
void analyzeLastTen() {
// analyze last 5
double tempValues[10];
if(zeiger == 0) {
tempValues[0] = valuesFive[zeiger];
int j=1;
for(int i=4;i >= 1;i--) {
tempValues[j] = valuesFive[i];
j++;
}
} else if(zeiger == 4) {
int k=0;
for(int l=4;l >= 0;l--) {
tempValues[k] = valuesFive[l];
k++;
}
} else {
int t=0;
for(int f=zeiger;f >= 0;f--) {
tempValues[t] = valuesFive[f];
t++;
}
for(int g=4;g >= (zeiger+1);g--) {
tempValues[t] = valuesFive[g];
t++;
}
}
// analyzing
double mw = mittelwert(tempValues);
if(tempValues[0] < mw) {
ObjectSet("arrow2", OBJPROP_ARROWCODE, 234);
} else if(tempValues[0] == mw) {
ObjectSet("arrow2", OBJPROP_ARROWCODE, 167);
} else {
ObjectSet("arrow2", OBJPROP_ARROWCODE, 233);
}
}
double mittelwert(double values[]) {
double sum = 0.0;
for(int i=0;i < ArraySize(values);i++) {
sum = sum + values[i];
}
return(sum / ArraySize(values));
}
int deinit() {
ObjectDelete("label_ask");
ObjectDelete("label_spread");
// ObjectDelete("arrow1");
//ObjectDelete("arrow2");
return(0);
}