//======================= double linetrendn ;//=GET_SD(Symbol(),0,2); double lineduoiup ;//=GET_SD(Symbol(),0,3); double linetrenup ;//=GET_SD(Symbol(),0,1); double lineduoidn ;//=GET_SD(Symbol(),0,4); int caynen_sup,caynen_dem; void GET_SD(string sym, int timefamre)// index 1 = highup.2= highdn,3 = lowup, 4 = lowdn { linetrenup=0;linetrendn=0;lineduoiup=0;lineduoidn=0; caynen_sup=0;caynen_dem=0; string text; //----- for( int i =1;i< Bars;i++) { double value = iCustom(sym,timefamre,"SupplyDemand_chinhsua",2,i);//cay nen tren if(value > 0 ) { linetrenup = iHigh(sym,timefamre,i); linetrendn = MathMin(iClose(sym,timefamre,i),iOpen(sym,timefamre,i)); linetrendn = MathMax(linetrendn,MathMax(iLow(sym,timefamre,i-1),iLow(sym,timefamre,i+1))); linetrendn = MathMax(linetrendn,MathMin(iOpen(sym,timefamre,i-1),iClose(sym,timefamre,i-1))); linetrendn = MathMax(linetrendn,MathMin(iOpen(sym,timefamre,i+1),iClose(sym,timefamre,i+1))); // if(khoang_cach == false){break;} //Comment(value +" i "+ i); text += "cay nen up " +i; caynen_sup = i; bool next =false; for(int j = i-1;j>=0;j--) { if(iHigh(sym,timefamre,j)> linetrenup){next = true;} } if(next == false){ break;} // break; // if(MathAbs(MarketInfo(sym,MODE_BID)-linetrendn)> 2*MathAbs(linetrendn-linetrenup) ){ text += " cay nen up " +i; break;} } } for( i =1;i< Bars;i++) { value = iCustom(sym,timefamre,"SupplyDemand_chinhsua",5,i);//cay nen duoi if(value > 0 ) {//text += "cay nen down " +i; lineduoidn = iLow(sym,timefamre,i); lineduoiup = MathMax(iClose(sym,timefamre,i),iOpen(sym,timefamre,i)); if(i>0) lineduoiup = MathMin(lineduoiup,MathMin(iHigh(sym,timefamre,i+1),iHigh(sym,timefamre,i-1))); if(i>0) lineduoiup = MathMin(lineduoiup,MathMax(iOpen(sym,timefamre,i-1),iClose(sym,timefamre,i-1))); lineduoiup = MathMin(lineduoiup,MathMax(iOpen(sym,timefamre,i+1),iClose(sym,timefamre,i+1))); caynen_dem = i; text += " cay nen dn " +i; next =false; for(j = i-1;j>=0;j--) { if(iLow(sym,timefamre,j) < lineduoidn){next = true;} } if(next == false){ break;} // break; // if(khoang_cach == false){break;} // if(MathAbs(MarketInfo(sym,MODE_BID)-lineduoiup)>2* MathAbs(lineduoiup-lineduoidn) ){ text += "cay nen dn " +i; break;} } } //Comment(text+" --- "+linetrenup +" " +linetrendn +" " +lineduoiup +" " +lineduoidn ); // Comment(text); /*if( index1 == 1){return(linetrenup);} if( index1 == 2){return(linetrendn);} if( index1 == 3){return(lineduoiup);} if( index1 == 4){return(lineduoidn);} if( index1 == 5){return(caynen_sup);} if( index1 == 6){return(caynen_dem);}*/ } //99999999999999999999999999999999999999999999999999999999999999999 //------------- bool Check_inside(double gia1,double pllineduoi,double pllinetren) { double llineduoi = MathMin(pllineduoi,pllinetren); double llinetren = MathMax(pllineduoi,pllinetren); if( llineduoi <= gia1 && gia1 <= llinetren ){return (true);} else {return (false);} }