Visible_Pos

Author: Valmars
Visible_Pos

This script is designed to enhance your trading visual experience by automatically plotting markers on your price chart to represent your trading history and current activity. Instead of manually tracking where you entered or exited a trade, this tool identifies those points for you and places clear visual indicators directly on the screen.

Core Functionality

The script scans through your trading account to identify all relevant transactions associated with the specific currency pair or asset you are currently viewing. It then performs the following actions:

  • Active Trade Visualization: For any open positions or pending orders (such as Buy Limits or Sell Stops), the script places an arrow at the exact price and time where the trade was opened.
  • Historical Trade Visualization: For trades that have already been completed, the script identifies two distinct points:
    1. The Entry Point: Where the trade originally began.
    2. The Exit Point: Where the trade was closed or canceled.

Visual Coding & Organization

To make the data easy to read at a glance, the script uses a color-coded system and specific symbols based on the type of trade performed:

  • Buy Orders: These are marked with an "Aqua" colored arrow.
  • Sell Orders: These are marked with a "Red" colored arrow.
  • Pending Orders (Limits/Stops): These are highlighted in "Yellow" to distinguish them from active market positions.
  • Exit Markers: When a trade is closed, the script places a second marker (using a different arrow style) at the closing price to clearly show where your profit or loss was realized.

Summary of Benefits

By using this tool, you eliminate the need to manually cross-reference your history logs with your charts. It provides an immediate, visual "map" of your trading behavior, allowing you to see exactly where your entries and exits occurred in relation to price action, making it much easier to analyze your trading strategy over time.

