//+------------------------------------------------------------------+ //| ProjectName | //| Copyright 2012, CompanyName | //| http://www.companyname.net | //+------------------------------------------------------------------+ #property copyright "Dima Z" extern int SL=0; extern int TP=0; extern bool AllPositions=True; // Управлять всеми позициями extern bool ProfitTrailing = True; // Тралить только профит extern int TrailingStop = 30; // Фиксированный размер трала extern int TrailingStep = 1; // Шаг трала extern bool UseSound = True; // Использовать звуковой сигнал extern string NameFileSound="expert.wav"; // Наименование звукового файла extern int time=0; //1 - включено, 0 - выключено. extern int starttime= 7; extern int stoptime = 17; extern int mn=1; extern int MAGIC=777; extern double Lots=0.01; int err; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { { for(int i=0; i-99.9 && okbuy==1) { okbuy=0; if(timecontrol()==1) { op=Ask;if(SL>0){sl=Ask-SL*Point*mn;}if(TP>0){tp=Ask+TP*Point*mn;} err=OrderSend(Symbol(),OP_BUY,Lots,NormalizeDouble(op,Digits),3,NormalizeDouble(sl,Digits),NormalizeDouble(tp,Digits),"",MAGIC,0,Blue); if(err<0){Print("OrderSend()- Ошибка OP_BUY. op "+op+" sl "+sl+" tp "+tp+" "+GetLastError());} } CloseAllPos(0); } if(WPRur>-0.1) {oksell=1;} if(WPRur<-0.1 && oksell==1) { oksell=0; if(timecontrol()==1) { op=Bid;if(SL>0){sl=Bid+SL*Point*mn;}if(TP>0){tp=Bid-TP*Point*mn;} err=OrderSend(Symbol(),OP_SELL,Lots,NormalizeDouble(op,Digits),3,NormalizeDouble(sl,Digits),NormalizeDouble(tp,Digits),"",MAGIC,0,Red); if(err<0){Print("OrderSend()- Ошибка OP_SELL. op "+op+" sl "+sl+" tp "+tp+" "+GetLastError());} } CloseAllPos(1); } } //Закрываем все позиции по типу int CloseAllPos(int type) { int buy=1; int sell=1; int i,b=0; if(type==1) { while(buy==1) { buy=0; for(i=0;i=0 && Hour()<=stoptime-1) || (Hour()>=starttime && Hour()<=23)) && starttime>stoptime) { return(1); } if((Hour()>=starttime && Hour()<=stoptime-1) && starttimeTrailingStop*pp) { if(OrderStopLoss()TrailingStop*pp) { if(OrderStopLoss()>pAsk+(TrailingStop+TrailingStep-1)*pp || OrderStopLoss()==0) { ModifyStopLoss(pAsk+TrailingStop*pp); return; } } } } //+------------------------------------------------------------------+ //| Перенос уровня StopLoss | //| Параметры: | //| ldStopLoss - уровень StopLoss | //+------------------------------------------------------------------+ void ModifyStopLoss(double ldStopLoss) { bool fm; fm=OrderModify(OrderTicket(),OrderOpenPrice(),ldStopLoss,OrderTakeProfit(),0,CLR_NONE); if(fm && UseSound) PlaySound(NameFileSound); } //+------------------------------------------------------------------+