質問編集履歴
2
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,341 +1 @@
|
|
1
|
-
- N計算のシグナルを作りたいのですが、矢印が沢山出てしまいます。
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
``````ここに言語を入力
|
8
|
-
|
9
|
-
MQL4
|
10
|
-
|
11
|
-
```
|
12
|
-
|
13
|
-
コード
|
14
|
-
|
15
|
-
```### 前提・実現したいこと
|
16
|
-
|
17
|
-
//+------------------------------------------------------------------+
|
18
|
-
|
19
|
-
//| Hafen9_ZigZag.mq4 |
|
20
|
-
|
21
|
-
//| minato9 |
|
22
|
-
|
23
|
-
//| https://www.mql5.com |
|
24
|
-
|
25
|
-
//+------------------------------------------------------------------+
|
26
|
-
|
27
|
-
#property copyright "sample"
|
28
|
-
|
29
|
-
#property link "https://www.mql5.com"
|
30
|
-
|
31
|
-
#property version "1.00"
|
32
|
-
|
33
|
-
#property strict
|
34
|
-
|
35
|
-
#property indicator_chart_window
|
36
|
-
|
37
|
-
#property indicator_buffers 2
|
38
|
-
|
39
|
-
#property indicator_color1 DeepPink //1つ目のインジケータを赤色に設定
|
40
|
-
|
41
|
-
#property indicator_color2 White //2つ目のインジケータを青色に設定
|
42
|
-
|
43
|
-
#property indicator_width1 1 //1つ目のインジケータの太さを1に設定
|
44
|
-
|
45
|
-
#property indicator_width2 1 //2つ目のインジケータの太さを1に設定
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
double ArrowUp[];//上矢印
|
50
|
-
|
51
|
-
double ArrowDown[];//下矢印
|
52
|
-
|
53
|
-
double Win[];//勝ち✓
|
54
|
-
|
55
|
-
double Lose[];//負け×
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
extern int MaxBars=1440;//計算するバーの本数
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
//+------------------------------------------------------------------+
|
64
|
-
|
65
|
-
//| Custom indicator initialization function |
|
66
|
-
|
67
|
-
//+------------------------------------------------------------------+
|
68
|
-
|
69
|
-
int OnInit()
|
70
|
-
|
71
|
-
{
|
72
|
-
|
73
|
-
//--- indicator buffers mapping
|
74
|
-
|
75
|
-
//下矢印 //上矢印
|
76
|
-
|
77
|
-
SetIndexBuffer(0,ArrowDown); SetIndexBuffer(1,ArrowUp);
|
78
|
-
|
79
|
-
SetIndexStyle(0,DRAW_ARROW); SetIndexStyle(1,DRAW_ARROW);
|
80
|
-
|
81
|
-
SetIndexArrow(0,234); SetIndexArrow(1,233);
|
82
|
-
|
83
|
-
SetIndexEmptyValue(0,0.0); SetIndexEmptyValue(1,0.0);
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
//---
|
88
|
-
|
89
|
-
return(INIT_SUCCEEDED);
|
90
|
-
|
91
|
-
}
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
//+------------------------------------------------------------------+
|
100
|
-
|
101
|
-
//| Custom indicator iteration function |
|
102
|
-
|
103
|
-
//+------------------------------------------------------------------+
|
104
|
-
|
105
|
-
int OnCalculate(const int rates_total,
|
106
|
-
|
107
|
-
const int prev_calculated,
|
108
|
-
|
109
|
-
const datetime &time[],
|
110
|
-
|
111
|
-
const double &open[],
|
112
|
-
|
113
|
-
const double &high[],
|
114
|
-
|
115
|
-
const double &low[],
|
116
|
-
|
117
|
-
const double &close[],
|
118
|
-
|
119
|
-
const long &tick_volume[],
|
120
|
-
|
121
|
-
const long &volume[],
|
122
|
-
|
123
|
-
const int &spread[])
|
124
|
-
|
125
|
-
{
|
126
|
-
|
127
|
-
//---
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
int m,n; m=0; n=0; double NLow,NHigh,N,N1,N3;
|
134
|
-
|
135
|
-
double Top[10]; double Bottom[10]; int tPosition[10]; int bPosition[10];
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
for(int i=0;i<=MaxBars;i++)
|
142
|
-
|
143
|
-
{
|
144
|
-
|
145
|
-
double Zg=NormalizeDouble(iCustom(NULL,0,"ZigZag",12,5,3,0,i),5);
|
146
|
-
|
147
|
-
if(Zg!=0 && Zg==NormalizeDouble(High[i],5))
|
148
|
-
|
149
|
-
{
|
150
|
-
|
151
|
-
Top[m++]=Zg; //天
|
152
|
-
|
153
|
-
tPosition[m-1]=i;
|
154
|
-
|
155
|
-
if(m>=10)break;
|
156
|
-
|
157
|
-
}
|
158
|
-
|
159
|
-
if(Zg!=0 && Zg==NormalizeDouble(Low[i],5))
|
160
|
-
|
161
|
-
{
|
162
|
-
|
163
|
-
Bottom[n++]=Zg; //底
|
164
|
-
|
165
|
-
bPosition[n-1]=i;
|
166
|
-
|
167
|
-
if(n>=10)break;
|
168
|
-
|
169
|
-
}
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
NLow=Bottom[0]+(Top[1]-Bottom[1]);
|
176
|
-
|
177
|
-
NHigh=Top[0]-(Top[1]-Bottom[1]);
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
//Low
|
182
|
-
|
183
|
-
if(NLow<Close[i] || NLow==Close[i])
|
184
|
-
|
185
|
-
{
|
186
|
-
|
187
|
-
ArrowDown[i]=High[i]+6*Point;
|
188
|
-
|
189
|
-
}
|
190
|
-
|
191
|
-
//High
|
192
|
-
|
193
|
-
if(NHigh>Close[i] || NHigh==Close[i])
|
194
|
-
|
195
|
-
{
|
196
|
-
|
197
|
-
ArrowUp[i]=Low[i]-6*Point;
|
198
|
-
|
199
|
-
}
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
}
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
ObjectCreate("LowTrend",OBJ_TREND,0,Time[0+bPosition[1]],Low[0+bPosition[1]],Time[0+bPosition[0]],Low[0+bPosition[0]]);
|
208
|
-
|
209
|
-
ObjectSet("LowTrend",OBJPROP_COLOR,DeepPink);
|
210
|
-
|
211
|
-
ObjectSet("LowTrend",OBJPROP_WIDTH,1);
|
212
|
-
|
213
|
-
ObjectMove("LowTrend", 0,Time[0+bPosition[1]],Low[0+bPosition[1]]);
|
214
|
-
|
215
|
-
ObjectMove("LowTrend", 1,Time[0+bPosition[0]],Low[0+bPosition[0]]);
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
ObjectCreate("HighTrend",OBJ_TREND,0,Time[0+tPosition[1]],High[0+tPosition[1]],Time[0+tPosition[0]],High[0+tPosition[0]]);
|
220
|
-
|
221
|
-
ObjectSet("HighTrend",OBJPROP_COLOR,White);
|
222
|
-
|
223
|
-
|
1
|
+
…………………………………………………………………………………………………………………………………
|
224
|
-
|
225
|
-
ObjectMove("HighTrend", 0,Time[0+tPosition[1]],High[0+tPosition[1]]);
|
226
|
-
|
227
|
-
ObjectMove("HighTrend", 1,Time[0+tPosition[0]],High[0+tPosition[0]]);
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
//--- return value of prev_calculated for next call
|
234
|
-
|
235
|
-
return(rates_total);
|
236
|
-
|
237
|
-
}
|
238
|
-
|
239
|
-
//+------------------------------------------------------------------+
|
240
|
-
|
241
|
-
//| Timer function |
|
242
|
-
|
243
|
-
//+------------------------------------------------------------------+
|
244
|
-
|
245
|
-
void OnTimer()
|
246
|
-
|
247
|
-
{
|
248
|
-
|
249
|
-
//---
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
}
|
254
|
-
|
255
|
-
//+------------------------------------------------------------------+
|
256
|
-
|
257
|
-
//| ChartEvent function |
|
258
|
-
|
259
|
-
//+------------------------------------------------------------------+
|
260
|
-
|
261
|
-
void OnChartEvent(const int id,
|
262
|
-
|
263
|
-
const long &lparam,
|
264
|
-
|
265
|
-
const double &dparam,
|
266
|
-
|
267
|
-
const string &sparam)
|
268
|
-
|
269
|
-
{
|
270
|
-
|
271
|
-
//---
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
}
|
276
|
-
|
277
|
-
//+------------------------------------------------------------------+
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
### 発生している問題・エラーメッセージ
|
284
|
-
|
285
|
-
N計算がうまく動作しない- リスト
|
286
|
-
|
287
|
-
上手く条件式が機能していない、矢印(サイン)が沢山出てしまう
|
288
|
-
|
289
|
-
ストラジーテスターで動かすと過去に沢山矢印が出てくる
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
エラーメッセージ
|
294
|
-
|
295
|
-
特になし
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
### 該当のソースコード
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
```
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
### 試したこと
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
![![イメージ説明](164761d7bfd70e3455c5e5ed0fa987ab.jpeg)](d58ed69eef2cba79ed3b3d0474db5367.jpeg)
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
N計算の場合
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
Low矢印の場合
|
320
|
-
|
321
|
-
目標値=C+(B-A) → NLow=Bottom[0]+(Top[1]-Bottom[1]);
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
High矢印の場合
|
326
|
-
|
327
|
-
目標値=C+(B-A) → NHigh=Top[0]-(Top[1]-Bottom[1]);
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
矢印を出す条件式に上記の画像を参考に計算。
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
### 補足情報(FW/ツールのバージョンなど)
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
ここにより詳細な情報を記載してください。
|
1
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
- N計算のシグナルを作りたいのですが、矢印が沢山出てしまいます。
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
|
1
7
|
``````ここに言語を入力
|
2
8
|
|
3
9
|
MQL4
|