cm_Transactions history

0 Views
0 Downloads
0 Favorites
cm_Transactions history
ÿþ#property copyright "Copyright © 2022, https://cmillion.ru"

#property link      "https://t.me/ea_cmillion"

string ver ="VP 1.0";

#property version "1.0"

#property strict

#property description "The script shows on the history when transactions were opened and when they were closed. As well as their profit loss and other parameters."

#property description "!:@8?B ?>:07K205 =0 8AB>@88 :>340 >B:@K20;8AL 8 :>340 70:@K20;8AL A45;:8.  B0: 65 8E ?@>D8B C1KB>: 8 ?@>G85 ?0@0<5B@K."

/*A;8 =0 M:@0=5 5ABL C65 8=D>@<0F8O > >@45@0E, B> A:@8?B 8E 2A5 AB8@05B. 0;55 70?CAB8B5 A:@8?B 5I5 @07 8 >= ?>:065B 2AN 8AB>@8N A45;>:, >B>1@078B 2A5 >B;>65==K5 >@45@0 8 ?>78F88 =0 8AB>@88. @8 =02545=88 <KH8 =0 ;8=8N >@45@0 8;8 =0 7=0G5: ?>O2;O5BAO 1>;55 ?>4@>1=0O 8=D>@<0F8O > A45;:5. @8 ?>2B>@=>< 70?CA:5 A:@8?B0 2A5 40==K5 >G8I0NBAO.*/

//+------------------------------------------------------------------+

//| script cm_Transactions history                                   |

//+------------------------------------------------------------------+

void OnStart() 

  { 

   if (ObjectsTotal()>0)

   {

      if (ObjectsDeleteAll(0, "open ")+

      ObjectsDeleteAll(0, "close ")+

      ObjectsDeleteAll(0, "delete ")+

      ObjectsDeleteAll(0, "BUY ")+

      ObjectsDeleteAll(0, "SELL ")+

      ObjectsDeleteAll(0, "Ticket ")+

      ObjectsDeleteAll(0, "info")>0) return;

   }

   string name,info,AC=AccountCurrency();

   int i;

   uchar Arrow=0;

   color Color=0;

   datetime time_open,time_close;

   double Profit,price_open,price_close;

   for(i = 0; i < HistoryTotal(); i++) 

	{ 	

	   if (!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue;

      if(OrderSymbol() != Symbol())                     continue;

      time_open = OrderOpenTime();

      time_close = OrderCloseTime();

      price_open = OrderOpenPrice();

      price_close = OrderClosePrice();

      info=StringConcatenate(IntegerToString(OrderTicket())," Lot=",DoubleToString(OrderLots(),2));

      Profit=OrderProfit()+OrderSwap()+OrderCommission();

      //----

      switch(OrderType())

      {

         case OP_BUY:       Arrow = 1; Color = Aqua; 

                            name = "BUY " + info; 

                            break;

         case OP_SELL:      Arrow = 2; Color = Red; 

                            name = "SELL " + info;

                            break;

         case OP_BUYLIMIT:  Arrow = 1; Color = Yellow; 

                            name = "BUYLIMIT " + info;

                            break;

         case OP_BUYSTOP:   Arrow = 1; Color = Yellow; 

                            name = "BUYSTOP " + info;

                            break;

         case OP_SELLLIMIT: Arrow = 2; Color = Yellow; 

                            name = "SELLLIMIT " + info;

                            break;

         case OP_SELLSTOP:  Arrow = 2; Color = Yellow; 

                            name = "SELLSTOP " + info;

                            break;

      }

      ArrowCreate(0,"open "+name,0,time_open, price_open,Arrow,ANCHOR_TOP,Color);

      name=StringConcatenate(name," Profit=",DoubleToString(Profit,2),AC);

      ArrowCreate(0,"close "+name,0,time_close, price_close,3,ANCHOR_BOTTOM,Color);

      if (Profit!=0) 

      {

         TrendCreate(0,name,0,time_open,price_open,time_close,price_close,Profit>0?clrGreen:clrRed,STYLE_SOLID);

         info = "Ticket "+IntegerToString(OrderTicket())+" Profit="+DoubleToString(OrderProfit(),2)+" Swap="+DoubleToString(OrderSwap(),2)+" Commission="+DoubleToString(OrderCommission(),2);

         for(int j = 0; j < 5; j++) TextCreate(0,"info"+IntegerToString(i)+" "+IntegerToString(j),0,time_close+Period()*60*j,price_close,CharToString(110)+(j==0?CharToString(110):""),"Wingdings",20,clrYellow);

         TextCreate(0,info,0,time_close,price_close,"     "+DoubleToString(Profit,2),"Arial",8,Profit>0?clrGreen:clrRed);

      }

   }

}

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+

bool ArrowCreate(const long              chart_ID=0,           // ID 3@0D8:0 

                 const string            name="Arrow",         // 8<O AB@5;:8 

                 const int               sub_window=0,         // =><5@ ?>4>:=0 

                 datetime                time=0,               // 2@5<O B>G:8 ?@82O7:8 

                 double                  price=0,              // F5=0 B>G:8 ?@82O7:8 

                 const uchar             arrow_code=252,       // :>4 AB@5;:8 

                 const ENUM_ARROW_ANCHOR anchor=ANCHOR_BOTTOM, // ?>;>65=85 B>G:8 ?@82O7:8 

                 const color             clr=clrRed,           // F25B AB@5;:8 

                 const ENUM_LINE_STYLE   style=STYLE_SOLID,    // AB8;L >:09<;ONI59 ;8=88 

                 const int               width=1,              // @07<5@ AB@5;:8 

                 const bool              back=false,           // =0 704=5< ?;0=5 

                 const bool              selection=false,      // 2K45;8BL 4;O ?5@5<5I5=89 

                 const bool              hidden=true,          // A:@KB 2 A?8A:5 >1J5:B>2 

                 const long              z_order=0)            // ?@8>@8B5B =0 =060B85 <KHLN 

  { 

   ResetLastError(); 

//--- A>74048< AB@5;:C 

   if(!ObjectCreate(chart_ID,name,OBJ_ARROW,sub_window,time,price)) 

     { 

      Print(__FUNCTION__, 

            ": =5 C40;>AL A>740BL AB@5;:C! >4 >H81:8 = ",GetLastError()); 

      return(false); 

     } 

//--- CAB0=>28< :>4 AB@5;:8 

   ObjectSetInteger(chart_ID,name,OBJPROP_ARROWCODE,arrow_code); 

//--- CAB0=>28< A?>A>1 ?@82O7:8 

   ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor); 

//--- CAB0=>28< F25B AB@5;:8 

   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr); 

