//+------------------------------------------------------------------+ //| iK_trend_v01.mq4 | //| Ivan Katsko | //| ICQ:372739628 | //+------------------------------------------------------------------+ #property copyright "Ivan Katsko" #property link "ICQ:372739628" //---- indicator settings #property indicator_separate_window #property indicator_buffers 3 #property indicator_color2 Blue #property indicator_width1 2 #property indicator_color1 Red #property indicator_color3 Green #property indicator_width2 2 #property indicator_width3 2 //---- indicator parameters extern int PeriodMA=3; extern int History=200; extern int VerExtr=10; //---- indicator buffers double up; double BuySell; double Trend[]; double Trade[]; double SL[]; double Delta[]; double DeltaMA[]; //+------------------------------------------------------------------+ int init() { //---- IndicatorBuffers(5); //---- SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexDrawBegin(0,VerExtr); SetIndexStyle(0,DRAW_LINE); SetIndexStyle(2,DRAW_LINE); IndicatorDigits(Digits+5); //---- SetIndexBuffer(1,Trend); SetIndexBuffer(0,SL); SetIndexBuffer(2,Trade); SetIndexBuffer(3,Delta); SetIndexBuffer(4,DeltaMA); //---- IndicatorShortName("iK_trend("+PeriodMA+","+History+","+VerExtr+")"); //---- return(0); } //+------------------------------------------------------------------+ int start() { int limit; // int counted_bars=IndicatorCounted(); //---- last counted bar will be recounted // if(counted_bars>0) counted_bars--; // limit=Bars-counted_bars; limit=History; //---- Разница двух МА-шек for(int i=0; i=0; i--) { if (MathAbs(Delta[i])>min && Delta[i]>0) { Trend[i]=MathRound(Open[1]); BuySell=1; } else if (MathAbs(Delta[i])>min && Delta[i]<0) { Trend[i]=-MathRound(Open[1]); BuySell=-1; } else { Trend[i]=0; } if ((BuySell==1 && Delta[i]<0 && MathAbs(Delta[i])>0.33*min) || (BuySell==-1 && Delta[i]>0 && MathAbs(Delta[i])>0.33*min)) { BuySell=0; } if (BuySell==1) Trade[i]=MathRound(Open[1])/2; else if (BuySell==-1) Trade[i]=-MathRound(Open[1])/2; else Trade[i]=0; } up=0; for(i=0; i=0 && Trade[i+1]<0 && Trade[i+2]>=0) || (Trade[i]<=0 && Trade[i+1]>0 && Trade[i+2]<=0) ) { up=1; minmin=min; min=DeltaMA[1]*100; for(i=0; iDeltaMA[i] && minmin0 && Low[i]SL[0]) SL[0]=High[i]; if (Trade[0]==0) SL[0]=0; } if (Trade[0]>0)SL[0]=-(SL[0] - MarketInfo(Symbol(), MODE_SPREAD)*Point); if (Trade[0]<0)SL[0]= SL[0] + MarketInfo(Symbol(), MODE_SPREAD)*Point; for(i=0; i<3; i++) SL[i]=SL[0]; //---- done return(0); }