//+------------------------------------------------------------------+ //| Tracert.mq4 | //| Rosh | //| http://forexsystems.ru/phpBB/index.php | //+------------------------------------------------------------------+ #property copyright "Rosh" #property link "http://forexsystems.ru/phpBB/index.php" //+------------------------------------------------------------------+ //| script program start function | //+------------------------------------------------------------------+ double tr_AOPLong,tr_AOPShort; double tr_LongLots,tr_ShortLots; int tr_CurrLongOrders,tr_CurrShortOrders; int tr_Total,tr_Counter; int tr_PrevLongOrders,tr_PrevShortOrders; int tr_CurrTotalOpenedOrders,tr_PrevTotalOpenedOrders; double tr_CurrBalance,tr_PrevCurrBalance; color tr_ProfitColor=Lime, tr_LossColor=DeepPink,tr_LongAOPColor=Blue,tr_ShortAOPColor=Red, tr_CurrCloseColor; int tr_CloseLabelArrow=108, tr_AOPLabelArrow=159; bool tr_CloseLong,tr_CloseShort; double tr_CloseLabelPrice; int tr_CloseLabelShift=20; int tr_CounterCloseLabel=0,tr_CounterAOPLabel=0; int tr_Bars; void SetTrace() { //---- if (IsTesting()&&(tr_Bars!=Bars)) { tr_CloseLong=false; tr_CloseShort=false; tr_AOPLong=0.0; tr_AOPShort=0.0; tr_LongLots=0.0; tr_ShortLots=0.0; //tr_CloseLabelShift=iATR(NULL,0,100,1)*3.0/10.0/Point; if (tr_CurrBalance==0.0) { tr_CurrBalance=AccountBalance(); tr_PrevCurrBalance=AccountBalance(); } //----------------Проверка открытых позиций --------------------------- tr_CurrLongOrders=0; tr_CurrShortOrders=0; tr_CurrTotalOpenedOrders=0; tr_Total=OrdersTotal(); if (true) //if (tr_Total>0)// есть открытые позиции { //tr_AOPLong=0.0; //tr_AOPShort=0.0; //tr_LongLots=0.0; //tr_ShortLots=0.0; for (tr_Counter=0;tr_Counter0) tr_AOPLong=tr_AOPLong/tr_LongLots; if (tr_CurrShortOrders>0)tr_AOPShort=tr_AOPShort/tr_ShortLots; //--------------- усреднение --------------------- if (tr_AOPLong>0.0) { ObjectCreate("AOP"+tr_CounterAOPLabel,OBJ_ARROW,0,Time[1],tr_AOPLong);// не совсем корректно, но пока пойдет ObjectSet("AOP"+tr_CounterAOPLabel,OBJPROP_ARROWCODE,tr_AOPLabelArrow); ObjectSet("AOP"+tr_CounterAOPLabel,OBJPROP_COLOR,tr_LongAOPColor); tr_CounterAOPLabel++; } if (tr_AOPShort>0.0) { ObjectCreate("AOP"+tr_CounterAOPLabel,OBJ_ARROW,0,Time[1],tr_AOPShort);// не совсем корректно, но пока пойдет ObjectSet("AOP"+tr_CounterAOPLabel,OBJPROP_ARROWCODE,tr_AOPLabelArrow); ObjectSet("AOP"+tr_CounterAOPLabel,OBJPROP_COLOR,tr_ShortAOPColor); tr_CounterAOPLabel++; } // Print("Long=",tr_CurrLongOrders," tr_AOPLong=",tr_AOPLong," *** Short=",tr_CurrShortOrders," tr_AOPShort=",tr_AOPShort); tr_CurrTotalOpenedOrders=tr_CurrLongOrders+tr_CurrShortOrders; if ((tr_CurrTotalOpenedOrders!=tr_PrevTotalOpenedOrders)||(tr_PrevLongOrders!=tr_CurrLongOrders)||(tr_PrevShortOrders!=tr_CurrShortOrders)) // изменилось колчиство ордеров в рынке { if (tr_PrevLongOrders>tr_CurrLongOrders) // изменилось число ордеров в Long { tr_CloseLong=true; tr_CloseLabelPrice=High[1]+tr_CloseLabelShift*Point; } if (tr_PrevShortOrders>tr_CurrShortOrders) // изменилось число ордеров в Short { tr_CloseShort=true; tr_CloseLabelPrice=Low[1]-tr_CloseLabelShift*Point; } tr_PrevLongOrders=tr_CurrLongOrders; tr_PrevShortOrders=tr_CurrShortOrders; tr_PrevTotalOpenedOrders=tr_CurrTotalOpenedOrders; } }// есть открытые позиции //---------------- Проверка изменения Баланса tr_CurrBalance=AccountBalance(); if (tr_CurrBalance!=tr_PrevCurrBalance)// проверка изменения Balance { if (tr_CurrBalance-tr_PrevCurrBalance>0.0) tr_CurrCloseColor=tr_ProfitColor; else tr_CurrCloseColor=tr_LossColor; tr_PrevCurrBalance=tr_CurrBalance; //------------------ установка Метки закрытия -------------------- ObjectCreate("Close"+tr_CounterCloseLabel,OBJ_ARROW,0,Time[1],tr_CloseLabelPrice); ObjectSet("Close"+tr_CounterCloseLabel,OBJPROP_ARROWCODE,tr_CloseLabelArrow); ObjectSet("Close"+tr_CounterCloseLabel,OBJPROP_COLOR,tr_CurrCloseColor); tr_CounterCloseLabel++; //------------------ установка Метки закрытия -------------------- }// проверка изменения Balance }//(IsTesting()) //---- tr_Bars=Bars; return(0); } //+------------------------------------------------------------------+