How can I detect when MACD visually touches the RSI in an MQL4/MQL5 indicator window for trade signals?
How can I detect when MACD visually touches the RSI in an MQL4/MQL5 indicator window for trade signals?
Loading saved threads...
Mr . · External communityPost link
External question — Stack Overflow Stack Exchange
Author: Mr .
Original post: https://stackoverflow.com/questions/79628405
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
I'm developing an Expert Advisor in MQL4/MQL5 that should trigger trade orders based on the visual interaction of two indicators—the MACD and the RSI—displayed in the same indicator window. The idea is that when the MACD Peaks or troughs "touches" or intersects with the levels of the RSI, a trade signal should be initiated (for example, issuing a BUY signal if RSI is oversold or a SELL signal if RSI is overbought).
The challenge arises because the RSI is plotted on a fixed 0–100 scale, while the MACD values can vary significantly due to market trends and other factors. As a result, directly comparing their numerical values can be unreliable. I would like to replicate the graphical output as seen in the indicator window to detect these intersections accurately, all within the MQL4/MQL5 environment.
My questions are:
Is there an established method or best practice in MQL4/MQL5 for detecting the graphical intersection (or "touch") between two indicator lines within the same window?
What techniques or functions provided by MQL4/MQL5 might help me mimic the chart rendering process so that I can trigger trade signals based on this visual condition?
Do you have any code examples or suggestions that could help implement this reliably without resorting to external solutions?
Any insights, examples, or references would be greatly appreciated.
I need a solution for that
Quote
Report
Daniel Kniaz · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: Daniel Kniaz
Original post: https://stackoverflow.com/a/79629501
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
This is a bad idea. Best solution is to forget about it.
But, before you follow my advice, there are some steps to try. You can point your attention to
https://docs.mql4.com/constants/chartconstants/enum_chart_property
and get all the data you need (width of each chart, for example). Alternative and faster way might be to know the number of bars and compute max / min value of macd / rsi for a selected number of bars, then compute the y and y-1 position on the scale, and finally get the crossover. Why it does not make sense? You will see that your signals depend on chart resolution, number of bars on the chart and whether your chart is shifted. Well, if you tried your strategy in tester and pretty sure cross of two individual signals matters, you should try. There's nothing complicated, use several built-in functions to make the code.
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External answer — Stack Overflow Stack Exchange Author: Daniel Kniaz Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/a/79629501 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. This is a bad idea. Best solution is to forget about it. But, before you follow my advice, there are some steps to try. You can point your attention to https://docs.mql4.com/constants/chartconstants/enum_chart_property and get all the data you need (width of each chart, for example). Alternative and faster way might be to know the number of bars and compute max / min value of macd / rsi for a selected number of bars, then compute the y and y-1 position on the scale, and finally get the crossover. Why it does not make sense? You will see that your signals depend on chart resolution, number of bars on the chart and whether your chart is shifted. Well, if you tried your strategy in tester and pretty sure cross of two individual signals matters, you should try. There's nothing complicated, use several built-in functions to make the code.
Checking account access…