HistoryGraph

Author: Copyright � 2010, freeman
Orders Execution
Checks for the total of closed orders
0 Views
0 Downloads
0 Favorites
HistoryGraph
//+------------------------------------------------------------------+
//|                                                History_graph.mq4 |
//|                                        Copyright © 2010, freeman |
//|                                           http://www.level.one   |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, freeman"
#property link      "http://www.level.one"

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+

// êîíñòàíòû
#define color_open_arrow MediumBlue 
#define color_close_arrow_good Blue 
#define color_close_arrow_bad Red 
#define color_line_good LimeGreen
#define color_line_bad Crimson
#define code_open_arrow_up 246 
#define code_open_arrow_down 248 
#define code_close_arrow_good 74 
#define code_close_arrow_bad 76 

int start()
  {
//----
   MathSrand(TimeLocal());

   string name, symb = Symbol();
   int i, arrow_code, order_type, color_close_arrow, line_color, accTotal=OrdersHistoryTotal();
   datetime t1, t2;
   double p1, p2;
   bool profit;
   
   for(i=0;i<accTotal;i++)
      {
         if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false)
            {
               Print("Îøèáêà ïðè äîñòóïå ê èñòîðè÷åñêîé áàçå (",GetLastError(),")");
               break;
            }
         if(OrderSymbol()!=symb) continue;   // åñëè íå òîò èíñòðóìåíò, òî áåðåì ñëåäóþùèé îðäåð
       
         order_type = OrderType();
         if(!((order_type==OP_BUY )||(order_type==OP_SELL ))) continue; // îáðàáàòûâàåì òîëüêî îðäåðà íà ïîêóïêó èëè ïðîäàæó
         
         if(OrderProfit()>0) 
            profit = true;
         else  
            profit = false;   
         
         t1 = OrderOpenTime();
         t2 = OrderCloseTime();
         p1 = OrderOpenPrice();
         p2 = OrderClosePrice();
         
// ðèñóåì îòêðûâàþùóþ ñòðåëêó         
         name = StringConcatenate("##hg", DoubleToStr(i,0),"-",DoubleToStr(MathRand(),0)); 
         ObjectCreate(name,OBJ_ARROW,0,t1,p1);
         if (order_type==OP_BUY) 
            arrow_code = code_open_arrow_up;
         else 
            arrow_code = code_open_arrow_down;
         ObjectSet(name,OBJPROP_ARROWCODE,arrow_code);
         ObjectSet(name,OBJPROP_COLOR,color_open_arrow);
         ObjectSet(name,OBJPROP_WIDTH,2);

// ðèñóåì çàêðûâàþùèé çíà÷îê         
         name = StringConcatenate("##hg", DoubleToStr(i,0),"-",DoubleToStr(MathRand(),0)); 
         ObjectCreate(name,OBJ_ARROW,0,t2,p2);
         if (profit)
            { 
               arrow_code = code_close_arrow_good;
               color_close_arrow = color_close_arrow_good;
            }
         else
            {
               arrow_code = code_close_arrow_bad;
               color_close_arrow = color_close_arrow_bad;
            }
         ObjectSet(name,OBJPROP_ARROWCODE,arrow_code);
         ObjectSet(name,OBJPROP_COLOR,color_close_arrow);
         ObjectSet(name,OBJPROP_WIDTH,1);
  
 // ðèñóåì ñîåäèíèòåëüíûé ïóíêòèð 
         name = StringConcatenate("##hg", DoubleToStr(i,0),"-",DoubleToStr(MathRand(),0)); 
         ObjectCreate(name,OBJ_TREND,0,t1,p1,t2,p2);
         if (profit) 
            line_color = color_line_good;
         else 
            line_color = color_line_bad;
         ObjectSet(name,OBJPROP_COLOR,line_color);
         ObjectSet(name,OBJPROP_STYLE,STYLE_DASHDOTDOT);
         ObjectSet(name,OBJPROP_RAY,false);
         ObjectSet(name,OBJPROP_WIDTH,3);
      } 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+


Comments