displayPostion

Download script
Author: Copyright � 2007okw,China.
displayPostion

This script is designed to enhance the visual clarity of your trading history by automatically plotting past trades directly onto your price chart. Instead of having to manually search through lists of numbers and dates, this tool provides a clear, visual "map" of where your previous transactions occurred and how they performed.

How it Works

When you run this script, it performs a comprehensive scan of your historical trading data. It looks back at every completed transaction in your account history to identify both "Buy" and "Sell" orders.

The logic follows a structured three-step process:

1. Data Retrieval The script systematically goes through your history, identifying the specific details of each closed trade, including:

  • The exact time the trade was opened and closed.
  • The entry price (where you got into the market).
  • The exit price (where you closed the position).

2. Trade Identification It categorizes these trades based on their type. If it finds a "Buy" order, it flags it for one style of visual display; if it finds a "Sell" order, it prepares a different visual layout.

3. Visual Mapping Once the data is collected, the script draws three specific elements on your chart for every completed trade to make your history easy to read at a glance:

  • Entry Markers: It places a distinct arrow icon at the exact moment and price where the trade began.
  • Trade Paths: It draws a dotted trend line connecting your entry point to your exit point, allowing you to see the duration and "path" of the trade.
  • Exit Markers: It places a final marker at the closing price to clearly indicate where the trade ended.

Visual Distinction

To keep your chart organized, the script uses color-coding to differentiate between market actions:

  • Buy Trades: These are highlighted using specific colors (Red/Tan) to separate them from sell positions.
  • Sell Trades: These are highlighted using different colors (Lime/Green) to ensure they stand out clearly.

By translating raw history into these visual markers, the script allows traders to quickly review their past performance, recognize patterns in their entries and exits, and better visualize their trading journey on the actual price action of the market.

7 Views
0 Downloads
0 Favorites
displayPostion
//+------------------------------------------------------------------+
//|                                               displayPostion.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007okw,China."

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int SignalBS =0;
datetime startTime=NULL, endTime = NULL;
color    SignalPriceBUY = Red;//Yellow;
color    SignalPriceSELL = Lime;//Cyan;
double startPrice, endprice;
int start()
  {
 int    orders=HistoryTotal(); Print("Ord=",orders);
 int i;
 for(i=orders-1;i>=0;i--)
 { 
    if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true)  
    {
      if (OrderType( )==OP_BUY) 
        {
         SignalBS =1;      
         startTime= OrderOpenTime();endTime = OrderCloseTime ();
         startPrice= OrderOpenPrice(); endprice = OrderClosePrice ();
          SetBS();
        }
        else if (OrderType( )==OP_SELL) 
        {
          SignalBS =-1;     
          startTime= OrderOpenTime();endTime = OrderCloseTime ();
          startPrice= OrderOpenPrice(); endprice = OrderClosePrice ();
          SetBS();
       }
    }
 }  
//----
   return(0);
  }
//+------------------------------------------------------------------+


void SetBS()
{
if (SignalBS == 1)
   {
   ObjectDelete("BUY SIGNAL: " + TimeToStr(startTime));
   ObjectDelete("BUY : " + TimeToStr(endTime));
   ObjectDelete("BUY Close: " + TimeToStr(endTime));
   ObjectCreate("BUY SIGNAL: " + TimeToStr(startTime),OBJ_ARROW,0,startTime,startPrice);
   ObjectSet("BUY SIGNAL: " + TimeToStr(startTime),OBJPROP_ARROWCODE,5);
   ObjectSet("BUY SIGNAL: " + TimeToStr(startTime),OBJPROP_COLOR,SignalPriceBUY);
   ObjectCreate("BUY : " + TimeToStr(endTime),OBJ_TREND,0,startTime,startPrice,endTime,endprice);
   ObjectSet("BUY : " + TimeToStr(endTime),OBJPROP_COLOR,SignalPriceBUY);
   ObjectSet("BUY : " + TimeToStr(endTime),OBJPROP_RAY,false);
   ObjectSet("BUY : " + TimeToStr(endTime),OBJPROP_STYLE,STYLE_DOT);
   ObjectCreate("BUY Close: " + TimeToStr(endTime),OBJ_ARROW,0,endTime,endprice);
   ObjectSet("BUY Close: " + TimeToStr(endTime),OBJPROP_ARROWCODE,5);
   ObjectSet("BUY Close: " + TimeToStr(endTime),OBJPROP_COLOR,Tan);
   }
if (SignalBS == -1)
   {
   ObjectDelete("SELL SIGNAL: " + TimeToStr(startTime));
   ObjectDelete("SELL : " + TimeToStr(endTime));
   ObjectDelete("SELL Close: " + TimeToStr(endTime));   ObjectCreate("SELL SIGNAL: " + TimeToStr(startTime),OBJ_ARROW,0,startTime,startPrice);
   ObjectSet("SELL SIGNAL: " + TimeToStr(startTime),OBJPROP_ARROWCODE,5);
   ObjectSet("SELL SIGNAL: " + TimeToStr(startTime),OBJPROP_COLOR,SignalPriceSELL);
   ObjectCreate("SELL : " + TimeToStr(endTime),OBJ_TREND,0,startTime,startPrice,endTime,endprice);
   ObjectSet("SELL : " + TimeToStr(endTime),OBJPROP_COLOR,SignalPriceSELL);
   ObjectSet("SELL : " + TimeToStr(endTime),OBJPROP_RAY,false);
   ObjectSet("SELL : " + TimeToStr(endTime),OBJPROP_STYLE,STYLE_DOT);
   ObjectCreate("SELL Close: " + TimeToStr(endTime),OBJ_ARROW,0,endTime,endprice);
   ObjectSet("SELL Close: " + TimeToStr(endTime),OBJPROP_ARROWCODE,5);
   ObjectSet("SELL Close: " + TimeToStr(endTime),OBJPROP_COLOR,Green);
   }
}

Comments