Код:
//+------------------------------------------------------------------+ //| @orders_view.mq4 | //+------------------------------------------------------------------+ int init() { //---- string $name; int $count=ObjectsTotal(); for(int $n=($count-1);$n>=0;$n--){ $name= ObjectName($n); if(StringSubstr($name,0,1)=="#"){ ObjectDelete($name); } } //---- return(0); } //+------------------------------------------------------------------+ //| script program start function | //+------------------------------------------------------------------+ int start() { //---- string $name,$nameb; color $tr_col; //ордера из истории if (OrdersHistoryTotal()>0){ for(int $j=OrdersHistoryTotal()-1;$j>=0;$j--){ OrderSelect($j,SELECT_BY_POS,MODE_HISTORY); if(Symbol()==OrderSymbol()){ int $OCT=OrderCloseTime(); int $OOT=OrderOpenTime(); double $OCP=OrderClosePrice(); double $OOP=OrderOpenPrice(); double $OL=OrderLots(); if(OrderType()==OP_SELL){ //начало ордера $name="#"+OrderTicket()+" sell "+DoubleToStr($OL,2)+" "+" at "+DoubleToStr($OOP,Digits); ObjectCreate($name, OBJ_ARROW, 0, $OOT,$OOP,0); ObjectSet($name,OBJPROP_ARROWCODE,1); ObjectSet($name,OBJPROP_COLOR,Red); ObjectSetText($name, TimeToStr($OOT,TIME_DATE|TIME_SECONDS)+" "+OrderComment()+" "+OrderMagicNumber()); //стоп if(OrderStopLoss()!=0 && OrderTakeProfit()==0){ $nameb=$name+" SL "+DoubleToStr(OrderStopLoss(),Digits); ObjectCreate($nameb, OBJ_TREND, 0,$OOT, OrderStopLoss(), $OCT,OrderStopLoss()); ObjectSet($nameb,OBJPROP_RAY,0); ObjectSet($nameb, OBJPROP_STYLE, STYLE_DASHDOT); ObjectSet($nameb,OBJPROP_COLOR,FireBrick); ObjectSetText($nameb, $nameb); } //профит if(OrderTakeProfit()!=0 && OrderStopLoss()==0){ $nameb=$name+" TP "+DoubleToStr(OrderTakeProfit(),Digits); ObjectCreate($nameb, OBJ_TREND, 0,$OOT, OrderTakeProfit(), $OCT,OrderTakeProfit()); ObjectSet($nameb,OBJPROP_RAY,0); ObjectSet($nameb, OBJPROP_STYLE, STYLE_DASHDOT); ObjectSet($nameb,OBJPROP_COLOR,FireBrick); ObjectSetText($nameb, $nameb); } if(OrderStopLoss()!=0 && OrderTakeProfit()!=0){ $nameb="#"+OrderTicket()+" SL "+DoubleToStr(OrderStopLoss(),Digits)+" TP "+DoubleToStr(OrderTakeProfit(),Digits); ObjectCreate($nameb, OBJ_RECTANGLE, 0,$OOT, OrderStopLoss(),$OCT, OrderTakeProfit()); ObjectSet($nameb, OBJPROP_STYLE, STYLE_DASHDOT); ObjectSet($nameb, OBJPROP_BACK, false); ObjectSet($nameb, OBJPROP_COLOR, FireBrick); ObjectSetText($nameb, $nameb); } //закрытие $name=$name+" close at "+DoubleToStr($OCP,Digits); ObjectCreate($name, OBJ_ARROW, 0, $OCT,$OCP,0); ObjectSet($name,OBJPROP_ARROWCODE,3); ObjectSet($name,OBJPROP_COLOR,Red); ObjectSetText($name, TimeToStr($OCT,TIME_DATE|TIME_SECONDS)); //путь ордера и прибыль в пунктах $name="#"+OrderTicket()+" "+DoubleToStr($OOP,Digits)+" -> "+DoubleToStr($OCP,Digits)+" = "+DoubleToStr(($OOP-$OCP)/Point,0)+"("+DoubleToStr(OrderProfit(),2)+")"; ObjectCreate($name, OBJ_TREND, 0,$OOT, $OOP, $OCT,$OCP); ObjectSet($name,OBJPROP_RAY,0); ObjectSet($name, OBJPROP_STYLE, STYLE_DOT); if($OCP>$OOP)$tr_col=Yellow; else $tr_col=Red; ObjectSet($name, OBJPROP_COLOR, $tr_col); } if(OrderType()==OP_BUY){ //начало ордера $name="#"+OrderTicket()+" buy "+DoubleToStr($OL,2)+" "+" at "+DoubleToStr($OOP,Digits); ObjectCreate($name, OBJ_ARROW, 0, $OOT,$OOP,0); ObjectSet($name,OBJPROP_ARROWCODE,1); ObjectSet($name,OBJPROP_COLOR,Blue); ObjectSetText($name, TimeToStr($OOT,TIME_DATE|TIME_SECONDS)+" "+OrderComment()+" "+OrderMagicNumber()); //стоп if(OrderStopLoss()!=0 && OrderTakeProfit()!=0){ $nameb=$name+" SL "+DoubleToStr(OrderStopLoss(),Digits); ObjectCreate($nameb, OBJ_TREND, 0,$OOT, OrderStopLoss(), $OCT,OrderStopLoss()); ObjectSet($nameb,OBJPROP_RAY,0); ObjectSet($nameb, OBJPROP_STYLE, STYLE_DASHDOT); ObjectSet($nameb,OBJPROP_COLOR,SteelBlue); ObjectSetText($nameb, $nameb); } //профит if(OrderTakeProfit()!=0 && OrderStopLoss()==0){ $nameb=$name+" TP "+DoubleToStr(OrderTakeProfit(),Digits); ObjectCreate($nameb, OBJ_TREND, 0,$OOT, OrderTakeProfit(), $OCT,OrderTakeProfit()); ObjectSet($nameb,OBJPROP_RAY,0); ObjectSet($nameb, OBJPROP_STYLE, STYLE_DASHDOT); ObjectSet($nameb,OBJPROP_COLOR,SteelBlue); ObjectSetText($nameb, $nameb); } if(OrderStopLoss()!=0 && OrderTakeProfit()!=0){ $nameb="#"+OrderTicket()+" SL "+DoubleToStr(OrderStopLoss(),Digits)+" TP "+DoubleToStr(OrderTakeProfit(),Digits); ObjectCreate($nameb, OBJ_RECTANGLE, 0,$OOT, OrderStopLoss(),$OCT, OrderTakeProfit()); ObjectSet($nameb, OBJPROP_STYLE, STYLE_DASHDOT); ObjectSet($nameb, OBJPROP_BACK, false); ObjectSet($nameb, OBJPROP_COLOR, SteelBlue); ObjectSetText($nameb, $nameb); } //закрытие $name=$name+" close at "+DoubleToStr($OCP,Digits); ObjectCreate($name, OBJ_ARROW, 0, $OCT,$OCP,0); ObjectSet($name,OBJPROP_ARROWCODE,3); ObjectSet($name,OBJPROP_COLOR,Blue); ObjectSetText($name, TimeToStr($OCT,TIME_DATE|TIME_SECONDS)); //путь ордера и прибыль в пунктах $name="#"+OrderTicket()+" "+DoubleToStr($OOP,Digits)+" -> "+DoubleToStr($OCP,Digits)+" = "+DoubleToStr(($OCP-$OOP)/Point,0)+"("+DoubleToStr(OrderProfit(),2)+")"; ObjectCreate($name, OBJ_TREND, 0,$OOT, $OOP, $OCT,$OCP); ObjectSet($name,OBJPROP_RAY,0); ObjectSet($name, OBJPROP_STYLE, STYLE_DOT); if($OCP<$OOP)$tr_col=Yellow; else $tr_col=DodgerBlue; ObjectSet($name, OBJPROP_COLOR, $tr_col); } } } } //открытые ордера if (OrdersTotal()>0){ for($j=OrdersTotal()-1;$j>=0;$j--){ OrderSelect($j,SELECT_BY_POS,MODE_TRADES); if(Symbol()==OrderSymbol()){ $OOT=OrderOpenTime(); $OOP=OrderOpenPrice(); $OL=OrderLots(); if(OrderType()==OP_SELL){ //начало ордера $name="#"+OrderTicket()+" sell "+DoubleToStr($OL,2)+" "+" at "+DoubleToStr($OOP,Digits); ObjectCreate($name, OBJ_ARROW, 0, $OOT,$OOP,0); ObjectSet($name,OBJPROP_ARROWCODE,1); ObjectSet($name,OBJPROP_COLOR,Red); ObjectSetText($name, TimeToStr($OOT,TIME_DATE|TIME_SECONDS)+" "+OrderComment()+" "+OrderMagicNumber()); //стоп if(OrderStopLoss()!=0){ $nameb=$name+" stop loss at "+DoubleToStr(OrderStopLoss(),Digits); ObjectCreate($nameb, OBJ_ARROW, 0, $OOT,OrderStopLoss(),0); ObjectSet($nameb,OBJPROP_ARROWCODE,4); ObjectSet($nameb,OBJPROP_COLOR,Red); } //профит if(OrderTakeProfit()!=0){ $nameb=$name+" take profit at "+DoubleToStr(OrderTakeProfit(),Digits); ObjectCreate($nameb, OBJ_ARROW, 0, $OOT,OrderTakeProfit(),0); ObjectSet($nameb,OBJPROP_ARROWCODE,4); ObjectSet($nameb,OBJPROP_COLOR,Red); } } if(OrderType()==OP_BUY){ //начало ордера $name="#"+OrderTicket()+" buy "+DoubleToStr($OL,2)+" "+" at "+DoubleToStr($OOP,Digits); ObjectCreate($name, OBJ_ARROW, 0, $OOT,$OOP,0); ObjectSet($name,OBJPROP_ARROWCODE,1); ObjectSet($name,OBJPROP_COLOR,Blue); ObjectSetText($name, TimeToStr($OOT,TIME_DATE|TIME_SECONDS)+" "+OrderComment()+" "+OrderMagicNumber()); //стоп if(OrderStopLoss()!=0){ $nameb=$name+" stop loss at "+DoubleToStr(OrderStopLoss(),Digits); ObjectCreate($nameb, OBJ_ARROW, 0, $OOT,OrderStopLoss(),0); ObjectSet($nameb,OBJPROP_ARROWCODE,4); ObjectSet($nameb,OBJPROP_COLOR,DodgerBlue); } //профит if(OrderTakeProfit()!=0){ $nameb=$name+" take profit at "+DoubleToStr(OrderTakeProfit(),Digits); ObjectCreate($nameb, OBJ_ARROW, 0, $OOT,OrderTakeProfit(),0); ObjectSet($nameb,OBJPROP_ARROWCODE,4); ObjectSet($nameb,OBJPROP_COLOR,DodgerBlue); } } } } } //---- return(0); } //+------------------------------------------------------------------+
Это мой скрипт.