//--- CAB0=>28< AB8;L >:09<;ONI59 ;8=88 

   ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style); 

//--- CAB0=>28< @07<5@ AB@5;:8 

   ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width); 

//--- >B>1@078< =0 ?5@54=5< (false) 8;8 704=5< (true) ?;0=5 

   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back); 

//--- 2:;NG8< (true) 8;8 >B:;NG8< (false) @568< ?5@5<5I5=8O AB@5;:8 <KHLN 

//--- ?@8 A>740=88 3@0D8G5A:>3> >1J5:B0 DC=:F859 ObjectCreate, ?> C<>;G0=8N >1J5:B 

//--- =5;L7O 2K45;8BL 8 ?5@5<5I0BL. =CB@8 65 MB>3> <5B>40 ?0@0<5B@ selection 

//--- ?> C<>;G0=8N @025= true, GB> ?>72>;O5B 2K45;OBL 8 ?5@5<5I0BL MB>B >1J5:B 

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection); 

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection); 

//--- A:@>5< (true) 8;8 >B>1@078< (false) 8<O 3@0D8G5A:>3> >1J5:B0 2 A?8A:5 >1J5:B>2 

   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden); 

//--- CAB0=>28< ?@8>@8B5B =0 ?>;CG5=85 A>1KB8O =060B8O <KH8 =0 3@0D8:5 

   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order); 

//--- CA?5H=>5 2K?>;=5=85 

   return(true); 

  } 

//+------------------------------------------------------------------+

bool TrendCreate(const long            chart_ID=0,        // ID 3@0D8:0 

                 const string          name="TrendLine",  // 8<O ;8=88 

                 const int             sub_window=0,      // =><5@ ?>4>:=0 

                 datetime              time1=0,           // 2@5<O ?5@2>9 B>G:8 

                 double                price1=0,          // F5=0 ?5@2>9 B>G:8 

                 datetime              time2=0,           // 2@5<O 2B>@>9 B>G:8 

                 double                price2=0,          // F5=0 2B>@>9 B>G:8 

                 const color           clr=clrRed,        // F25B ;8=88 

                 const ENUM_LINE_STYLE style=STYLE_SOLID, // AB8;L ;8=88 

                 const int             width=1,           // B>;I8=0 ;8=88 

                 const bool            back=false,        // =0 704=5< ?;0=5 

                 const bool            selection=false,    // 2K45;8BL 4;O ?5@5<5I5=89 

                 const bool            ray_right=false,   // ?@>4>;65=85 ;8=88 2?@02> 

                 const bool            hidden=true,       // A:@KB 2 A?8A:5 >1J5:B>2 

                 const long            z_order=0)         // ?@8>@8B5B =0 =060B85 <KHLN 

  { 

//--- A1@>A8< 7=0G5=85 >H81:8 

   ResetLastError(); 

//--- A>74048< B@5=4>2CN ;8=8N ?> 7040==K< :>>@48=0B0< 

   if(!ObjectCreate(chart_ID,name,OBJ_TREND,sub_window,time1,price1,time2,price2)) 

     { 

      Print(__FUNCTION__, 

            ": =5 C40;>AL A>740BL ;8=8N B@5=40! >4 >H81:8 = ",GetLastError()); 

      return(false); 

     } 

//--- CAB0=>28< F25B ;8=88 

   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr); 