Orders Execution
Checks for the total of open orders
15 Views
0 Downloads
0 Favorites
Visible_Pos
//+------------------------------------------------------------------+
//|                                             Visible_Pos.mq4      |
//|                                             Valmars              |
//|                                             valmars@bk.ru        |
//+------------------------------------------------------------------+
#property copyright "Valmars"
#property link      "valmars@bk.ru"
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start() 
  { 
   ObjectsDeleteAll(0, OBJ_ARROW); // Óäàëåíèå âñåõ ñòðåëîê ñ ãðàôèêà
   string name;                    // Èìÿ îáúåêòà-ñòðåëêè
   int Arrow;                      // Êîä ñòðåëêè
   double Color;                   // Öâåò ñòðåëêè
//  Ïðîâåðêà äëÿ âñåõ îòêðûòûõ è îòëîæåííûõ îðäåðîâ
   for(int i = 0; i < OrdersTotal(); i++)  
	    { 	
	      OrderSelect(i, SELECT_BY_POS);
       // Ñèìâîëû îðäåðà è ãðàôèêà íå ñîâïàäàþò
	      if(OrderSymbol()!=Symbol()) 
		         continue;               // Ñëåäóþùèé îðäåð
       // Ñèìâîëû îðäåðà è ãðàôèêà ñîâïàäàþò
       else
         {
           // Âðåìÿ îòêðûòèÿ, âðåìÿ çàêðûòèÿ îðäåðà
           datetime tm_open = OrderOpenTime();
           datetime tm_close = OrderCloseTime();
           double pr_open = OrderOpenPrice(); 
           // Öåíà îòêðûòèÿ, öåíà çàêðûòèÿ îðäåðà
           double pr_close = OrderClosePrice(); 
           //----
           switch(OrderType()) // Ïàðàìåòðû ñòðåëîê
             {
               case OP_BUY:       Arrow = 1; Color = Aqua; 
                                  name = "OP_BUY_" + OrderTicket(); 
                                  break;         
               case OP_SELL:      Arrow = 2; Color = Red; 
                                  name = "OP_SELL_" + OrderTicket(); 
                                  break;
               case OP_BUYLIMIT:  Arrow = 1; Color = Yellow; 
                                  name = "OP_BUYLIMIT_" + OrderTicket(); 
                                  break;
               case OP_BUYSTOP:   Arrow = 1; Color = Yellow; 
                                  name = "OP_BUYSTOP_" + OrderTicket(); 
                                  break;
               case OP_SELLLIMIT: Arrow = 2; Color = Yellow; 
                                  name = "OP_SELLLIMIT_" + OrderTicket();
                                  break;
               case OP_SELLSTOP:  Arrow = 2; Color = Yellow; 
                                  name = "OP_SELLSTOP_" + OrderTicket();
                                  break;
             }
           // Ñòðåëêà îòêðûòèÿ îðäåðà
           ObjectCreate(name, OBJ_ARROW, 0, tm_open, pr_open);      
           ObjectSet(name, OBJPROP_ARROWCODE, Arrow); 
           ObjectSet(name, OBJPROP_COLOR, Color);
         }
     }
//  Ïðîâåðêà äëÿ âñåõ çàêðûòûõ è óäàë¸ííûõ îðäåðîâ  
   for(i = 0; i < HistoryTotal(); i++) 
	    { 	
	      OrderSelect(i, SELECT_BY_POS, MODE_HISTORY);
       // Ñèìâîëû îðäåðà è ãðàôèêà íå ñîâïàäàþò
	      if(OrderSymbol() != Symbol())     
		         continue;           // Ñëåäóþùèé îðäåð
       else                    // Ñèìâîëû îðäåðà è ãðàôèêà ñîâïàäàþò
         {
           tm_open = OrderOpenTime();
           tm_close = OrderCloseTime();
           pr_open = OrderOpenPrice();
           pr_close = OrderClosePrice();
           //----
           switch(OrderType())
             {
               case OP_BUY:       Arrow = 1; Color = Aqua; 
                                  name = "OP_BUY_" + OrderTicket(); 
                                  break;
               case OP_SELL:      Arrow = 2; Color = Red; 
                                  name = "OP_SELL_" + OrderTicket();
                                  break;
               case OP_BUYLIMIT:  Arrow = 1; Color = Yellow; 
                                  name = "OP_BUYLIMIT_" + OrderTicket();
                                  break;
               case OP_BUYSTOP:   Arrow = 1; Color = Yellow; 
                                  name = "OP_BUYSTOP_" + OrderTicket();
                                  break;
               case OP_SELLLIMIT: Arrow = 2; Color = Yellow; 
                                  name = "OP_SELLLIMIT_" + OrderTicket();
                                  break;
               case OP_SELLSTOP:  Arrow = 2; Color = Yellow; 
                                  name = "OP_SELLSTOP_" + OrderTicket();
                                  break;
             }
           // Ñòðåëêà îòêðûòèÿ îðäåðà
           ObjectCreate(name, OBJ_ARROW, 0, tm_open,pr_open);   
           ObjectSet(name, OBJPROP_ARROWCODE, Arrow); 
           ObjectSet(name, OBJPROP_COLOR, Color);
           switch(OrderType())
             {
               case OP_BUY:       Color = Aqua; 
                                  name = "CL_BUY_" + OrderTicket(); 
                                  break;
               case OP_SELL:      Color = Red; 
                                  name = "CL_SELL_" + OrderTicket();
                                  break;
               case OP_BUYLIMIT:  Color = Yellow; 
                                  name = "DEL_BUYLIMIT_" + OrderTicket(); 
                                  break;
               case OP_BUYSTOP:   Color = Yellow; 
                                  name = "DEL_BUYSTOP_" + OrderTicket(); 
                                  break;
               case OP_SELLLIMIT: Color = Yellow; 
                                  name = "DEL_SELLLIMIT_" + OrderTicket(); 
                                  break;
               case OP_SELLSTOP:  Color = Yellow; 
                                  name = "DEL_SELLSTOP_" + OrderTicket(); 
                                  break;
             }
           // Ñòðåëêà çàêðûòèÿ îðäåðà
           ObjectCreate(name, OBJ_ARROW, 0, tm_close, pr_close);    
           ObjectSet(name, OBJPROP_ARROWCODE, 3); 
           ObjectSet(name, OBJPROP_COLOR, Color);
         }
     }
   return(0);
  }
//+------------------------------------------------------------------+

Comments