|
|
@@ -11,6 +11,8 @@ CTrade trade;
|
|
|
#resource "\\Indicators\\SequentialVolumeProfileWithFVG.ex5"
|
|
|
#define previousBullish "previousBullish"
|
|
|
#define previousBearish "previousBearish"
|
|
|
+#define buy "buy"
|
|
|
+#define sell "sell"
|
|
|
//+------------------------------------------------------------------+
|
|
|
//| Expert initialization function |
|
|
|
//+------------------------------------------------------------------+
|
|
|
@@ -171,11 +173,14 @@ void OnTick()
|
|
|
double close_2 = iClose(Symbol(), PERIOD_CURRENT, 2);
|
|
|
double upper_price = MathMax(open_2, close_2);
|
|
|
double lower_price = MathMin(open_2, close_2);
|
|
|
- if(((upper_price < absHigh) && (lower_price < absHigh)))
|
|
|
+ if(((upper_price > absLow) && (lower_price > absLow)))
|
|
|
if(((upper_price > val) && (lower_price < val)) || ((upper_price < val) && (lower_price < val)))
|
|
|
{
|
|
|
- Print("Buy Trade. Val: ", val, " Vah: ", vah, " AbsHigh: ", absHigh, " AbsLow: ", absLow);
|
|
|
- placeBuyTrade();
|
|
|
+ if(candleNotTouchingHigh(absLow, buy))
|
|
|
+ {
|
|
|
+ Print("Buy Trade. Val: ", val, " Vah: ", vah, " AbsHigh: ", absHigh, " AbsLow: ", absLow);
|
|
|
+ placeBuyTrade();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -187,11 +192,14 @@ void OnTick()
|
|
|
double close_2 = iClose(Symbol(), PERIOD_CURRENT, 2);
|
|
|
double upper_price = MathMax(open_2, close_2);
|
|
|
double lower_price = MathMin(open_2, close_2);
|
|
|
- if(((upper_price > absLow) && (lower_price > absLow)))
|
|
|
+ if(((upper_price < absHigh) && (lower_price < absHigh)))
|
|
|
if(((upper_price > vah) && (lower_price < vah)) || ((upper_price > vah) && (lower_price > vah)))
|
|
|
{
|
|
|
- Print("Sell Trade. Val: ", val, " Vah: ", vah, " AbsHigh: ", absHigh, " AbsLow: ", absLow);
|
|
|
- placeSellTrade();
|
|
|
+ if(candleNotTouchingHigh(absHigh, sell))
|
|
|
+ {
|
|
|
+ Print("Sell Trade. Val: ", val, " Vah: ", vah, " AbsHigh: ", absHigh, " AbsLow: ", absLow);
|
|
|
+ placeSellTrade();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -577,4 +585,28 @@ bool newBar()
|
|
|
//+------------------------------------------------------------------+
|
|
|
//| |
|
|
|
//+------------------------------------------------------------------+
|
|
|
+bool candleNotTouchingHigh(double priceToBreak, string calledBy)
|
|
|
+ {
|
|
|
+ int index = iBarShift(Symbol(), PERIOD_CURRENT, iTime(Symbol(), PERIOD_D1, 0), false);
|
|
|
+ for(int i = 0; i <= index; i++)
|
|
|
+ {
|
|
|
+ if(calledBy == "buy")
|
|
|
+ {
|
|
|
+ double low = iLow(Symbol(), PERIOD_CURRENT, i);
|
|
|
+ if(low < priceToBreak)
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ if(calledBy == "sell")
|
|
|
+ {
|
|
|
+ double high = iHigh(Symbol(), PERIOD_CURRENT, i);
|
|
|
+ if(high > priceToBreak)
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+//+------------------------------------------------------------------+
|
|
|
+//| |
|
|
|
+//+------------------------------------------------------------------+
|
|
|
//+------------------------------------------------------------------+
|