Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

The intersection of two lines - MetaTrader 4 script | Trading script download - MT4/MT5 resources

author EAcpu | 5 reads | 0 comments |

The intersections of two lines - script for MetaTrader 4

The intersections of two lines - script for MetaTrader 4

The intersections of two lines - script for MetaTrader 4

The intersections of two lines - script for MetaTrader 4

The intersections of two lines - script for MetaTrader 4

A friend asked a question and it became my excuse to reminisce about my math class from years ago! 😊 (Then tell me what’s the use of arithmetic and geometry in high school; this is a very practical example of the same course 😉)

In MetaTrader 4 we intend to use MQL4 to calculate the intersection coordinates of two straight line objects with different slopes.

I'll give a general explanation:

If the horizontal axis of the chart represents time X, the vertical axis of the chart represents price Y. For each line on the graph that has two points at or one point away from it and the slope of the line, find the equations of the two lines.

We end up with a set of equations that, by doing math and writing one variable over another and replacing it with another function, give us the values ​​of X and Y, which are the coordinates of the intersection of the two lines.

I tried to solve the problem with a few simple and clean lines of code, which was also educational, and I also put down the source code files.

The intersections of two lines - script for MetaTrader 4

The intersections of two lines - script for MetaTrader 4

The intersections of two lines - script for MetaTrader 4

Translate via Google Translate.

Telegram: @JahanChart


Attachment download

📎 the_intersections_of_two_lines.mq4 (2.05 KB)

Source: MQL5 #32982

Verification code Refresh