CurrentInfo

Download script
Author: Andrei Andreev
CurrentInfo

This script is designed to serve as a comprehensive analytical dashboard for traders, providing real-time market data and account performance metrics directly on the trading chart. Instead of executing trades automatically, it acts as an informational tool that summarizes both current market volatility and the overall health of your open positions.

The logic can be broken down into two primary categories:

Market Volatility Analysis

The script monitors price movements to help traders understand the "personality" of the current market. It specifically calculates:

  • Daily Ranges: It identifies the highest and lowest price points reached during the current day and compares them to the previous day's movement.
  • Historical Averages: Based on a user-defined timeframe (defaulting to 10 days), the script calculates the average price range. This allows traders to see if the market is currently moving more or less than it usually does, which is vital for setting realistic take-profit and stop-loss targets.
  • Technical Constants: It retrieves standard market information, such as "pips" and other fundamental values, to ensure the data displayed is accurate to the specific currency pair or asset being viewed.

Account & Performance Monitoring

Simultaneously, the script scans all currently active trades in your account to provide a live summary of your portfolio performance. It automatically calculates:

  • Profit/Loss Distribution: It counts how many of your open trades are currently in profit versus how many are in a loss.
  • Financial Totals: It aggregates the total monetary amount gained from winning trades and the total amount lost on losing trades, including adjustments for swaps (overnight fees).
  • Stop-Loss Impact: It features a specific calculation to estimate potential profit or loss based on your current "Stop Loss" orders, helping you visualize your risk exposure.
  • Pending Orders: It identifies and counts all "pending" orders (orders waiting to be triggered) so you can keep track of your total market exposure at a glance.

User Experience

All of this information is consolidated into a clean, text-based overlay on the trading screen. This allows a trader to see their active performance and the market's volatility trends in one place without having to navigate through multiple menus or windows, facilitating faster decision-making during live trading sessions.

Price Data Components
Series array that contains close prices for each bar
Orders Execution
Checks for the total of open orders
Indicators Used
Indicator of the average true range
10 Views
0 Downloads
0 Favorites
CurrentInfo
//+------------------------------------------------------------------+
//|                                                Donchian.mq4 |
//|                                                   Andrei Andreev |
//|                                             http://www.andand.ru |
//+------------------------------------------------------------------+

// BASED ON:
//+------------------------------------------------------------------+
//|                                                   ^X_Sensors.mq4 |
//|                                                    Version 2.0.1 |
//|------------------------------------------------------------------|
//|                     Copyright © 2007, Mr.WT, Senior Linux Hacker |
//|                                     http://w-tiger.narod.ru/wk2/ |
//+------------------------------------------------------------------+
#property copyright "Andrei Andreev"
#property link      "http://www.andand.ru"

#property indicator_chart_window

extern int ForDays=10;



