#property copyright "NutCracker" #property link "forex-way@yandex.ru" #property link "http://wellforex.ru" //---- input parameters extern double Lots=0.1; extern int K=20; extern int D=24; extern int S=35; extern double Stop_Loss=400; extern double Take_Profit=750; extern double TS=900; extern double L_open=21; extern double EndTime=19; #define MAGICMA 20050610 double SMain_current_M15; double SMain_past_M15, MA_cur, MA_past; double SS_current_M15, SS_past_M15, Axel; double Trend_M15; double TrailingStop; double Delta_M15, Bar_Low_1, Bar_Hi_1, Bar_Low_M, Bar_Hi_M, Bar_Low_N, Bar_Hi_N,PriceUp, PriceDown, Bar_Open, Bar_Close; double Lev_Delta_Bay_Open_M15; double Lev_Delta_Sell_Open_M15; double Lev_Delta_Bay_Close_M15; double Lev_Delta_Sell_Close_M15; double Axel_lavel_Bay; double Axel_lavel_Sell; double Axel_M15; double Bay_Lavel; double Sell_Lavel; bool BuyOk, SellOk, BuyOk_N, SellOk_N; int MODE_AV; int Price_f; int Slaw; int Flag_Bay; int Flag_Sell; int res, cnt; int Slippage=6; int MaxTries=5, mode=0; int CalculateCurrentOrders(string symbol) { int buys=0,sells=0; //---- for(int i=0;i0) return(buys); else return(-sells); } void CloseOrdbyTime() { bool result; int total=OrdersTotal(); for (cnt=0;cnt1) return; SMain_current_M15=iStochastic(NULL,PERIOD_M15,K,D,S,MODE_AV,Price_f,MODE_MAIN,1); SS_current_M15=iStochastic(NULL,PERIOD_M15,K,D,S,MODE_AV,Price_f,MODE_SIGNAL,1); SMain_past_M15=iStochastic(NULL,PERIOD_M15,K,D,S,MODE_AV,Price_f,MODE_MAIN,2); if (SMain_current_M15>L_open && SMain_past_M150) { if(OrderSelect(res,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY по цене : ",OrderOpenPrice()); break; } else { Print("Error opening BUY order : ",GetLastError()); } } } if (SMain_current_M15<100-L_open && SMain_past_M15>100-L_open) { for (int tryy=1;tryy<=MaxTries;tryy++) { while (!IsTradeAllowed()) Sleep(5000); RefreshRates(); res=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+Stop_Loss*Point,Bid-Take_Profit*Point,"",MAGICMA,0,Red); Sleep(2000); if(res>0) { if(OrderSelect(res,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL по цене : ",OrderOpenPrice()); break; } else { Print("Error opening BUY order : ",GetLastError()); } } } return; } void TrailStops() { int total=OrdersTotal(); bool result; for (cnt=0;cntPoint*TS) { if(OrderStopLoss()(Point*TS)) { if((OrderStopLoss()>OrderOpenPrice()) || (OrderStopLoss()==0)) { for (int tryy=1;tryy<=MaxTries;tryy++) { while (!IsTradeAllowed()) Sleep(5000); RefreshRates(); result= OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Green); Sleep(2000); if (result) break; } } } } } } } int start() { MODE_AV=MODE_EMA; Price_f=1; TrailingStop=TS; if(Bars<100 || IsTradeAllowed()==false) return; if(CalculateCurrentOrders(Symbol())==0) { if (DayOfWeek()==3 && Hour()=EndTime && Hour()