My shopper requested how you can connect the Worth Vary indicator to his buying and selling robotic. Certainly, this enables the usage of totally different Cease Loss and Take Revenue values, in addition to quite a lot of buying and selling logic.
When you’re new to this highly effective indicator, you possibly can learn extra about it right here: Worth Vary Indicator – Keep updated with worth actions.
It’s also possible to 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.
This is a short information on how you can 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 title 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. Due to this fact, we have to verify 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 contemplate 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. Examine purchase (UpTrend). The indicator writes Low[i] to the buffer. Checking:
A) The worth will not be 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. Examine promote (DownTrend). The indicator writes Excessive[i] to the buffer. Checking:
A) The worth will not be 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
Remember that the Worth Vary indicator has a really handy, customizable notification system for brand spanking 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!

