#property strictextern double Lot = 0.1; extern int Magic = 454;extern int degree = 3;extern double kstd = 2.0;extern int bars = 250;extern int shift = 0;double SL1,SL2,TP1,TP2,TP3,TP4;//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+int OnInit() {//--- //--- return(INIT_SUCCEEDED); }//+------------------------------------------------------------------+//| Expert deinitialization function |//+------------------------------------------------------------------+void OnDeinit(const int reason) {//--- }//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+bool New_Bar=false;int start() { int kolpos = 0; double Line1 = iCustom (Symbol(),0,"i-Regr",1,1); double Line2 = iCustom (Symbol(),0,"i-Regr",2,1); //--- SL2 = MathMin(Low[2], Low[1]);SL1 = MathMax(High[2], High[1]); //---------------------------------------------------- if (Digits == 3) { TP1=NormalizeDouble((Low[1]+(High[1]-Low[2])*1.618),3); } if (Digits == 2) { TP1=NormalizeDouble((Low[1]+(High[1]-Low[2])*1.618),2); } if (Digits == 4) { TP1=NormalizeDouble((Low[1]+(High[1]-Low[2])*1.618),4); } if (Digits == 5) { TP1=NormalizeDouble((Low[1]+(High[1]-Low[2])*1.618),5); } //--------------------------------------------------- if (Digits == 3) { TP2=NormalizeDouble((High[1]-(High[2]-Low[1])*1.618),3); } if (Digits == 2) { TP2=NormalizeDouble((High[1]-(High[2]-Low[1])*1.618),2); } if (Digits == 4) { TP2=NormalizeDouble((High[1]-(High[2]-Low[1])*1.618),4); } if (Digits == 5) { TP2=NormalizeDouble((High[1]-(High[2]-Low[1])*1.618),5); } //-------------------------------------------- if (Digits == 3) { TP3=NormalizeDouble((High[1]-(High[2]-Low[1])*2.618),3); } if (Digits == 2) { TP3=NormalizeDouble((High[1]-(High[2]-Low[1])*2.618),2); } if (Digits == 4) { TP3=NormalizeDouble((High[1]-(High[2]-Low[1])*2.618),4); } if (Digits == 5) { TP3=NormalizeDouble((High[1]-(High[2]-Low[1])*2.618),5); } //------------------------------------------------------- if (Digits == 3) { TP4=NormalizeDouble((Low[1]+(High[1]-Low[2])*2.618),3); } if (Digits == 2) { TP4=NormalizeDouble((Low[1]+(High[1]-Low[2])*2.618),2); } if (Digits == 4) { TP4=NormalizeDouble((Low[1]+(High[1]-Low[2])*2.618),4); } if (Digits == 5) { TP4=NormalizeDouble((Low[1]+(High[1]-Low[2])*2.618),5); } for (int pos=0; pos<OrdersTotal();pos++) { OrderSelect (pos,SELECT_BY_POS,MODE_TRADES); if (OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic) kolpos++; } if (kolpos==0) { //-------------------------------------------------------- if (High[1] >= MathMax(Open[2], Close[2]) && High[1] >= MathMax(Open[3], Close[3]) && (High[2] - MathMax(Open[2],Close[2]))/MathAbs(Open[2]-Close[2]) > 2 && (MathMin(Open[2], Close[2]) - Low[2])< (High[2] - MathMax(Open[2],Close[2]))/2 && Close[1] < MathMin(Close[2], Open[2]) && Close[1]< MathMin(Open[3], Close[3]) &&Volume[0]>3) { OrderSend(Symbol(),OP_SELL,Lot,Bid,3,SL1,TP2,NULL,Magic,0,Red); } //---------------------------------------------------------- if (Open[1] >= MathMax(Open[2], Close[2]) && Close [1] >= MathMax(High[3], Close[3]) && (High[2] - MathMax(Open[2],Close[2]))/MathAbs(Open[2]-Close[2]) > 1 && (MathMin(Open[2], Close[2]) - Low[2])> (High[2] - MathMax(Open[2],Close[2]))/2 && Close[1] > MathMax(Close[2], Open[2]) && Close[1]> MathMax(Open[3], Close[3]) &&Volume[0]>3) { OrderSend(Symbol(),OP_BUY,Lot,Ask,3,SL2,TP1,NULL,Magic,0,Green); } //------------------------------------------------------- if (Open[1] >= MathMax(Open[2], Close[2]) && Close [1] >= MathMax(High[3], Close[3]) && (High[2] - MathMax(Open[2],Close[2]))/MathAbs(Open[2]-Close[2]) > 1 && (MathMin(Open[2], Close[2]) - Low[2])> (High[2] - MathMax(Open[2],Close[2]))/2 && Close[1] > MathMax(Close[2], Open[2]) && Close[1]> MathMax(Open[3], Close[3])&&Low[2]<Line2 &&Volume[0]>3) { OrderSend(Symbol(),OP_BUY,Lot,Ask,3,SL2,TP4,NULL,Magic,0,Green); } //------------------------------------------------------- if (High[1] >= MathMax(Open[2], Close[2]) && High[1] >= MathMax(Open[3], Close[3]) && (High[2] - MathMax(Open[2],Close[2]))/MathAbs(Open[2]-Close[2]) > 2 && (MathMin(Open[2], Close[2]) - Low[2])< (High[2] - MathMax(Open[2],Close[2]))/2 && Close[1] < MathMin(Close[2], Open[2]) && Close[1]< MathMin(Open[3], Close[3]) &&Volume[0]>3 &&Low[1]<Line2) { OrderSend(Symbol(),OP_SELL,Lot,Bid,3,SL1,TP3,NULL,Magic,0,Red); } } //----- return(0); } void Fun_New_Bar() // Ф-ия обнаружения .. { // .. нового бара static datetime New_Time=0; // Время текущего бара New_Bar=false; // Нового бара нет if(New_Time!=Time[0]) // Сравниваем время { New_Time=Time[0]; // Теперь время такое New_Bar=true; // Поймался новый бар } }//+------------------------------------------------------------------+