Time: 2012-09-19 | Download file:_StopOrders_Mouse.mq4
//+------------------------------------------------------------------+ //| Copyright © 2012, Vladimir Hlystov | //| cmillion@narod.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2012, Vladimir Hlystov" #property link "cmillion@narod.ru" #property show_inputs //-------------------------------------------------------------------- extern int Stoploss = 0, // Takeprofit = 0; // extern double Lots = 0.01; //если=0 то лот будет расчитан как процент от свободных средств по RiskPercent % extern double RiskPercent = 1.0; //Lots = AccountBalance() * (RiskPercent / 100.0) / 10000.0 extern int Magic = 0; // extern bool comment = true; //display information on screen //-------------------------------------------------------------------- int start() { double SL,TP; double Price = NormalizeDouble(WindowPriceOnDropped(),Digits); string txt=StringConcatenate("Stop the script issuing a warrant ",DoubleToStr(Price,Digits)," старт ",TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS)); RefreshRates(); double Lot = LOT(); if(Price>Ask) { if (Takeprofit!=0) TP = NormalizeDouble(Price + Takeprofit * Point,Digits); else TP=0; if (Stoploss!=0) SL = NormalizeDouble(Price - Stoploss * Point,Digits); else SL=0; if (OrderSend(Symbol(),OP_BUYSTOP,Lot,Price,0,SL,TP,"StopOrders",Magic,0,CLR_NONE)!=-1) txt = StringConcatenate(txt,"\nSet BUYSTOP ",DoubleToStr(Price,Digits)); else txt = StringConcatenate(txt,"\nError ",GetLastError()," BUYSTOP "); } if(Price0) return(Lots); double LOT = NormalizeDouble(AccountFreeMargin()* RiskPercent/100/MarketInfo(Symbol(),MODE_MARGINREQUIRED),2); if (LOT>MarketInfo(Symbol(),MODE_MAXLOT)) LOT = MarketInfo(Symbol(),MODE_MAXLOT); if (LOT