My consumer requested the right way to connect the Worth Vary indicator to his buying and selling robotic. Certainly, this enables using completely different Cease Loss and Take Revenue values, in addition to quite a lot of buying and selling logic.
If you happen to’re new to this highly effective indicator, you’ll be able to learn extra about it right here: Worth Vary Indicator – Keep updated with worth actions.
You too can learn all about utilizing this indicator successfully right here: Buying and selling methods for the “Worth Vary MT5” indicator.
Let’s get again to attaching this indicator to your buying and selling robotic.
Here is a quick information on the right way to connect the Worth Vary indicator to your buying and selling robotic
1. Place the Worth Vary indicator in the identical folder as your robotic.
2. When receiving the indicator deal with by way of the iCustom perform, specify the precise identify of the indicator file (with out “.ex5“):
indiHandle = iCustom(_Symbol, _Period, “Worth Vary MT5”);
3. Within the case of a purchase sign, the buffer accommodates the present bar’s low worth. Equally, within the case of a promote sign, the buffer accommodates the present bar’s excessive worth. Subsequently, we have to test whether or not the quantity within the buffer is the same as these costs. Since these are double numbers, they can’t be in contrast precisely; we have to use epsilon.
4. Get costs from the chart. We want the Low and Excessive costs of the identical bar from which we took the sign (the primary bar):
double barLow = iLow(_Symbol, _Period, 1);
double barHigh = iHigh(_Symbol, _Period, 1);
5. Set accuracy (epsilon). Let’s use _Point – the dimensions of 1 level (e.g., 0.00001). We take into account numbers equal if the distinction between them is lower than half some extent.
double epsilon = _Point * 0.5;
6. Get knowledge from the primary bar (earlier closed):
if (CopyBuffer(indiHandle, 0, 1, 1, bufferBuy) < 0 || CopyBuffer(indiHandle, 1, 1, 1, bufferSell) < 0) {
return;
}
7. Put together values for checking the sign:
double buyValue = bufferBuy(0);
double sellValue = bufferSell(0);
8. Verify purchase (UpTrend). The indicator writes Low(i) to the buffer. Checking:
A) The worth isn’t empty (< DBL_MAX),
B) The worth within the buffer is sort of equal to the Low worth.
bool isBuySignal = (buyValue < DBL_MAX) && (MathAbs(buyValue – barLow) < epsilon);
9. Verify promote (DownTrend). The indicator writes Excessive(i) to the buffer. Checking:
A) The worth isn’t empty (< DBL_MAX),
B) The worth within the buffer is sort of equal to the Excessive worth.
bool isSellSignal = (sellValue < DBL_MAX) && (MathAbs(sellValue – barHigh) < epsilon);
That’s it!
You should utilize the Worth Vary indicator with out attaching it to your buying and selling robotic
Do not forget that the Worth Vary indicator has a really handy, customizable notification system for brand new tendencies, help and resistance ranges, and worth ranges on any buying and selling image and timeframe.
Good luck together with your buying and selling!

