Schtirlitz_854

Download script
Author: Rosh
Schtirlitz_854

This script is a visual analysis tool designed to automatically map out and "trace" the history of your trading activity on a specific currency pair or financial instrument. Instead of making live trading decisions, it acts as a retrospective auditing tool that paints a clear visual narrative of past trades directly onto your chart.

Core Functionality

The primary purpose of this script is to convert historical trade data into a visual timeline. When you run it, the program scans through your account history and identifies every completed "Buy" or "Sell" transaction for the current symbol.

It then performs several key actions:

  • Visual Marking: The script places distinct arrows on your chart to pinpoint exactly where a trade was opened and where it was eventually closed. It uses different colors (typically Blue for Buys and Red for Sells) to make the distinction immediately clear.
  • Trade Tracing: One of the most unique features is the "Trace" logic. If a trade remained open for an extended period, the script draws a continuous path of markers between the opening and closing points. This allows you to visually see the "journey" of the price while your position was active.
  • Profit/Loss Identification: To give you an at-a-glance summary of performance, the script marks the final closing point of each trade with a specific label. It dynamically changes the color of this label based on the outcome: it will appear in Lime for profitable trades and DeepPink for losing trades.
  • Automated Data Retrieval: The script automatically filters your history to ensure it only displays data relevant to the current chart you are viewing. It specifically looks for orders that match either a general trading profile or a specific "Magic Number" (a unique identifier used by automated systems).

User Experience Highlights

  • Visual Feedback: For every trade processed, the script generates labels that include the ticket number and the exact profit/loss amount in currency.
  • Ease of Review: By transforming raw numbers from a history tab into visual arrows and paths on the chart, it helps traders identify patterns, such as how long they tend to hold positions or at what price levels their trades typically fail or succeed.
  • Status Notifications: If the script is run on a symbol where no trading history exists, it will provide an alert to notify you, ensuring you know whether the data has been successfully mapped.

In summary, this tool serves as a "visual diary" for your trading history, turning static logs into a dynamic map of your past market behavior.

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

extern int  scht_ExpertMagicNumber=854;
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