// äëÿ UpTrendLines
if (Trend>=0){
Comm=Comm+"» "+Col[Step*2-1]+" UpTrendLine ";
col=ColNum[Step*2-1];
L1=GetTD(Step+BackStep,Buf2);
L2=GetNextLowTD(L1);
qTL=(Low[L1]-Low[L2])/(L2-L1);
qExt=Highest(NULL,0,MODE_HIGH,L2-L1-1,L1+1); // ëîêàëüíûé ìèíèìóì ìåæäó òî÷êàìè
qLevel=Low[L2]+qTL*L2; if (Step+BackStep==1) qLevel=qLevel+qTL*startBar;
if (L1<0 || L2<0) Comm=Comm+"íà ãðàôèêå íåäîñòàòî÷íî òî÷åê äëÿ ïîñòðîåíèÿ\n";
else {
Comm=Comm+"["+DoubleToStr(Low[L2],Digits)+"»"+DoubleToStr(Low[L1],Digits)+"]";
Comm=Comm+"; Level "+DoubleToStr(qLevel,Digits);
if (Step+BackStep==1) {
if (startBar>0) Comm=Comm+"; Future Bar "+DownHitch(-1,qLevel);
else Comm=Comm+"; Last Bar "+DownHitch(startBar,qLevel);
}
Comm=Comm+"\n";
// Àíàëèç — áûë ëè ïðîáîé òðåíäîâîé ëèíèè
i=L1;isHitch=false;Text="";
while(i>0 && isHitch==false){
tmp=Low[L2]+qTL*(L2-i);
Rem=«LA_»+Step;
if (Low[i]<tmp){
qp=DownHitch(i,tmp);
if (qp!=""){
isHitch=true;
Text=Text+"Èñò. (óð "+DoubleToStr(tmp,Digits)+") "+qp;
ObjectCreate(Rem,OBJ_ARROW,0,Time[i],Low[i]-Point);
ObjectSet(Rem,OBJPROP_COLOR,col); ObjectSet(Rem,OBJPROP_ARROWCODE,242);
while(i>0){ // ïðîáîé îòìåíåí, åñëè ïîñëå ïðîáîÿ áûë íîâûé õàé èëè çàêðûòèå âûøå
i--;
if (High[i]>High[qExt] || Close[i]>High[qExt]-(High[qExt]-Low[L1])*0.236){
Text=Text+" (îòìåíåí)";
ObjectSet(Rem,OBJPROP_PRICE1,Low[i]-Point); ObjectSet(Rem,OBJPROP_TIME1,Time[i]); ObjectSet(Rem,OBJPROP_ARROWCODE,251);
break;
}
}
}
else { Text=Text+"Ëîæ. (óð "+DoubleToStr(tmp,Digits)+"); "; ObjectDelete(Rem);}
}
i--;
}
if (Text=="") Text="Ïðîáîÿ íå áûëî.";
Comm=Comm+Text+"\n";
// end analysis
Rem=«LL_»+Step; // ñîáñíî ëèíèÿ òðåíäà
if (TrendLine==1) {
ObjectCreate(Rem,OBJ_TREND,0,Time[L2],Low[L2],Time[L1],Low[L1]);
ObjectSet(Rem,OBJPROP_COLOR,col); ObjectSet(Rem,OBJPROP_WIDTH,3-MathMin(2,Step));
}
Rem=«HLL_»+Step; // óðîâåíü ïðîáîÿ ëèíèè òðåíäà
if (HorizontLine && (Step+BackStep)==1){
ObjectCreate(Rem,OBJ_HLINE,0,0,qLevel);
ObjectSet(Rem,OBJPROP_COLOR,col);
}
Rem=«LCL_»+Step; // ëèíèÿ êàíàëà
if (ChannelLine){
ObjectCreate(Rem,OBJ_TREND,0,Time[qExt],High[qExt],Time[0],High[qExt]+qTL*qExt);
ObjectSet(Rem,OBJPROP_COLOR,col);
}
Rem=«LTL_»+Step;
if (TakeLines){ // ëèíèè öåëåé
LT[3]=qLevel-High[qExt]+(High[qExt]-Low[L1])*1.618; // äîï óðîâåíü
LT[0]=High[qExt]-qTL*(L2-qExt)-Low[L2];
LT[1]=Close[qExt]-qTL*(L2-qExt)-Low[L2];
qExt=Highest(NULL,0,MODE_CLOSE,L2-L1,L1);
LT[2]=Close[qExt]-qTL*(L2-qExt)-Low[L2];
Comm=Comm+"Öåëè: ";
for(i=0;i<4;i++){
qTL=NormalizeDouble(qLevel-LT[i],Digits);
ObjectCreate(Rem+i,OBJ_HLINE,0,0,qTL,0,0);
ObjectSet(Rem+i,OBJPROP_STYLE,STYLE_DOT); ObjectSet(Rem+i,OBJPROP_COLOR,col);
Comm=Comm+DoubleToStr(qTL,Digits)+" ("+DoubleToStr(LT[i]/Point,0)+"ï.) ";
}
Comm=Comm+"\n";
}
}
}
return(Comm);
}
int GetTD(int P, double Arr[]){
int i=0,j=0;
while(j<P){ i++; while(Arr[i]==0){i++;if(i>showBars-2)return(-1);} j++;}
return (i);
}
int GetNextHighTD(int P){
int i=P+1;
while(Buf1[i]<=High[P]){i++;if(i>showBars-2)return(-1);}
return (i);
}
int GetNextLowTD(int P){
int i=P+1;
while(Buf2[i]>=Low[P] || Buf2[i]==0){i++;if(i>showBars-2)return(-1);}
return (i);
}
// ðåêóðñèâíàÿ ïðîâåðêà íà óñëîâèÿ Äåìàðêà (õàé), âîçâðàùàåò çíà÷åíèå èëè 0
double DemHigh(int cnt, int sh){
if (High[cnt]>=High[cnt+sh] && High[cnt]>High[cnt-sh]) {
if (sh>1) return(DemHigh(cnt,sh-1));
else return(High[cnt]);
}
else return(0);
}
// ðåêóðñèâíàÿ ïðîâåðêà íà óñëîâèÿ Äåìàðêà (ëîó), âîçâðàùàåò çíà÷åíèå èëè 0
double DemLow(int cnt, int sh){
if (Low[cnt]<=Low[cnt+sh] && Low[cnt]<Low[cnt-sh]) {
if (sh>1) return(DemLow(cnt,sh-1));
else return(Low[cnt]);
}
else return(0);
}
string On(bool On){
if (On) return("Âêë"); else return("Âûêë");
}
string UpHitch(int P, double qLevel){ // îïðåäåëåíèå êâàëèôèêàòîðîâ ïðîðûâà ââåðõ
string Comm="";
if (Close[P+1]<Close[P+2]) Comm=Comm+" 1";
if (P>=0 && Open[P]>qLevel) Comm=Comm+" 2";
if (2*Close[P+1]-Low[P+1]<qLevel) Comm=Comm+" 3";
if (Comm!="") Comm="[ Êâ.Ïð:"+Comm+" ]";
return(Comm);
}
string DownHitch(int P, double qLevel){ // îïðåäåëåíèå êâàëèôèêàòîðîâ ïðîðûâà âíèç
string Comm="";
if (Close[P+1]>Close[P+2]) Comm=Comm+" 1";
if (P>=0 && Open[P]<qLevel) Comm=Comm+" 2";
if (2*Close[P+1]-High[P+1]>qLevel) Comm=Comm+" 3";
if (Comm!="") Comm="[ Êâ.Ïð:"+Comm+" ]";
return(Comm);
}
HoaNguyen