|
|
@@ -11,6 +11,8 @@ CTrade trade;
|
|
11
|
11
|
#resource "\\Indicators\\SequentialVolumeProfileWithFVG.ex5"
|
|
12
|
12
|
#define previousBullish "previousBullish"
|
|
13
|
13
|
#define previousBearish "previousBearish"
|
|
|
14
|
+#define buy "buy"
|
|
|
15
|
+#define sell "sell"
|
|
14
|
16
|
//+------------------------------------------------------------------+
|
|
15
|
17
|
//| Expert initialization function |
|
|
16
|
18
|
//+------------------------------------------------------------------+
|
|
|
@@ -171,11 +173,14 @@ void OnTick()
|
|
171
|
173
|
double close_2 = iClose(Symbol(), PERIOD_CURRENT, 2);
|
|
172
|
174
|
double upper_price = MathMax(open_2, close_2);
|
|
173
|
175
|
double lower_price = MathMin(open_2, close_2);
|
|
174
|
|
- if(((upper_price < absHigh) && (lower_price < absHigh)))
|
|
|
176
|
+ if(((upper_price > absLow) && (lower_price > absLow)))
|
|
175
|
177
|
if(((upper_price > val) && (lower_price < val)) || ((upper_price < val) && (lower_price < val)))
|
|
176
|
178
|
{
|
|
177
|
|
- Print("Buy Trade. Val: ", val, " Vah: ", vah, " AbsHigh: ", absHigh, " AbsLow: ", absLow);
|
|
178
|
|
- placeBuyTrade();
|
|
|
179
|
+ if(candleNotTouchingHigh(absLow, buy))
|
|
|
180
|
+ {
|
|
|
181
|
+ Print("Buy Trade. Val: ", val, " Vah: ", vah, " AbsHigh: ", absHigh, " AbsLow: ", absLow);
|
|
|
182
|
+ placeBuyTrade();
|
|
|
183
|
+ }
|
|
179
|
184
|
}
|
|
180
|
185
|
}
|
|
181
|
186
|
}
|
|
|
@@ -187,11 +192,14 @@ void OnTick()
|
|
187
|
192
|
double close_2 = iClose(Symbol(), PERIOD_CURRENT, 2);
|
|
188
|
193
|
double upper_price = MathMax(open_2, close_2);
|
|
189
|
194
|
double lower_price = MathMin(open_2, close_2);
|
|
190
|
|
- if(((upper_price > absLow) && (lower_price > absLow)))
|
|
|
195
|
+ if(((upper_price < absHigh) && (lower_price < absHigh)))
|
|
191
|
196
|
if(((upper_price > vah) && (lower_price < vah)) || ((upper_price > vah) && (lower_price > vah)))
|
|
192
|
197
|
{
|
|
193
|
|
- Print("Sell Trade. Val: ", val, " Vah: ", vah, " AbsHigh: ", absHigh, " AbsLow: ", absLow);
|
|
194
|
|
- placeSellTrade();
|
|
|
198
|
+ if(candleNotTouchingHigh(absHigh, sell))
|
|
|
199
|
+ {
|
|
|
200
|
+ Print("Sell Trade. Val: ", val, " Vah: ", vah, " AbsHigh: ", absHigh, " AbsLow: ", absLow);
|
|
|
201
|
+ placeSellTrade();
|
|
|
202
|
+ }
|
|
195
|
203
|
}
|
|
196
|
204
|
}
|
|
197
|
205
|
}
|
|
|
@@ -577,4 +585,28 @@ bool newBar()
|
|
577
|
585
|
//+------------------------------------------------------------------+
|
|
578
|
586
|
//| |
|
|
579
|
587
|
//+------------------------------------------------------------------+
|
|
|
588
|
+bool candleNotTouchingHigh(double priceToBreak, string calledBy)
|
|
|
589
|
+ {
|
|
|
590
|
+ int index = iBarShift(Symbol(), PERIOD_CURRENT, iTime(Symbol(), PERIOD_D1, 0), false);
|
|
|
591
|
+ for(int i = 0; i <= index; i++)
|
|
|
592
|
+ {
|
|
|
593
|
+ if(calledBy == "buy")
|
|
|
594
|
+ {
|
|
|
595
|
+ double low = iLow(Symbol(), PERIOD_CURRENT, i);
|
|
|
596
|
+ if(low < priceToBreak)
|
|
|
597
|
+ return false;
|
|
|
598
|
+ }
|
|
|
599
|
+ else
|
|
|
600
|
+ if(calledBy == "sell")
|
|
|
601
|
+ {
|
|
|
602
|
+ double high = iHigh(Symbol(), PERIOD_CURRENT, i);
|
|
|
603
|
+ if(high > priceToBreak)
|
|
|
604
|
+ return false;
|
|
|
605
|
+ }
|
|
|
606
|
+ }
|
|
|
607
|
+ return true;
|
|
|
608
|
+ }
|
|
|
609
|
+//+------------------------------------------------------------------+
|
|
|
610
|
+//| |
|
|
|
611
|
+//+------------------------------------------------------------------+
|
|
580
|
612
|
//+------------------------------------------------------------------+
|