OrderScreenShot_v1

Author: *
OrderScreenShot_v1
Price Data Components
Series array that contains open time of each bar
Orders Execution
Checks for the total of open orders
Miscellaneous
It issuies visual alerts to the screenUses files from the file system
0 Views
0 Downloads
0 Favorites
OrderScreenShot_v1
//+------------------------------------------------------------------+
//|                                           OrderScreenShot_v1.mq4 |
//|                                                                * |
//|                                                                * |
//+------------------------------------------------------------------+

#import "user32.dll"
   int GetAncestor(int hWnd, int gaFlags);
   int GetDlgItem(int hDlg, int nIDDlgItem);
   int SendMessageA(int hWnd, int Msg, int wParam, int lParam);
   int GetWindowTextA(int hWnd, string lpString, int nMaxCount);
   int GetWindowTextLengthA(int hWnd);
   int GetWindowRect(int hWnd,int & lpRect[]);
  
  
#import

#property copyright "*"
#property link      "*"

#property indicator_chart_window
//---- input parameters
string    Path="OrderScreenShot";
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start(){

         if(!IsDllsAllowed()){
            Alert("Ðàçðåøèòå DLL â íàñòðîéêàõ òåðìèíàëà");
         }


      static   bool ft=false;
      static   int LastTickets[];
               int NowTickets[];
               int Size=0;  
               
               
      ArrayResize(NowTickets,OrdersTotal());

         for(int i=0;i<OrdersTotal();i++){
            if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){
               if(OrderMagicNumber()==0){
                  if(OrderSymbol()==Symbol()){
                     if(OrderType()==OP_BUY || OrderType()==OP_SELL){
                        NowTickets[Size]=OrderTicket();
                        Size++;
                     }
                  }
               }
            }
         }
      ArrayResize(NowTickets,Size);

      //===================================================================
      
         if(ft){
            for(i=0;i<Size;i++){
               bool exist=false;
                  for(int j=0;j<ArraySize(LastTickets);j++){
                     if(NowTickets[i]==LastTickets[j]){
                        exist=true;
                     }
                  }
                  if(!exist){
                     if(OrderSelect(NowTickets[i],SELECT_BY_TICKET)){
                        if(Symbol()+","+fTimeFrameName(Period())==GetNameActiveChart()){
                           int Rect[4];
                           GetWindowRect(WindowHandle(Symbol(),Period()),Rect);
                           Comment(OrderTicket()+" "+fNameOrderType(OrderType())+" "+Symbol()+" "+DS2(OrderLots())+", price: "+DS(OrderOpenPrice()));
                           int h=FileOpen(Path+"\\1.txt",FILE_CSV|FILE_WRITE);
                           FileClose(h);
                           FileDelete(Path+"\\1.txt");
                           string Path2=Path+"\\";
                           Path2=Path2+FM2(TimeDay(OrderOpenTime()))+"."+FM2(TimeMonth(OrderOpenTime()))+"."+TimeYear(OrderOpenTime())+"\\";
                           Path2=Path2+FM2(TimeHour(OrderOpenTime()))+"h"+FM2(TimeMinute(OrderOpenTime()))+"m"+FM2(TimeSeconds(OrderOpenTime()))+"s "+OrderTicket()+".gif";
                           WindowScreenShot(Path2,Rect[2]-Rect[0],Rect[3]-Rect[1]);
                           Comment("");
                        }               
                     }
                     else{
                        return;
                     }
                  }
            }
         }
      
      //===================================================================
      
      ArrayResize(LastTickets,Size);
         if(Size>0){
            ArrayCopy(LastTickets,NowTickets);
         }
      ft=true;         
               



   return(0);
  }
//+------------------------------------------------------------------+

string FM2(int aArg){
      if(aArg<10){
         return("0"+aArg);
      }
   return(aArg);
}

string DS2(double v){return(DoubleToStr(v,2));}

string DS(double v){return(DoubleToStr(v, Digits));}

string fNameOrderType(int aOrderType){
   switch (aOrderType){
      case OP_BUY: return("BUY");
      case OP_SELL: return("SELL");
      case OP_BUYLIMIT: return("BUYLIMIT");
      case OP_SELLLIMIT: return("SELLLIMIT");      
      case OP_BUYSTOP: return("BUYSTOP");
      case OP_SELLSTOP: return("SELLSTOP"); 
      default: return("?");
   }
}


string GetNameActiveChart(){
   int ThWnd,hMDICWnd,hMDIAWnd,nMxCnt;
   string sActiveChartName="                             ";
   ThWnd=GetAncestor(WindowHandle(Symbol(),Period()),2);
   hMDICWnd=GetDlgItem(ThWnd,0xE900);
   hMDIAWnd=SendMessageA(hMDICWnd,0x0229,0,0);
   nMxCnt=GetWindowTextLengthA(hMDIAWnd);
   GetWindowTextA(hMDIAWnd,sActiveChartName,nMxCnt+1);
   return(sActiveChartName);
}

string fTimeFrameName(int arg){

   // fTimeFrameName();

   int v;
      if(arg==0){
         v=Period();
      }
      else{
         v=arg;
      }
      switch(v){
         case 0:
            return("0");
         case 1:
            return("M1");
         case 5:
            return("M5");                  
         case 15:
            return("M15");
         case 30:
            return("M30");             
         case 60:
            return("H1");
         case 240:
            return("H4");                  
         case 1440:
            return("D1");
         case 10080:
            return("W1");          
         case 43200:
            return("MN1");
         default:
            return("M"+arg);          
      }
}

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---