int _N_Time, ObjectId;
string OBJECT_PREFIX = "LEVELS";
int _My_Period=PERIOD_D1;
//-------------------------------------------------------------------------------------------
int init() {
_N_Time = 0;
return(0);
}
//-------------------------------------------------------------------------------------------
int deinit() {
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {

//if ( _N_Time == Time[0] ) return(0);

double _rates[][6];

double open,close, high, low;
double AverageRange;

ArrayCopyRates(_rates, NULL, _My_Period);
int err = GetLastError();
if(err == 4066) 
  {
  Sleep(1000);
  if(iClose(NULL, _My_Period, 0) != Close[0]) 
    {
     Sleep(1000);
     return(0);
     }
  }
close = _rates[1][4];
high = _rates[0][3];
low = _rates[0][2];
open = _rates[0][1];

AverageRange=0;
for (int i=1;i<ForDays+1;i++)
    {
    AverageRange=AverageRange+(_rates[i][3]-_rates[i][2])/Point;
    }
AverageRange=NormalizeDouble(AverageRange/ForDays,0); 

double Risk=0.05;
double N=NormalizeDouble(iATR(Symbol(),0,96,1)/Point,0);
double pips=MarketInfo(Symbol(),MODE_TICKVALUE);
double NUS=NormalizeDouble(N*pips,0);

Comment( "\nÏðèáûëüíûõ ñäåëîê  : ",TotalProfitableDeals()," íà ",ProfitableDealsAmount()," òóãðèêîâ",
         "\nÓáûòî÷íûõ ñäåëîê    : ",TotalLoosingDeals()," íà ",-LoosingDealsAmount()," òóãðèêîâ",
         "\nÏðèáûëü ïî ñòîïàì  : ", NormalizeDouble(TotalProfitByStops(),0)," òóãðèêîâ",
         "\nÎòëîæåííûõ ñäåëîê : ",CalculatePendingTotal(),
         "\n",
         "\nÄíåâíîé äèàïàçîí:",
         "\nÑåãîäíÿ   :  ",(high-low)/Point," ïèïñîâ",
         "\nÂ÷åðà       : ",(_rates[1][3]-_rates[1][2])/Point," ïèïñîâ",
         "\nÑðåäíèé   :  ",AverageRange," ïèïñîâ"," çà ",ForDays," äíåé",
         "\nÎäèí ïèïñ : ",pips," òóãðèêîâ"
         );  
              



   
_N_Time = Time[0];
//---- End Of Program
return(0);
}
//+------------------------------------------------------------------+
double TotalProfitByStops()
{
int cnt, ticket, total;
double Profit=0;
   
   total=OrdersTotal();
   for(cnt=0;cnt<total;cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
  if (OrderStopLoss()!=0)
      {   
      if(OrderType()==OP_BUY)  Profit=Profit+(OrderStopLoss()-OrderOpenPrice())/MarketInfo(OrderSymbol(),MODE_POINT)*OrderLots()*MarketInfo(OrderSymbol(),MODE_TICKVALUE)+OrderSwap();
      if(OrderType()==OP_SELL) Profit=Profit+(OrderOpenPrice()-OrderStopLoss())/MarketInfo(OrderSymbol(),MODE_POINT)*OrderLots()*MarketInfo(OrderSymbol(),MODE_TICKVALUE)+OrderSwap();
      }
     } 
return (Profit);    
} 




double TotalProfitableDeals()
{
int cnt, ticket, total;
double ProfitableDeals=0;
   
   total=OrdersTotal();
   for(cnt=0;cnt<total;cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
  if (OrderProfit()>0)
      {  
      ProfitableDeals=ProfitableDeals+1; 
      }
     } 
return (ProfitableDeals);    
} 

double ProfitableDealsAmount()
{
int cnt, ticket, total;
double Amount=0;
   
   total=OrdersTotal();
   for(cnt=0;cnt<total;cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
  if (OrderProfit()>0)
      {   
      Amount=Amount+(OrderProfit()+OrderSwap());
      }
     } 
return (Amount);    
} 

double LoosingDealsAmount()
{
int cnt, ticket, total;
double Amount=0;
   
   total=OrdersTotal();
   for(cnt=0;cnt<total;cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
  if (OrderProfit()<0)
      {
      Amount=Amount+(OrderProfit()+OrderSwap());
      }
     } 
return (Amount);    
} 


double TotalLoosingDeals()
{
int cnt, ticket, total;
double LoosingDeals=0;
   
   total=OrdersTotal();
   for(cnt=0;cnt<total;cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
  if (OrderProfit()<0)
      {  
      LoosingDeals=LoosingDeals+1; 
      }
     } 
return (LoosingDeals);    
} 

int CalculatePendingTotal()
  {
   int cmd;
   int orders=0;
//----
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
         cmd=OrderType();
         if(cmd!=OP_BUY && cmd!=OP_SELL) orders++;

     }
//---- return orders volume
  return(orders);
  
  }   

//-------------------------------------------------------------------------------------------

Comments