//--- CAB0=>28< AB8;L >B>1@065=8O ;8=88 

   ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style); 

//--- CAB0=>28< B>;I8=C ;8=88 

   ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width); 

//--- >B>1@078< =0 ?5@54=5< (false) 8;8 704=5< (true) ?;0=5 

   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back); 

//--- 2:;NG8< (true) 8;8 >B:;NG8< (false) @568< ?5@5<5I5=8O ;8=88 <KHLN 

//--- ?@8 A>740=88 3@0D8G5A:>3> >1J5:B0 DC=:F859 ObjectCreate, ?> C<>;G0=8N >1J5:B 

//--- =5;L7O 2K45;8BL 8 ?5@5<5I0BL. =CB@8 65 MB>3> <5B>40 ?0@0<5B@ selection 

//--- ?> C<>;G0=8N @025= true, GB> ?>72>;O5B 2K45;OBL 8 ?5@5<5I0BL MB>B >1J5:B 

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection); 

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection); 

//--- 2:;NG8< (true) 8;8 >B:;NG8< (false) @568< ?@>4>;65=8O >B>1@065=8O ;8=88 2?@02> 

   ObjectSetInteger(chart_ID,name,OBJPROP_RAY_RIGHT,ray_right); 

//--- A:@>5< (true) 8;8 >B>1@078< (false) 8<O 3@0D8G5A:>3> >1J5:B0 2 A?8A:5 >1J5:B>2 

   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden); 

//--- CAB0=>28< ?@8>@8B5B =0 ?>;CG5=85 A>1KB8O =060B8O <KH8 =0 3@0D8:5 

   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order); 

//--- CA?5H=>5 2K?>;=5=85 

   return(true); 

  } 

//+------------------------------------------------------------------+ 

bool TextCreate(const long              chart_ID=0,               // ID 3@0D8:0 

                const string            name="Text",              // 8<O >1J5:B0 

                const int               sub_window=0,             // =><5@ ?>4>:=0 

                datetime                time=0,                   // 2@5<O B>G:8 ?@82O7:8 

                double                  price=0,                  // F5=0 B>G:8 ?@82O7:8 

                const string            text="Text",              // A0< B5:AB 

                const string            font="Arial",             // H@8DB 

                const int               font_size=10,             // @07<5@ H@8DB0 

                const color             clr=clrRed,               // F25B 

                const double            angle=0.0,                // =0:;>= B5:AB0 

                const ENUM_ANCHOR_POINT anchor=ANCHOR_LEFT,       // A?>A>1 ?@82O7:8 

                const bool              back=false,               // =0 704=5< ?;0=5 

                const bool              selection=false,          // 2K45;8BL 4;O ?5@5<5I5=89 

                const bool              hidden=true,              // A:@KB 2 A?8A:5 >1J5:B>2 

                const long              z_order=0)                // ?@8>@8B5B =0 =060B85 <KHLN 

  { 

   ResetLastError(); 

//--- A>74048< >1J5:B ""5:AB" 

   if(!ObjectCreate(chart_ID,name,OBJ_TEXT,sub_window,time,price)) 

     { 

      Print(__FUNCTION__, 

            ": =5 C40;>AL A>740BL >1J5:B \""5:AB\"! >4 >H81:8 = ",GetLastError()); 

      return(false); 

     } 

//--- CAB0=>28< B5:AB 

   ObjectSetString(chart_ID,name,OBJPROP_TEXT,text); 

//--- CAB0=>28< H@8DB B5:AB0 

   ObjectSetString(chart_ID,name,OBJPROP_FONT,font); 

//--- CAB0=>28< @07<5@ H@8DB0 

   ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size); 

//--- CAB0=>28< C3>; =0:;>=0 B5:AB0 

   ObjectSetDouble(chart_ID,name,OBJPROP_ANGLE,angle); 

//--- CAB0=>28< A?>A>1 ?@82O7:8 

   ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor); 

//--- CAB0=>28< F25B 

   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr); 

//--- >B>1@078< =0 ?5@54=5< (false) 8;8 704=5< (true) ?;0=5 

   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back); 

//--- 2:;NG8< (true) 8;8 >B:;NG8< (false) @568< ?5@5<5I5=8O >1J5:B0 <KHLN 

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection); 

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection); 

//--- A:@>5< (true) 8;8 >B>1@078< (false) 8<O 3@0D8G5A:>3> >1J5:B0 2 A?8A:5 >1J5:B>2 

   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden); 

//--- CAB0=>28< ?@8>@8B5B =0 ?>;CG5=85 A>1KB8O =060B8O <KH8 =0 3@0D8:5 

   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order); 

//--- CA?5H=>5 2K?>;=5=85 

   return(true); 

  } 

//+------------------------------------------------------------------+ 



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 ---