My shopper requested the way to connect the Value Vary indicator to his buying and selling robotic. Certainly, this permits using totally different Cease Loss and Take Revenue values, in addition to a wide range of buying and selling logic.
In the event you’re new to this highly effective indicator, you’ll be able to learn extra about it right here: Value Vary Indicator – Keep updated with value actions.
You can even learn all about utilizing this indicator successfully right here: Buying and selling methods for the “Value Vary MT5” indicator.
Let’s get again to attaching this indicator to your buying and selling robotic.
This is a quick information on the way to connect the Value Vary indicator to your buying and selling robotic
1. Place the Value Vary indicator in the identical folder as your robotic.
2. When receiving the indicator deal with through the iCustom perform, specify the precise identify of the indicator file (with out “.ex5“):
indiHandle = iCustom(_Symbol, _Period, “Value Vary MT5”);
3. Within the case of a purchase sign, the buffer comprises the present bar’s low value. Equally, within the case of a promote sign, the buffer comprises the present bar’s excessive value. 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 scale 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 information 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 is just not empty (< DBL_MAX),
B) The worth within the buffer is sort of equal to the Low value.
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 is just not empty (< DBL_MAX),
B) The worth within the buffer is sort of equal to the Excessive value.
bool isSellSignal = (sellValue < DBL_MAX) && (MathAbs(sellValue – barHigh) < epsilon);
That’s it!
You should use the Value Vary indicator with out attaching it to your buying and selling robotic
Remember that the Value Vary indicator has a really handy, customizable notification system for brand spanking new developments, help and resistance ranges, and value ranges on any buying and selling image and timeframe.
Good luck together with your buying and selling!



