|
|
@@ -14,7 +14,14 @@ string trend;
|
|
14
|
14
|
bool bearish_found = false;
|
|
15
|
15
|
bool bullish_found = false;
|
|
16
|
16
|
|
|
|
17
|
+int index_of_last_high = 0;
|
|
|
18
|
+int index_of_last_low = 0;
|
|
|
19
|
+
|
|
|
20
|
+double hi;
|
|
|
21
|
+double lo;
|
|
|
22
|
+
|
|
17
|
23
|
int index_of_low = 0;
|
|
|
24
|
+int index_of_high = 0;
|
|
18
|
25
|
int high_index=0;
|
|
19
|
26
|
double high,low,low1,high1;
|
|
20
|
27
|
//+------------------------------------------------------------------+
|
|
|
@@ -42,22 +49,20 @@ void foo(int index)
|
|
42
|
49
|
if(trend == "uptrend")
|
|
43
|
50
|
{
|
|
44
|
51
|
|
|
45
|
|
-
|
|
46
|
|
-
|
|
47
|
|
-
|
|
48
|
52
|
high1 = iHigh(Symbol(),PERIOD_CURRENT,i);
|
|
49
|
53
|
|
|
50
|
54
|
//double low1 = iLow(Symbol(),PERIOD_CURRENT,i);
|
|
51
|
55
|
|
|
52
|
56
|
if(high1 > high)
|
|
53
|
57
|
{
|
|
|
58
|
+
|
|
54
|
59
|
high = high1;
|
|
55
|
60
|
|
|
56
|
61
|
// Print("high break at index value",i);
|
|
57
|
62
|
// Print("index is ",index);
|
|
58
|
63
|
|
|
59
|
64
|
int count = (index-1) - i;
|
|
60
|
|
- Print("count is ", count);
|
|
|
65
|
+ Print("index is : : ", i);
|
|
61
|
66
|
|
|
62
|
67
|
// Print("index updated ",index);
|
|
63
|
68
|
|
|
|
@@ -96,8 +101,9 @@ void foo(int index)
|
|
96
|
101
|
}
|
|
97
|
102
|
|
|
98
|
103
|
Print(" high price is ", high);
|
|
|
104
|
+
|
|
99
|
105
|
Print("low price is ", low);
|
|
100
|
|
- Print("index of low is ", index_of_low);
|
|
|
106
|
+ Print("index of last updated low is ", index_of_low);
|
|
101
|
107
|
|
|
102
|
108
|
for(int l=index_of_low; l > 0; l--)
|
|
103
|
109
|
{
|
|
|
@@ -108,17 +114,24 @@ void foo(int index)
|
|
108
|
114
|
{
|
|
109
|
115
|
double price_low = iLow(Symbol(),PERIOD_CURRENT,l+1);
|
|
110
|
116
|
double time = iTime(Symbol(),PERIOD_CURRENT,l+1);
|
|
111
|
|
- double time1 = iTime(Symbol(),PERIOD_CURRENT,l+1);
|
|
|
117
|
+ double time1 = iTime(Symbol(),PERIOD_CURRENT,l-1);
|
|
112
|
118
|
ObjectCreate(0,"tline1",OBJ_TREND,0,time,price_low,time1,price_low);
|
|
113
|
119
|
trend = "downtrend";
|
|
114
|
120
|
Print("choch");
|
|
115
|
|
-
|
|
|
121
|
+ index_of_last_high = i;
|
|
116
|
122
|
Print("close", close);
|
|
117
|
123
|
break;
|
|
118
|
124
|
|
|
119
|
125
|
}
|
|
120
|
126
|
|
|
121
|
127
|
}
|
|
|
128
|
+ Print("index of last updated high is : ",index_of_last_high);
|
|
|
129
|
+ hi = iHigh(Symbol(),PERIOD_CURRENT,index_of_last_high+1);
|
|
|
130
|
+ lo = iLow(Symbol(),PERIOD_CURRENT,index_of_last_high+1);
|
|
|
131
|
+
|
|
|
132
|
+ Print("hy",hi, "index is : ",index_of_last_high+1);
|
|
|
133
|
+ Print("ho",lo);
|
|
|
134
|
+
|
|
122
|
135
|
index = i;
|
|
123
|
136
|
|
|
124
|
137
|
}
|
|
|
@@ -188,7 +201,7 @@ void foo(int index)
|
|
188
|
201
|
{
|
|
189
|
202
|
//Print("here");
|
|
190
|
203
|
high = high1;
|
|
191
|
|
- index_of_low = index - k;
|
|
|
204
|
+ index_of_high = index - k;
|
|
192
|
205
|
Print("high is updated at index : ",index - k);
|
|
193
|
206
|
|
|
194
|
207
|
}
|
|
|
@@ -199,9 +212,9 @@ void foo(int index)
|
|
199
|
212
|
|
|
200
|
213
|
Print(" high price is ", high);
|
|
201
|
214
|
Print("low price is ", low);
|
|
202
|
|
- Print("index of low is ", index_of_low);
|
|
|
215
|
+ Print("index of last updated high is ", index_of_high);
|
|
203
|
216
|
|
|
204
|
|
- for(int l=index_of_low; l > 0; l--)
|
|
|
217
|
+ for(int l=index_of_high; l > 0; l--)
|
|
205
|
218
|
{
|
|
206
|
219
|
// print("hi");
|
|
207
|
220
|
double close = iClose(Symbol(),PERIOD_CURRENT,l);
|
|
|
@@ -210,19 +223,23 @@ void foo(int index)
|
|
210
|
223
|
|
|
211
|
224
|
double price_high = iLow(Symbol(),PERIOD_CURRENT,l+1);
|
|
212
|
225
|
double time = iTime(Symbol(),PERIOD_CURRENT,l+1);
|
|
213
|
|
- double time1 = iTime(Symbol(),PERIOD_CURRENT,l+1);
|
|
214
|
|
- ObjectCreate(0,"tline2",OBJ_TREND,0,time,price_high,time1,price_high);
|
|
|
226
|
+ double time1 = iTime(Symbol(),PERIOD_CURRENT,l-1);
|
|
|
227
|
+ bool a = ObjectCreate(0,"tline2",OBJ_TREND,0,time,price_high,time1,price_high);
|
|
|
228
|
+ Print("object created : ", a);
|
|
215
|
229
|
|
|
216
|
230
|
trend = "uptrend";
|
|
217
|
231
|
Print("choch");
|
|
218
|
232
|
Print(l);
|
|
219
|
|
-
|
|
|
233
|
+ index_of_last_low = i;
|
|
220
|
234
|
Print("close", close);
|
|
221
|
235
|
break;
|
|
222
|
236
|
|
|
223
|
237
|
}
|
|
224
|
238
|
|
|
225
|
239
|
}
|
|
|
240
|
+ hi = iHigh(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
|
|
|
241
|
+ lo = iLow(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
|
|
|
242
|
+
|
|
226
|
243
|
index = i;
|
|
227
|
244
|
|
|
228
|
245
|
}
|
|
|
@@ -240,7 +257,7 @@ void foo(int index)
|
|
240
|
257
|
int OnInit()
|
|
241
|
258
|
{
|
|
242
|
259
|
|
|
243
|
|
- ObjectCreate(0,"line",OBJ_VLINE,0,D'2023.07.01 10:00:27',0);
|
|
|
260
|
+//ObjectCreate(0,"line",OBJ_VLINE,0,D'2023.07.01 10:00:27',0);
|
|
244
|
261
|
object_find(object_name);
|
|
245
|
262
|
//Print(ObjectFind(0,"line")); // to find the object drawn on the chart
|
|
246
|
263
|
|
|
|
@@ -252,6 +269,7 @@ int OnInit()
|
|
252
|
269
|
Print("line time: ",time_of_candle);
|
|
253
|
270
|
int index = iBarShift(Symbol(), PERIOD_CURRENT, time_of_candle, false);
|
|
254
|
271
|
Print(index);
|
|
|
272
|
+ Print(index);
|
|
255
|
273
|
|
|
256
|
274
|
// datetime time_of_candle = (datetime)ObjectGetInteger(0,"line",OBJPROP_TIME,0);
|
|
257
|
275
|
// Print("time is " , time_of_candle);
|
|
|
@@ -347,3 +365,53 @@ string checkCandle(int i) // to check the candle is bullish or bearish
|
|
347
|
365
|
//+------------------------------------------------------------------+
|
|
348
|
366
|
|
|
349
|
367
|
//+------------------------------------------------------------------+
|
|
|
368
|
+
|
|
|
369
|
+
|
|
|
370
|
+
|
|
|
371
|
+
|
|
|
372
|
+
|
|
|
373
|
+
|
|
|
374
|
+/////////////////////////////////////
|
|
|
375
|
+//void third condition()
|
|
|
376
|
+// {
|
|
|
377
|
+// if(checkCandle(index) == "Bearish")
|
|
|
378
|
+// {
|
|
|
379
|
+//
|
|
|
380
|
+// trend = "downtrend";
|
|
|
381
|
+//
|
|
|
382
|
+// // double high,low = 0.0;
|
|
|
383
|
+//
|
|
|
384
|
+// // to store high and low of the value after the object
|
|
|
385
|
+// low = iLow(Symbol(),PERIOD_CURRENT,index);
|
|
|
386
|
+//
|
|
|
387
|
+// //low = iLow(Symbol(),PERIOD_CURRENT,index-1);
|
|
|
388
|
+//
|
|
|
389
|
+// if(trend == "downtrend")
|
|
|
390
|
+// {
|
|
|
391
|
+//
|
|
|
392
|
+// low1 = iLow(Symbol(),PERIOD_CURRENT,i);
|
|
|
393
|
+//
|
|
|
394
|
+//
|
|
|
395
|
+// if(low1 < low)
|
|
|
396
|
+// {
|
|
|
397
|
+// low = low1;
|
|
|
398
|
+// for(int l=i; l > 0; l--)
|
|
|
399
|
+// {
|
|
|
400
|
+// // print("hi");
|
|
|
401
|
+// double high2 = iHigh(Symbol(),PERIOD_CURRENT,l);
|
|
|
402
|
+// if(high2 > high)
|
|
|
403
|
+// {
|
|
|
404
|
+//
|
|
|
405
|
+// high = high2;
|
|
|
406
|
+//
|
|
|
407
|
+// }
|
|
|
408
|
+//
|
|
|
409
|
+// }
|
|
|
410
|
+// }
|
|
|
411
|
+//
|
|
|
412
|
+// }
|
|
|
413
|
+// //
|
|
|
414
|
+// }
|
|
|
415
|
+//
|
|
|
416
|
+// }
|
|
|
417
|
+//+------------------------------------------------------------------+
|