CurrentInfo_v2
Download scriptThis script serves as a comprehensive analytical dashboard designed to provide traders with a real-time overview of their current trading activity and the prevailing market volatility. Rather than executing trades itself, it acts as an information hub, distilling complex data into clear metrics on the chart interface.
The logic is divided into three primary functional areas:
1. Market Volatility Analysis
The script monitors the historical price movement to establish a baseline for current market behavior. It performs the following calculations:
- Daily Range Tracking: It identifies the highest and lowest prices reached today and compares them against the range from the previous day.
- Average Movement: Based on a user-defined timeframe (defaulting to 10 days), it calculates the average daily range of the asset. This helps traders understand if the current market movement is normal or unusually high/low compared to historical trends.
- Volatility Indicators: It incorporates technical data (ATR) and currency values to provide context on how much a price "pip" is worth in actual value, helping with risk assessment.
2. Live Portfolio Performance Monitoring
The tool scans all currently open positions to provide a snapshot of the trader's performance. It automatically tallies and displays:
- Profit vs. Loss: It separates current trades into "Profitable" and "Losing" categories, showing both the total number of trades in each category and the total monetary amount gained or lost.
- Pending Orders: It counts how many "waiting" orders (limit or stop orders) are currently active but not yet filled.
- Stop-Loss Projections: It calculates a theoretical profit/loss value based specifically on where your "Stop Loss" levels are set relative to your entry prices.
3. Dynamic Data Reporting
All the information gathered from the market and your personal portfolio is displayed as a text comment directly on the trading chart. This allows a trader to see, at a glance:
- The total amount of profit/loss currently held in active trades.
- A comparison of today's price movement versus yesterday's.
- The average daily range over a specific period.
- The quantity and value of losing vs. winning positions.
By consolidating these data points, the script allows a trader to monitor their risk exposure and the market's "pulse" simultaneously without having to manually switch between different tabs or tools.
//+------------------------------------------------------------------+
//| 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);
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;
if(counted_bars==0) limit-=1+ForDays+1;
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