//+------------------------------------------------------------------+ //| Фунт Покупка.mqh | //| Copyright 2016, Yury V. Reshetov | //| http://yury-reshetov.com/forum/55 | //+------------------------------------------------------------------+ #property copyright "Copyright 2016, Yury V. Reshetov" #property link "http://yury-reshetov.com/forum/55" #property indicator_chart_window #property indicator_buffers 15 double Buffer5[]; double Buffer6[]; int b; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int init() { SetIndexStyle(5,DRAW_ARROW,STYLE_SOLID,2,Blue); SetIndexArrow(5,241);// DaDA SetIndexBuffer(5,Buffer5);// Назначение массива буферу SetIndexEmptyValue(5,0.0); SetIndexStyle(6,DRAW_ARROW,STYLE_SOLID,2,Blue); SetIndexArrow(6,242);// NetNet SetIndexBuffer(6,Buffer6);// Назначение массива буферу SetIndexEmptyValue(6,0.0); return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int OnCalculate( const int rates_total, // размер входных таймсерий const int prev_calculated, // обработано баров на предыдущем вызове const datetime& time[], // Time const double& open[], // Open const double& high[], // High const double& low[], // Low const double& close[], // Close const long& tick_volume[], // Tick Volume const long& volume[], // Real Volume const int &spread[] // Spread ) { int i,limit,K=5,K1=5; int counted_bars=IndicatorCounted(); if(counted_bars<1) limit=Bars-1; else limit=Bars-counted_bars; if(b!=Bars) { b=Bars; double SG=0; for(i=limit-1; i>=1; i--) { double VOL=iCustom(NULL,0,"eVOLution-dvoid.1.3 (1)",1,i); double OPN=iCustom(NULL,0,"eVOLution-dvoid.1.3 (1)",2,i); double Signal=iCustom(NULL,0,"TDSEQUENTA v2015",K,K1,12,6,i); if((Signal<0) && (VOL>0) && (OPN>0)) { double PONT=iCustom(NULL,0,"TDSEQUENTA v2015",K,K1,12,5,i); if(PONT==1) PONT=2; double v0=iCustom(NULL, 0, "ClusterX_CumDelta1","6C 03-17",0,i)-iCustom(NULL, 0, "ClusterX_CumDelta1","6C 03-17",0,i+PONT); double v1=iCustom(NULL, 0, "ClusterX_CumDelta1","6N 03-17",0,i)-iCustom(NULL, 0, "ClusterX_CumDelta1","6N 03-17",0,i+PONT); double v2=iCustom(NULL, 0, "ClusterX_CumDelta1","DX 03-17",0,i)-iCustom(NULL, 0, "ClusterX_CumDelta1","DX 03-17",0,i+PONT); double v3=iCustom(NULL, 0, "ClusterX_CumDelta1","6C 03-17",0,i)-iCustom(NULL, 0, "ClusterX_CumDelta1","6C 03-17",0,i+PONT); if(getTernaryClassificator(v0,v1,v2,v3)>0){Buffer5[i]=Low[i]-150*Point;} if(getTernaryClassificator(v0,v1,v2,v3)<=0){Buffer6[i]=High[i]+150*Point;} } } } return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double getBinaryClassificator1(double v0,double v1,double v2,double v3) { double x0 = 2.0 * (v0 + 618.0) / 827.0 - 1.0; double x1 = 2.0 * (v1 + 96.0) / 433.0 - 1.0; double x2 = 2.0 * (v2 + 296.0) / 772.0 - 1.0; double x3 = 2.0 * (v3 + 618.0) / 827.0 - 1.0; double decision=-3.3491480611045827*x1 +2.665834312573443*sigmoid(x2) -1.7100470035252644*sigmoid(x1+x2) +7.968566392479436*sigmoid(x0+x1+x3) -5.946876224050137*sigmoid(1.0+x2) + 0.6858597728162945 * sigmoid(1.0 + x0 + x1 + x2) + 0.6858108108108109 * sigmoid(1.0 + x1 + x2 + x3); return decision; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double sigmoid(double x) { if(MathAbs(x)<1.0) { return 2.0 * signum(x) - x; } return signum(x); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double getBinaryClassificator2(double v0,double v1,double v2,double v3) { double x0 = 2.0 * (v0 + 156.0) / 1243.0 - 1.0; double x1 = 2.0 * (v1 + 265.0) / 930.0 - 1.0; double x2 = 2.0 * (v2 + 1079.0) / 1052.0 - 1.0; double x3 = 2.0 * (v3 + 156.0) / 1243.0 - 1.0; double decision=-0.007134043746494672*sigmoid(x1) + 0.01802019068984857 * sigmoid(x0 + x2) + 0.7998149186763881 * sigmoid(x0 + x1 + x3) + 0.01802019068984857 * sigmoid(x2 + x3) + 0.18139091418956815 * sigmoid(x0 + x2 + x3) + 0.3041503084688727 * sigmoid(1.0 + x0) -0.2522546270330903 * sigmoid(1.0 + x0 + x1) -0.15318003365114974 * sigmoid(1.0 + x0 + x1 + x2) +0.3041503084688727*sigmoid(1.0+x3) -0.2522546270330903 * sigmoid(1.0 + x1 + x3) -0.15318003365114974 * sigmoid(1.0 + x1 + x2 + x3) +0.192456533931576*sigmoid(1.0+x0+x1+x2+x3); return decision; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double signum(double x) { if(x==0.0) { return 0.0; } if(x>0.0) { return 1.0; } return -1.0; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int getTernaryClassificator(double x0,double x1,double x2,double x3) { double result1 = getBinaryClassificator1(x0, x1, x2, x3); double result2 = getBinaryClassificator2(x0, x1, x2, x3); if((result1*result2)>0.0) { if(result1>0.0) { return(1); } else { return(0); } } return(-1); } //+------------------------------------------------------------------+