qShowTrades_v1

Download script
Author: Copyright � 2011, Thomas Quester

This script is designed to provide a visual historical summary of your trading activity directly on your MetaTrader 4 chart. Instead of forcing you to manually scroll through lists or history tabs, it automatically maps out your past completed trades as physical lines on the graph.

How it Works

The tool functions by constantly monitoring your account's order history. Every time a new trade is closed or a change is detected in your history, the script triggers an automated "drawing" process:

  • Filtering for Relevance: The script scans through your history to identify trades that match the specific currency pair you are currently viewing on your screen. This ensures your chart remains clean and only displays information relevant to the asset you are analyzing.
  • Visual Mapping: For every relevant completed trade, the script creates a trend line connecting the entry point (where you opened the trade) to the exit point (where you closed it). This allows you to see at a glance how much "room" was left in a move or where a specific price action occurred.
  • Profit and Loss Identification: To make the data easy to read instantly, the script applies color-coding based on the outcome of the trade:
    • Green Lines: Represent profitable trades.
    • Red Lines: Represent losing trades.
  • Trade Details: Each line is labeled with specific information, including the type of order (e.g., Buy, Sell, Buy Stop, or Sell Stop) and the price at which it was opened. It also adjusts the visual style—such as using dashed lines for Sell orders—to help differentiate between different types of market entries.
  • Automatic Cleanup: To keep your platform running smoothly, the script is programmed to clear out old visual data every time a new update occurs, ensuring that the lines you see are always current and not cluttered by outdated information.

In essence, this tool turns your trading history into a visual map, allowing you to see the "footprints" of your past successes and mistakes directly on the price action.

Orders Execution
Checks for the total of closed orders
9 Views
0 Downloads
0 Favorites
qShowTrades_v1
//+------------------------------------------------------------------+
//|                                                   ShowTrades.mq4 |
//|                                 Copyright © 2011, Thomas Quester |
//|                                                 www.mt4expert.de |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, Thomas Quester"
#property link      "www.mt4expert.de"
#property indicator_chart_window

bool   gTimeDemo=false;
int    gDemoDate=1;
int    gDemoMonth=1;
int    gDemoYear=2018;
int    gOldCnt=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   gOldCnt=0;
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----
   int cnt;
   int i,typ;
   /*if(gTimeDemo)
     {
      int t,m,y;
      t = TimeDay(Time[0]);
      m = TimeMonth(Time[0]);
      y = TimeYear(Time[0]);
      if(y>=gDemoYear && 
         m >= gDemoMonth &&
         t >= gDemoDate)
         return(0);
     }*/

   cnt=OrdersHistoryTotal();
   if(cnt!=gOldCnt)
     {
      gOldCnt=cnt;
      Print("ShowTraces start");

      string name;
      datetime ostart,oend;
      double   open,close;

      Print("cnt = "+cnt);
      for(i=0;i<15000;i++)
        {

         ObjectDelete("trades_"+i);
        }

      for(i=0;i<cnt;i++)
        {
         Print("Order 1 = "+OrderSymbol());
         if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) break;
         if(OrderSymbol()==Symbol())
           {
            typ=OrderType();
            if(typ==OP_BUY || typ==OP_SELL)
              {
               ostart = OrderOpenTime();
               oend   = OrderCloseTime();
               open   = OrderOpenPrice();
               close  = OrderClosePrice();
               Print("o=",ostart," ",open," ",oend," ",close);
               ObjectCreate("trades_"+i,OBJ_TREND,0,ostart,open,oend,close);
               ObjectSet("trades_"+i,OBJPROP_RAY,false);
               if(OrderProfit()>0)
                  ObjectSet("trades_"+i,OBJPROP_COLOR,Green);
               else
                  ObjectSet("trades_"+i,OBJPROP_COLOR,Red);

               name="";

               switch(typ)
                 {
                  case OP_BUY: name="buy"; break;
                  case OP_SELL: name="sell"; break;
                  case OP_BUYSTOP: name="buystop"; break;
                  case OP_SELLSTOP: name="sellstop"; break;
                 }
               name=name+" "+open;
               ObjectSetText("trades_"+i,name,10,"Times New Roman",Green);
               if(typ==OP_SELL)
                  ObjectSet("trades_"+i,OBJPROP_STYLE,STYLE_DASH);
               ObjectSet("trades_"+i,OBJPROP_WIDTH,2);
              }
           }
        }
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments