Schtirlitz_856

Download script
Author: Rosh
Schtirlitz_856

This script is designed as a visual auditing tool for traders who want to see a clear history of their past trades directly on their trading chart. Instead of manually scrolling through a list of numbers in a history tab, this tool "draws" the life cycle of every trade onto the price candles.

Here is a breakdown of how the logic works:

Visual Trade Mapping

When you run the script, it scans your account's trading history specifically for the currency pair you are currently viewing. For every completed trade it finds, it performs the following visual actions:

  • Entry Markers: It places an arrow at the exact price and time where a trade was opened. Blue arrows typically indicate "Buy" positions, while Red arrows indicate "Sell" positions.
  • Exit Markers: It places a specific white arrow at the exact price and time where the trade was closed.
  • Path Tracking (Tracing): One of the core features is the ability to see the "path" of a trade. If a trade remained open for an extended period, the script can draw a trail of labels along the price action between the entry and the exit. This helps you visualize how long a position was held relative to market movement.
  • Profit/Loss Identification: The script automatically checks the final result of each closed trade. It will display a label at the closing point that changes color based on the outcome: one color for profitable trades (success) and another for losing trades (failure). It also includes the specific profit amount in these labels for quick reference.

Smart Filtering

The logic includes two layers of filtering to ensure the chart doesn't get cluttered with irrelevant data:

  1. Symbol Filtering: The tool only draws information for the specific currency or asset you are currently looking at. If you switch charts, the visual history will update accordingly.
  2. Magic Number Matching: It is designed to work with automated trading systems. You can set a specific "Magic Number" (a unique ID used by EAs); if set, the script will only show trades from that specific robot. If left at zero, it shows all manual and automated trades for that symbol.

Summary of User Experience

For a trader, this means that instead of looking at a spreadsheet of historical data, you can simply look at your chart and see a visual "map" of your performance. You can quickly see where you got into trades, how long they lasted, the path the price took while you were in the position, and whether each specific trade resulted in a win or a loss, all labeled clearly with colors and numbers.

Miscellaneous
It issuies visual alerts to the screen
12 Views
0 Downloads
0 Favorites
Schtirlitz_856
//+------------------------------------------------------------------+
//|                                                   Schtirlitz.mq4 |
//|                                                             Rosh |
//|                                    http://forexsystems.ru/phpBB/ |
//+------------------------------------------------------------------+
#property copyright "Rosh"
#property link      "http://forexsystems.ru/phpBB/"
#property show_inputs

extern int  scht_ExpertMagicNumber=856;
extern bool scht_ShowProfitLabels=true;
extern bool scht_ShowTrace=true;

int scht_UpOpenArrow=1;
int scht_DownOpenArrow=2;
int scht_CloseArrow=3;
color scht_UpOpenColor=Blue;
color jd_DownOpenColor=Red;
color scht_CloseColor=White;
color scht_ProfitClose=Lime;
color scht_LossClose=DeepPink;
color scht_lastCloseColor;
int scht_TraceLabel=159;
int scht_CloseLabel=108;
int scht_traceCounter;
int scht_closeLabelShift=30;
//+------------------------------------------------------------------+
//| ïîñòàâèì ñòðåëêó                                                 |
//+------------------------------------------------------------------+
void SetArrow(datetime _time,double _price,string _Description ,int _arrowType, color _arrowColor)
   {
   bool res;
   ObjectCreate(_Description,OBJ_ARROW,0,_time,_price);
   ObjectSet(_Description,OBJPROP_ARROWCODE,_arrowType);
   ObjectSet(_Description,OBJPROP_COLOR,_arrowColor);
//   res=ObjectSetText(_Description,"Ïðîáà", 10, "Times New Roman", Green);
//   if (!res) Print(GetLastError());
   }

