//+------------------------------------------------------------------+ //| itdlines.mq4 | //| Frostow | //| https://www.mql5.com/en/users/frostow | //+------------------------------------------------------------------+ #property indicator_chart_window #property indicator_buffers 2 #property indicator_plots 2 #property indicator_color1 clrGreen #property indicator_color2 clrBlue input int Level=1; double LU[],LD[]; datetime LastCount; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void GetBK(double &Ub,double &Uk,double &Db,double &Dk,int &EndUN,int &EndDN) { double TDU[]; double TDD[]; int TDU_n[]; int TDD_n[]; ArrayResize(TDU,2,2); ArrayResize(TDD,2,2); ArrayResize(TDU_n,2,2); ArrayResize(TDD_n,2,2); //Obtain values of point's prices and numbers of candlesticks from the beginning int Ui = 0; int Di = 0; for(int i=0;; i++) { double current_bar_U = iCustom(NULL, 0, "itddots", Level, 0, i); double current_bar_D = iCustom(NULL, 0, "itddots", Level, 1, i); if(current_bar_U>0 && Ui<2) { TDU[Ui] = current_bar_U; //Price TDU_n[Ui] = i; //Number Ui++; } if(current_bar_D>0 && Di<2) { TDD[Di]=current_bar_D; TDD_n[Di]=i; Di++; } if(Ui==2 && Di==2) break; } Ub = ( (TDU_n[0] * TDU[1]) - (TDU_n[1] * TDU[0]) ) / ( TDU_n[0] - TDU_n[1] ); Uk = (TDU[0] - TDU[1]) / (TDU_n[0] - TDU_n[1]); Db = ( (TDD_n[0] * TDD[1]) - (TDD_n[1] * TDD[0]) ) / ( TDD_n[0] - TDD_n[1] ); Dk = (TDD[0] - TDD[1]) / (TDD_n[0] - TDD_n[1]); EndUN = TDU_n[1]; EndDN = TDD_n[1]; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int OnInit() { SetIndexBuffer(0,LU); SetIndexLabel(0,"TDLineU"); SetIndexBuffer(1,LD); SetIndexLabel(1,"TDLineD"); SetIndexEmptyValue(0,0); SetIndexEmptyValue(1,0); LastCount=iTime(NULL,0,1); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { //New candlestick or first launch if(iTime(NULL,0,0)!=LastCount) { double Ub,Uk,Db,Dk; int eUp,eDp; GetBK(Ub,Uk,Db,Dk,eUp,eDp); //Remove old values for(int i=0; i