거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Telegram에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
조회수:
3158
평가:
(19)
게시됨:
2018.06.06 14:38
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

Function parameters:

  • double LX1 - the X coordinate of the first point of the line;
  • double LY1 - the Y coordinate of the first point of the line;
  • double LX2 - the X coordinate of the second point of the line;
  • double LY2 - the Y coordinate of the second point of the line;
  • double DX - the X coordinate of the point;
  • double DY - the Y coordinate of the point.


Calculation principle

Based on the coordinates of two points of the line, we get the line formula: y=a+k*x. The k coefficient determines the slope of the line, i.e. a change in the y coordinate per a unit of change in the x coordinate. The k coefficient is calculated as follows:

double K=(LY2-LY1)/(LX2-LX1);

The a constant determines the value of the line, if x=0, i.e. corresponds to the level, where the line crosses the y axis. Knowing the slope coefficient and the X coordinate of one of the line points, we calculate a:

double LA=LY1-K*LX1;

The distance from a point to the line is determined based on the perpendicular drawn to the line. If you rotate the drawing 90 degrees counterclockwise, the d line will have the same slope as the main line, but with the opposite sign. Knowing the slope and the coordinates of one point, we can get the equation of the line, but in this case in the form x =a-ky. So, the a constant:

double DA=DX+K*DY;

Having the formulas of two lines, we find the point of their intersection. For this purpose, we substitute y expressed by the formula of the first line to the formula of the second line, make some transformations and obtain the x coordinate of the intersection point:

double CX=(DA-K*LA)/(1.0+K*K);

Then substitute the resulting x in the formula for the first line, and obtain the y coordinate of the point of intersection of lines:

double CY=LA+K*CX;

Knowing the coordinates of two points, we can calculate the distance between them along the x and y axes (the projections on the axis). Further, using the Pythagorean theorem, calculate the distance:

MathSqrt(MathPow(DX-CX,2)+MathPow(DY-CY,2))

A discussion in Russian is available at https://www.mql5.com/ru/forum/237198. You can also discuss the idea here, in comments.

MetaQuotes Ltd에서 러시아어로 번역함.
원본 코드: https://www.mql5.com/ru/code/20481

maximus_vX lite maximus_vX lite

The Expert Advisor trades using levels. It can have a maximum of two positions of each type (Buy and Sell) in the market.

WCCI WCCI

A weighted CCI.

Poker_SHOW Poker_SHOW

An Expert Advisor based on a random number generator. Trend is determined using the iMA (Moving Average, MA) indicator.

TrueSort_1100 TrueSort_1100

The Expert Advisor waits when the lines of MA(10), MA(20), MA(50), MA(100) and MA(200) get arranged one above the other (or one below the other).