//+------------------------------------------------------------------+
//| ïðîòðåéñèì îðäåð                                                 |
//+------------------------------------------------------------------+
void scht_TraceOrder(int _orderTicket)
   {
   double priceCloseLabel;
   string scht_openDescription;
   string scht_closeDescription;
   int scht_open_ArrowType;
   int scht_orderType=OrderType();
   color scht_orderColor;
   if (scht_orderType==OP_BUY ||scht_orderType==OP_SELL)
      {
      double scht_openPrice=OrderOpenPrice();
      double scht_closePrice=OrderClosePrice();
      if (scht_orderType==OP_BUY) scht_open_ArrowType=scht_UpOpenArrow; else scht_open_ArrowType=scht_DownOpenArrow;
      if (scht_orderType==OP_BUY) scht_orderColor=scht_UpOpenColor; else scht_orderColor=jd_DownOpenColor;
      datetime scht_timeClose=OrderCloseTime();
      datetime scht_timeOpen=OrderOpenTime();
      if (scht_orderType==OP_BUY) 
         {
         scht_openDescription="buy #"+_orderTicket;
         }
      else 
         {
         scht_openDescription="sell #"+_orderTicket;
         }
      scht_closeDescription="close "+scht_openDescription;
      SetArrow(scht_timeOpen,scht_openPrice,scht_openDescription,scht_open_ArrowType,scht_orderColor); // ñòðåëêà îòêðûòèÿ
      SetArrow(scht_timeClose,scht_closePrice,scht_closeDescription,scht_CloseArrow,scht_CloseColor); // ñòðåëêà çàêðûòèÿ
      if (scht_ShowTrace)
         {
         int scht_openShift=0;
         int scht_closeShift=0;
         while (Time[scht_openShift]>scht_timeOpen) scht_openShift++;
         //scht_openShift--;
         while (Time[scht_closeShift]>scht_timeClose) scht_closeShift++;
         //scht_closeShift--;
         if (scht_openShift-scht_closeShift>1)
            {
            for (int tr_shift=scht_openShift-1; tr_shift>scht_closeShift;tr_shift--) 
               {
               SetArrow(Time[tr_shift],scht_openPrice,scht_openDescription+" "+scht_traceCounter,scht_TraceLabel,scht_orderColor);
               scht_traceCounter++;
               }
            }
         if (scht_ShowProfitLabels)
            {
            if (OrderProfit()>0) scht_lastCloseColor=scht_ProfitClose; else scht_lastCloseColor=scht_LossClose;
            if (scht_orderType==OP_BUY) priceCloseLabel=High[scht_closeShift]+scht_closeLabelShift*Point ; else priceCloseLabel=Low[scht_closeShift]-scht_closeLabelShift*Point;
            SetArrow(Time[scht_closeShift],priceCloseLabel,scht_openDescription+" "+DoubleToStr(OrderProfit(),2),scht_CloseLabel,scht_lastCloseColor);
            }
         }
      }
   }
//+------------------------------------------------------------------+
//| ïîäñ÷èòàåì êîëè÷åñòâî ñäåëîê ïî ñèìâîëó/èíñòðóìåíòó              |
//+------------------------------------------------------------------+
int scht_SymbolTrades()
  {
   int scht_tradesOnSymbol=0;
   int scht_allTrades=HistoryTotal();
   int cnt;
   for (cnt=0;cnt<HistoryTotal();cnt++)
      {
      if(OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY)==false)
         {
         Print("Îøèáêà ïðè äîñòóïå ê èñòîðè÷åñêîé áàçå (",GetLastError(),")");
         break;
         }
      if ((OrderSymbol()==Symbol())&&(OrderType()==OP_BUY||OrderType()==OP_SELL)) scht_tradesOnSymbol++;
      } 
   return(scht_tradesOnSymbol);
  }
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//---- 
   if (scht_SymbolTrades()==0)   Alert("Ïî ñèìâîëó ",Symbol()," ñäåëîê íå íàéäåíî");
   else
      {
      for (int cnt=0;cnt<HistoryTotal();cnt++)
         {
         if(OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY)==false)
            {
            Print("Îøèáêà ïðè äîñòóïå ê èñòîðè÷åñêîé áàçå (",GetLastError(),")");
            break;
            }
         if ((OrderSymbol()==Symbol())&&((OrderMagicNumber()==0)||((OrderMagicNumber()!=0)&&(OrderMagicNumber()==scht_ExpertMagicNumber))))  
            {
            Print("Ticket=",OrderTicket());
            scht_TraceOrder(OrderTicket());
            }
         }
      Comment("Äàííûå ïîëó÷åíû óòèëèòîé Øòèðëèö :) ");   
      }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments