English

## problem about cross of two trend lines

 32 maniac1984 2012.01.22 14:11 #   ```#property copyright "" #property link      "" //---Header Files----------------------------------------------------- #property indicator_chart_window #property indicator_buffers 1 datetime X1 = D'2010.07.15 16:00'; double   Y1 = 1.332603; datetime X2 = D'2010.09.10 16:00'; double   Y2 = 1.227437; datetime X3 = D'2010.07.09 08:00'; double   Y3 = 1.22197; datetime X4 = D'2010.09.08 00:00'; double   Y4 = 1.33196; //-------------------------------------------------------------------- int init() {    return(0); } //--------------------------------------------------------- int deinit() {    return(0); } //--------------------------------------------------------- int start() {    Comment( TimeToStr(LinesCrossTime(X1,Y1,X2,Y2,X3,Y3,X4,Y4)) + " , " + DoubleToStr(LinesCrossLevel(X1,Y1,X2,Y2,X3,Y3,X4,Y4),5) );       return(0); } //--------------------------------------------------------- datetime LinesCrossTime(datetime X1, double Y1, datetime X2, double Y2, datetime X3, double Y3, datetime X4, double Y4) {    double M1 = (Y2-Y1)/(X2-X1);    double M3 = (Y4-Y3)/(X4-X3);       return ((M1*X1-M3*X3+Y3-Y1)/(M1-M3)); } //-------------------------------------------------------- double LinesCrossLevel(datetime X1, double Y1, datetime X2, double Y2, datetime X3, double Y3, datetime X4, double Y4) {    double M1 = (Y2-Y1)/(X2-X1);    double M3 = (Y4-Y3)/(X4-X3);       double crossPoint = (M1*X1-M3*X3+Y3-Y1)/(M1-M3);       int i =0;    while (Time[i]>crossPoint)       i++;    return(Close[i-1]);   }  ```