//+------------------------------------------------------------------+ //| ProjectName | //| Copyright 2012, CompanyName | //| http://www.companyname.net | //+------------------------------------------------------------------+ #property copyright "Infoplus" #property link "http://www.infoplus.ipsys.net" #define MAGIC 1000 #include //------- Внешние параметры советника -------------------------------- extern string _Parameters_Trade="----- Параметры торговли"; extern bool UseTrailing=True; // Использовать трал extern bool ProfitTrailing= False; // Тралить только профит extern int TrailingStop = 20; // Фиксированный размер трала extern int TrailingStep=1; // Шаг трала extern int Slippage = 3; // Проскальзывание цены extern double Lott = 0.1; // Размер лота extern int Delta = 20; // Расстояние для стоп-ордеров extern double KK = 10; // Коэффициент умножения лота extern int ProfClose = 1; // Закрыть все при профите extern int TimeStart=7; //ограничение времени работы советника extern int TimeEnd= 23; //не открываем ордера и закрываем отложки если время не между TimeStart и TimeEnd extern string _Parameters_Expert="----- Параметры советника"; extern bool UseSound = True; // Использовать звуковой сигнал extern string NameFileSound = "expert.wav"; // Наименование звукового файла extern color clOpenBuy = LightBlue; // Цвет открытия покупки extern color clOpenSell = LightCoral; // Цвет открытия продажи extern color clModifyBuy = Aqua; // Цвет модификации покупки extern color clModifySell = Tomato; // Цвет модификации продажи extern color clCloseBuy = Blue; // Цвет закрытия покупки extern color clCloseSell = Red; // Цвет закрытия продажи //---- Глобальные переменные советника ------------------------------- int g_fontsize_544=10; int g_color_548 = Gold; int g_color_547 = Red; int g_color_5=Gold; double BStopLoss; double priceBid; double priceAsk; double HistoryZeroPrice,ZeroPrice,StopOutPrice; //----------- extern string Symbol_1="GBPJPY"; extern string Symbol_2="USDCHF"; extern string Symbol_3="EURUSD"; extern string Symbol_4="EURGBP"; extern string Symbol_5="GBPUSD"; extern string Symbol_6="EURCHF"; extern string Symbol_7="EURJPY"; extern string Symbol_8="GPBPCHF"; extern string Symbol_9="AUDJPY"; extern string Symbol_10="AUDUSD"; extern string Symbol_11="NZDUSD"; extern string Symbol_12="NZDJPY"; extern string Symbol_13="CHFJPY"; extern string Symbol_14="USDCHF"; extern int РазмерШрифта=10; //---- double LotS,ProfitS; double LotB,ProfitB; double LotT,ProfitT; double ProfitHistory; double PartEquity; color Color; int pos,orderremit,TotalOrders,Symb; string text; int File; string FileName; int CountDate; //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ void init() { Comment(""); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ void start() { IndikatorLots(); if(IsTrade()) { if(!ExistOrder(1)) { DeleteAllOrders(); Sleep(500); CalcLots(); SetOrders(1); } for(int i=2;i<30;i++) { if(!ExistOrder(i)) {if(ExistOrderTr(i-1)) {SetOrders(i); }} } } Show(); TrailingPositions(); } //+------------------------------------------------------------------+ //| Установка ордеров | //+------------------------------------------------------------------+ void SetOrders(int nn) { bool fc; StopOutPrice=0; ZeroPrice=0; if(nn==1) { fc=false; while(fc==false) { fc=OrderSend(Symbol(),OP_BUY,Lott,Ask,Slippage,0,0,"",MAGIC+1,0,clOpenBuy); EE(); } return; } if(MathMod(nn,2)!=0) { priceBid=Ask+Delta*Point; fc=false; while(fc==false) { fc=OrderSend(Symbol(),OP_BUYSTOP,NormalizeDouble(KK*Checks(nn-1),2),priceBid,Slippage,0,0,"",MAGIC+nn,0,clOpenBuy); } } if(MathMod(nn,2)==0) { priceBid=Bid-Delta*Point; fc=false; while(fc==false) { fc=OrderSend(Symbol(),OP_SELLSTOP,NormalizeDouble(KK*Checks(nn-1),2),priceBid,Slippage,0,0,"",MAGIC+nn,0,clOpenSell); } } } //+------------------------------------------------------------------+ //| Расчет лотов | //+------------------------------------------------------------------+ void CalcLots() { Lott=NormalizeDouble(AccountFreeMargin()/100000,2); ProfClose=NormalizeDouble(Lott*10,2); } //+------------------------------------------------------------------+ //| Подсчет профита | //+------------------------------------------------------------------+ string ShowProfit() { double Proff=0; for(int i=0; i=ProfClose) { CloseAll(0); DeleteAllOrders(); } return(Proff); } //+------------------------------------------------------------------+ //| Возвращает флаг существования ордера или позиции по номеру | //+------------------------------------------------------------------+ bool ExistOrder(int mn) { bool Exist=False; for(int i=0; i=0; i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) { if(OrderSymbol()==Symbol()) { if(OrderType()==OP_BUY) { fc=False; while(fc==False) { fc=OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,clCloseBuy); EE(); } } if(OrderType()==OP_SELL) { fc=False; while(fc==False) { fc=OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,clCloseSell); EE(); } } if(OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP || OrderType()==OP_SELLLIMIT || OrderType()==OP_BUYLIMIT) { fc=OrderDelete(OrderTicket()); } if(fc && UseSound) PlaySound(NameFileSound); } } } } } //+------------------------------------------------------------------+ //| выявление ошибок | //+------------------------------------------------------------------+ void EE() { int EError=GetLastError(); // Не получилось :( switch(EError) // Преодолимые ошибки { case 135:Alert("Цена изменилась. Пробуем ещё раз.."); RefreshRates(); // Обновим данные case 136:Alert("Нет цен. Ждём новый тик.."); while(RefreshRates()==false) // До нового тика Sleep(1); // Задержка в цикле // continue; // На след. итерацию case 146:Alert("Подсистема торговли занята. Пробуем ещё.."); Sleep(500); // Простое решение RefreshRates(); // Обновим данные } } //+------------------------------------------------------------------+ //| Удаление всех ордеров | //+------------------------------------------------------------------+ void DeleteAllOrders() { bool fd; for(int i=OrdersTotal()-1; i>=0; i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) { if(OrderSymbol()==Symbol()) { if(OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP) { fd=OrderDelete(OrderTicket()); if(fd && UseSound) PlaySound(NameFileSound); } } } } } //+------------------------------------------------------------------+ //| Стоп-ордерный тралл | //+------------------------------------------------------------------+ void TrailingPositions() { int i; for(i=0; iTrailingStop*Point) { if(OrderOpenPrice()TrailingStop*Point) { if(OrderOpenPrice()>Ask+(TrailingStop+TrailingStep-1)*Point) { double newprBS=Ask+TrailingStop*Point; ModStopOrders(newprBS,OP_BUYSTOP); } } } } } } //+------------------------------------------------------------------+ //| Модификация отл.ордера | //+------------------------------------------------------------------+ void ModStopOrders(double newprice,string OP) { bool fm; double SL=OrderStopLoss(); if(OP==OP_BUYSTOP) { SL=SL+TrailingStep*Point; } if(OP==OP_SELLSTOP) { SL=SL-TrailingStep*Point; } fm=OrderModify(OrderTicket(),newprice,0,0,0,Red); if(fm && UseSound) {PlaySound(NameFileSound); } } //+------------------------------------------------------------------+ //| Информпанель | //+------------------------------------------------------------------+ void Show() { string name_8="5"; if(ObjectFind(name_8)==-1) { ObjectCreate(name_8,OBJ_LABEL,0,0,0); ObjectSet(name_8,OBJPROP_CORNER,1); ObjectSet(name_8,OBJPROP_XDISTANCE,20); ObjectSet(name_8,OBJPROP_YDISTANCE,36); } ObjectSetText(name_8,"Баланс: "+DoubleToStr(AccountBalance(),2),g_fontsize_544,"Courier New",g_color_548); name_8="6"; if(ObjectFind(name_8)==-1) { ObjectCreate(name_8,OBJ_LABEL,0,0,0); ObjectSet(name_8,OBJPROP_CORNER,1); ObjectSet(name_8,OBJPROP_XDISTANCE,20); ObjectSet(name_8,OBJPROP_YDISTANCE,56); } ObjectSetText(name_8,"Средства: "+DoubleToStr(AccountFreeMargin(),2),g_fontsize_544,"Courier New",g_color_548); name_8="7"; if(ObjectFind(name_8)==-1) { ObjectCreate(name_8,OBJ_LABEL,0,0,0); ObjectSet(name_8,OBJPROP_CORNER,1); ObjectSet(name_8,OBJPROP_XDISTANCE,60); ObjectSet(name_8,OBJPROP_YDISTANCE,76); } if(AccountMargin()==0) { StopOutPrice=0; ZeroPrice=0; ObjectSetText(name_8,"Уровень: ",g_fontsize_544,"Courier New",g_color_548); } else { if(AccountEquity()/AccountMargin()*100<2000) {g_color_5=Red;} else {g_color_5=Gold;} ObjectSetText(name_8,"Уровень: "+DoubleToStr(AccountEquity()/AccountMargin()*100,2),g_fontsize_544,"Courier New",g_color_5); } name_8="8"; if(ObjectFind(name_8)==-1) { ObjectCreate(name_8,OBJ_LABEL,0,0,0); ObjectSet(name_8,OBJPROP_CORNER,1); ObjectSet(name_8,OBJPROP_XDISTANCE,60); ObjectSet(name_8,OBJPROP_YDISTANCE,96); } ObjectSetText(name_8,"Профит: "+DoubleToStr(ShowProfit(),2),g_fontsize_544,"Courier New",g_color_548); name_8="11"; if(ObjectFind(name_8)==-1) { ObjectCreate(name_8,OBJ_LABEL,0,0,0); ObjectSet(name_8,OBJPROP_CORNER,1); ObjectSet(name_8,OBJPROP_XDISTANCE,20); ObjectSet(name_8,OBJPROP_YDISTANCE,116); } ObjectSetText(name_8,"STOPLOSS: "+DoubleToStr(BStopLoss,4),g_fontsize_544,"Courier New",g_color_548); name_8="13"; if(ObjectFind(name_8)==-1) { ObjectCreate(name_8,OBJ_LABEL,0,0,0); ObjectSet(name_8,OBJPROP_CORNER,1); ObjectSet(name_8,OBJPROP_XDISTANCE,20); ObjectSet(name_8,OBJPROP_YDISTANCE,136); } ObjectSetText(name_8,"STOPOUT: "+DoubleToStr(StopOutPrice,4),g_fontsize_544,"Courier New",g_color_547); name_8="14"; if(ObjectFind(name_8)==-1) { ObjectCreate(name_8,OBJ_LABEL,0,0,0); ObjectSet(name_8,OBJPROP_CORNER,1); ObjectSet(name_8,OBJPROP_XDISTANCE,20); ObjectSet(name_8,OBJPROP_YDISTANCE,156); } ObjectSetText(name_8,"ZEROPRICE: "+DoubleToStr(ZeroPrice,4),g_fontsize_544,"Courier New",Red); name_8="15"; if(ObjectFind(name_8)==-1) { ObjectCreate(name_8,OBJ_LABEL,0,0,0); ObjectSet(name_8,OBJPROP_CORNER,1); ObjectSet(name_8,OBJPROP_XDISTANCE,20); ObjectSet(name_8,OBJPROP_YDISTANCE,176); } ObjectSetText(name_8,"BUY Lots: "+DoubleToStr(LotB,2),g_fontsize_544,"Courier New",g_color_548); name_8="16"; if(ObjectFind(name_8)==-1) { ObjectCreate(name_8,OBJ_LABEL,0,0,0); ObjectSet(name_8,OBJPROP_CORNER,1); ObjectSet(name_8,OBJPROP_XDISTANCE,20); ObjectSet(name_8,OBJPROP_YDISTANCE,196); } ObjectSetText(name_8,"SELL Lots: "+DoubleToStr(LotS,2),g_fontsize_544,"Courier New",g_color_548); name_8="17"; if(ObjectFind(name_8)==-1) { ObjectCreate(name_8,OBJ_LABEL,0,0,0); ObjectSet(name_8,OBJPROP_CORNER,1); ObjectSet(name_8,OBJPROP_XDISTANCE,20); ObjectSet(name_8,OBJPROP_YDISTANCE,216); } ObjectSetText(name_8,"BUY Profit: "+DoubleToStr(ProfitB,2),g_fontsize_544,"Courier New",g_color_548); name_8="18"; if(ObjectFind(name_8)==-1) { ObjectCreate(name_8,OBJ_LABEL,0,0,0); ObjectSet(name_8,OBJPROP_CORNER,1); ObjectSet(name_8,OBJPROP_XDISTANCE,20); ObjectSet(name_8,OBJPROP_YDISTANCE,236); } ObjectSetText(name_8,"SELL Profit: "+DoubleToStr(ProfitS,2),g_fontsize_544,"Courier New",g_color_548); name_8="19"; if(ObjectFind(name_8)==-1) { ObjectCreate(name_8,OBJ_LABEL,0,0,0); ObjectSet(name_8,OBJPROP_CORNER,1); ObjectSet(name_8,OBJPROP_XDISTANCE,20); ObjectSet(name_8,OBJPROP_YDISTANCE,256); } ObjectSetText(name_8,"ПрофитClose: "+DoubleToStr(ProfClose,2),g_fontsize_544,"Courier New",g_color_548); } //+------------------------------------------------------------------+ //| Торговля по времени | //+------------------------------------------------------------------+ bool IsTrade() { //--- int TekHour=Hour(); bool Trade; if(TimeStart=TimeStart && TekHourTimeEnd && (TekHour>=TimeStart || TekHour=0;pos--) { if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true) { if(OrderType()<=OP_SELL) { if(OrderType()==OP_BUY){Lot=OrderLots();} if(OrderType()==OP_SELL){Lot=-OrderLots();} if(OrderSymbol()==Symbol_1){Lot_1=NormalizeDouble(Lot_1+Lot,2);} else if(OrderSymbol()==Symbol_2){Lot_2=NormalizeDouble(Lot_2+Lot,2);} else if(OrderSymbol()==Symbol_3){Lot_3=NormalizeDouble(Lot_3+Lot,2);} else if(OrderSymbol()==Symbol_4){Lot_4=NormalizeDouble(Lot_4+Lot,2);} else if(OrderSymbol()==Symbol_5){Lot_5=NormalizeDouble(Lot_5+Lot,2);} else if(OrderSymbol()==Symbol_6){Lot_6=NormalizeDouble(Lot_6+Lot,2);} else if(OrderSymbol()==Symbol_7){Lot_7=NormalizeDouble(Lot_7+Lot,2);} else if(OrderSymbol()==Symbol_8){Lot_8=NormalizeDouble(Lot_8+Lot,2);} else if(OrderSymbol()==Symbol_9){Lot_9=NormalizeDouble(Lot_9+Lot,2);} else if(OrderSymbol()==Symbol_10){Lot_10=NormalizeDouble(Lot_10+Lot,2);} else { Alert("\"Inf_Open_Orders\". Появился ордер по неуказанному инструменту ",OrderSymbol(),"!"); return(0); } } } else Print("Ошибка ",GetLastError()); } Symb=0; if(Lot_1!=0){Symb++;} if(Lot_2!=0){Symb++;} if(Lot_3!=0){Symb++;} if(Lot_4!=0){Symb++;} if(Lot_5!=0){Symb++;} if(Lot_6!=0){Symb++;} if(Lot_7!=0){Symb++;} if(Lot_8!=0){Symb++;} if(Lot_9!=0){Symb++;} if(Lot_10!=0){Symb++;} } if(Symb!=0) { PartEquity=(AccountEquity()-AccountStopoutLevel()/100*AccountMargin())/Symb;//распределённые средства } //---- определение профитов и обьёмов лотов LotS=0; ProfitS=0; LotB=0; ProfitB=0; ProfitT=0; for(pos=OrdersTotal()-1; pos>=0; pos--) { if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true) { if(OrderSymbol()==Symbol()) { //---- if(OrderType()==OP_BUY) { LotB+=OrderLots(); ProfitB+=OrderProfit()+OrderSwap(); } //---- if(OrderType()==OP_SELL) { LotS+=OrderLots(); ProfitS+=OrderProfit()+OrderSwap(); } //---- ProfitT+=OrderProfit()+OrderSwap(); //---- } } else Print("Ошибка при доступе к реал базе (",GetLastError(),")"); } //---- определение начала отсчёта в истории ордеров if(AccountBalance()!=0) //---- { int order; for(pos=OrdersTotal()-1;pos>=0;pos--)//поиск наличия открытых ордеров { if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true) { if(OrderSymbol()==Symbol() && OrderType()<=OP_SELL) { order++; } } else Print("Ошибка при доступе к реал базе (",GetLastError(),")"); } } //---- string text=StringConcatenate("Total History profit (",TimeToStr(CountDate,TIME_DATE|TIME_MINUTES),")="); ObjectSetText("Inf_HistoryTotal",text,РазмерШрифта,"Arial",DarkOrange); //---- ProfitHistory=0; for(pos=OrdersHistoryTotal()-1;pos>=0;pos--)//подсчёт профита из истории { if(OrderSelect(pos,SELECT_BY_POS,MODE_HISTORY)==true) { if(OrderSymbol()==Symbol() && OrderOpenTime()>=CountDate) { ProfitHistory+=OrderProfit()+OrderSwap(); } } else Print("Ошибка при доступе к исторической базе (",GetLastError(),")"); } ProfitHistory=ProfitHistory+ProfitT; //---- выставление нулевых и StopOut уровней LotT=LotB-LotS; if(LotT!=0) { if(LotT>0)//Buy лот прeимущество { HistoryZeroPrice=NormalizeDouble(Bid-(ProfitHistory/LotT/TickVal*Point),Digits); ZeroPrice=NormalizeDouble(Bid-(ProfitT/LotT/TickVal*Point),Digits); StopOutPrice=NormalizeDouble(Bid-(PartEquity/LotT/TickVal*Point),Digits); } if(LotT<0)//Sell лот прeимущество { HistoryZeroPrice=NormalizeDouble(Ask-(ProfitHistory/LotT/TickVal*Point),Digits); ZeroPrice=NormalizeDouble(Ask-(ProfitT/LotT/TickVal*Point),Digits); StopOutPrice=NormalizeDouble(Ask-(PartEquity/LotT/TickVal*Point),Digits); } //---- Выставление общего нулевого реал уровня if(ObjectFind("Line of the zero price")!=0)//отсутствие Line zero в главном окне { ObjectCreate("Line of the zero price",OBJ_TREND,0,Time[5],ZeroPrice,Time[0]+Period()*60*20,ZeroPrice,0,0); ObjectSetText("Line of the zero price",DoubleToStr(ZeroPrice,Digits)); ObjectSet("Line of the zero price",OBJPROP_RAY,false); ObjectSet("Line of the zero price",OBJPROP_STYLE,STYLE_SOLID); ObjectSet("Line of the zero price",OBJPROP_WIDTH,1); ObjectSet("Line of the zero price",OBJPROP_COLOR,Gold); } else if(ObjectFind("Line of the zero price")==0)//наличие Line zero в главном окне { ObjectSetText("Line of the zero price",DoubleToStr(ZeroPrice,Digits)); ObjectSet("Line of the zero price",OBJPROP_TIME1,Time[5]); ObjectSet("Line of the zero price",OBJPROP_PRICE1,ZeroPrice); ObjectSet("Line of the zero price",OBJPROP_TIME2,Time[0]+Period()*60*20); ObjectSet("Line of the zero price",OBJPROP_PRICE2,ZeroPrice); } if(ObjectFind("Zero price")!=0)//отсутствие Arrow zero в главном окне { ObjectCreate("Zero price",OBJ_ARROW,0,Time[5],ZeroPrice,0,0,0,0); ObjectSet("Zero price",OBJPROP_ARROWCODE,5); ObjectSet("Zero price",OBJPROP_WIDTH,2); ObjectSet("Zero price",OBJPROP_COLOR,Gold); } else if(ObjectFind("Zero price")==0)//наличие Arrow zero в главном окне { ObjectSet("Zero price",OBJPROP_PRICE1,ZeroPrice); ObjectSet("Zero price",OBJPROP_TIME1,Time[5]); } //---- Выставление StopOut уровня if(ObjectFind("Line of the StopOut price")!=0) { ObjectCreate("Line of the StopOut price",OBJ_TREND,0,Time[5],StopOutPrice,Time[0]+Period()*60*20,StopOutPrice,0,0); ObjectSetText("Line of the StopOut price",DoubleToStr(StopOutPrice,Digits)); ObjectSet("Line of the StopOut price",OBJPROP_RAY,false); ObjectSet("Line of the StopOut price",OBJPROP_STYLE,STYLE_SOLID); ObjectSet("Line of the StopOut price",OBJPROP_WIDTH,2); ObjectSet("Line of the StopOut price",OBJPROP_COLOR,Brown); } else if(ObjectFind("Line of the StopOut price")==0) { ObjectSetText("Line of the StopOut price",DoubleToStr(StopOutPrice,Digits)); ObjectSet("Line of the StopOut price",OBJPROP_TIME1,Time[5]); ObjectSet("Line of the StopOut price",OBJPROP_PRICE1,StopOutPrice); ObjectSet("Line of the StopOut price",OBJPROP_TIME2,Time[0]+Period()*60*20); ObjectSet("Line of the StopOut price",OBJPROP_PRICE2,StopOutPrice); } if(ObjectFind("StopOut price")!=0) { ObjectCreate("StopOut price",OBJ_ARROW,0,Time[5],StopOutPrice,0,0,0,0); ObjectSet("StopOut price",OBJPROP_ARROWCODE,5); ObjectSet("StopOut price",OBJPROP_WIDTH,3); ObjectSet("StopOut price",OBJPROP_COLOR,Brown); } else if(ObjectFind("StopOut price")==0) { ObjectSet("StopOut price",OBJPROP_PRICE1,StopOutPrice); ObjectSet("StopOut price",OBJPROP_TIME1,Time[5]); } //---- } else if(LotT==0) { if(ObjectFind("Line of the history zero price")==0)ObjectDelete("Line of the history zero price"); if(ObjectFind("History zero price")==0)ObjectDelete("History zero price"); if(ObjectFind("Line of the zero price")==0)ObjectDelete("Line of the zero price"); if(ObjectFind("Zero price")==0)ObjectDelete("Zero price"); if(ObjectFind("Line of the StopOut price")==0)ObjectDelete("Line of the StopOut price"); if(ObjectFind("StopOut price")==0)ObjectDelete("StopOut price"); } //---- Выставление BUY нулевого уровня if(LotB>0) { double BUYZeroPrice; BUYZeroPrice=NormalizeDouble(Bid-(ProfitB/LotB/TickVal*Point),Digits); if(ObjectFind("Line of the BUY zero price")!=0) { ObjectCreate("Line of the BUY zero price",OBJ_TREND,0,Time[5],BUYZeroPrice,Time[0]+Period()*60*20,BUYZeroPrice,0,0); ObjectSetText("Line of the BUY zero price",DoubleToStr(BUYZeroPrice,Digits)); ObjectSet("Line of the BUY zero price",OBJPROP_RAY,false); ObjectSet("Line of the BUY zero price",OBJPROP_STYLE,STYLE_SOLID); ObjectSet("Line of the BUY zero price",OBJPROP_WIDTH,1); ObjectSet("Line of the BUY zero price",OBJPROP_COLOR,Chartreuse); } else if(ObjectFind("Line of the BUY zero price")==0) { ObjectSetText("Line of the BUY zero price",DoubleToStr(BUYZeroPrice,Digits)); ObjectSet("Line of the BUY zero price",OBJPROP_TIME1,Time[5]); ObjectSet("Line of the BUY zero price",OBJPROP_PRICE1,BUYZeroPrice); ObjectSet("Line of the BUY zero price",OBJPROP_TIME2,Time[0]+Period()*60*20); ObjectSet("Line of the BUY zero price",OBJPROP_PRICE2,BUYZeroPrice); } if(ObjectFind("BUY Zero price")!=0) { ObjectCreate("BUY Zero price",OBJ_ARROW,0,Time[5],BUYZeroPrice,0,0,0,0); ObjectSet("BUY Zero price",OBJPROP_ARROWCODE,5); ObjectSet("BUY Zero price",OBJPROP_WIDTH,2); ObjectSet("BUY Zero price",OBJPROP_COLOR,Chartreuse); } else if(ObjectFind("BUY Zero price")==0) { ObjectSet("BUY Zero price",OBJPROP_PRICE1,BUYZeroPrice); ObjectSet("BUY Zero price",OBJPROP_TIME1,Time[5]); } } else if(LotB==0) { if(ObjectFind("Line of the BUY zero price")==0)ObjectDelete("Line of the BUY zero price"); if(ObjectFind("BUY Zero price")==0)ObjectDelete("BUY Zero price"); } //---- Выставление SELL нулевого уровня if(LotS>0) { double SELLZeroPrice; SELLZeroPrice=NormalizeDouble(Ask+(ProfitS/LotS/TickVal*Point),Digits); if(ObjectFind("Line of the SELL zero price")!=0) { ObjectCreate("Line of the SELL zero price",OBJ_TREND,0,Time[5],SELLZeroPrice,Time[0]+Period()*60*20,SELLZeroPrice,0,0); ObjectSetText("Line of the SELL zero price",DoubleToStr(SELLZeroPrice,Digits)); ObjectSet("Line of the SELL zero price",OBJPROP_RAY,false); ObjectSet("Line of the SELL zero price",OBJPROP_STYLE,STYLE_SOLID); ObjectSet("Line of the SELL zero price",OBJPROP_WIDTH,1); ObjectSet("Line of the SELL zero price",OBJPROP_COLOR,DeepPink); } else if(ObjectFind("Line of the SELL zero price")==0) { ObjectSetText("Line of the SELL zero price",DoubleToStr(SELLZeroPrice,Digits)); ObjectSet("Line of the SELL zero price",OBJPROP_TIME1,Time[5]); ObjectSet("Line of the SELL zero price",OBJPROP_PRICE1,SELLZeroPrice); ObjectSet("Line of the SELL zero price",OBJPROP_TIME2,Time[0]+Period()*60*20); ObjectSet("Line of the SELL zero price",OBJPROP_PRICE2,SELLZeroPrice); } if(ObjectFind("SELL Zero price")!=0) { ObjectCreate("SELL Zero price",OBJ_ARROW,0,Time[5],SELLZeroPrice,0,0,0,0); ObjectSet("SELL Zero price",OBJPROP_ARROWCODE,5); ObjectSet("SELL Zero price",OBJPROP_WIDTH,2); ObjectSet("SELL Zero price",OBJPROP_COLOR,DeepPink); } else if(ObjectFind("SELL Zero price")==0) { ObjectSet("SELL Zero price",OBJPROP_PRICE1,SELLZeroPrice); ObjectSet("SELL Zero price",OBJPROP_TIME1,Time[5]); } } else if(LotS==0) { if(ObjectFind("Line of the SELL zero price")==0)ObjectDelete("Line of the SELL zero price"); if(ObjectFind("SELL Zero price")==0)ObjectDelete("SELL Zero price"); } //---- заполнение строк информацией ProfitB=NormalizeDouble(ProfitB,0); ProfitS=NormalizeDouble(ProfitS,0); ProfitHistory=NormalizeDouble(ProfitHistory,0); //строка Buy if(LotB>0) { text=DoubleToStr(LotB,2); } else if(LotB==0){text="";} ObjectSetText("Inf_BuyLots",text,РазмерШрифта,"Arial",Aqua); if(LotB>0) { if(ProfitB<0)Color=Red; if(ProfitB>0)Color=Green; if(ProfitB==0)Color=Gold; text=DoubleToStr(ProfitB,0); } else if(LotB==0){text="";} ObjectSetText("Inf_BuyProfit",text,РазмерШрифта,"Arial",Color); //строка Sell if(LotS>0) { text=DoubleToStr(LotS,2); } else if(LotS==0){text="";} ObjectSetText("Inf_SellLots",text,РазмерШрифта,"Arial",OrangeRed); if(LotS>0) { if(ProfitS<0)Color=Red; if(ProfitS>0)Color=Green; if(ProfitS==0)Color=Gold; text=DoubleToStr(ProfitS,0); } else if(LotS==0){text="";} ObjectSetText("Inf_SellProfit",text,РазмерШрифта,"Arial",Color); //строка тотал if(LotS>0 || LotB>0) { LotT=NormalizeDouble(LotB-LotS,2); if(LotT<0)Color=OrangeRed; if(LotT>0)Color=Aqua; if(LotT==0)Color=Gold; text=DoubleToStr(LotT,2); } else if(LotS==0 && LotB==0){text="";} ObjectSetText("Inf_TotalLots",text,РазмерШрифта,"Arial",Color); if(LotS>0 || LotB>0) { if(ProfitB+ProfitS<0)Color=Red; if(ProfitB+ProfitS>0)Color=Green; if(ProfitB+ProfitS==0)Color=Gold; text=DoubleToStr(ProfitB+ProfitS,0); } else if(LotS==0 && LotB==0){text="";} ObjectSetText("Inf_TotalProfit",text,РазмерШрифта,"Arial",Color); //строка History тотал if(LotS>0 || LotB>0) { if(ProfitHistory<0)Color=Red; if(ProfitHistory>0)Color=Green; if(ProfitHistory==0)Color=Gold; text=DoubleToStr(ProfitHistory,0); } else if(LotS==0 && LotB==0){text="";} ObjectSetText("Inf_HistoryTotalProfit",text,РазмерШрифта,"Arial",Color); //---- return(0); } //+------------------------------------------------------------------+