Exp_Ind-_FutureProfit_v_CodeBase

Download script
Author: Copyright � 2009, expforex

This tool is designed as an on-screen dashboard for MetaTrader users to monitor the financial implications of their open trading positions in real-time. Rather than just showing current profits, it calculates "projected" outcomes based on your pre-set safety targets.

Core Functionality

The script automatically scans every active trade on your account and performs the following logic:

  • Potential Profit Calculation: For every open position, the script identifies where your "Take Profit" (TP) level is set. It then calculates exactly how much money you would gain if all current trades hit their respective targets simultaneously.
  • Potential Loss Assessment: Similarly, it identifies your "Stop Loss" (SL) levels. It calculates the total amount of capital that would be lost if every open trade hit its exit point at the same time.
  • Dynamic Dashboard Updates: These figures are displayed directly on your trading chart as clear, easy-to-read text labels. You can see three primary values:
    1. Your current account balance.
    2. Your total projected balance (Balance + Potential Profit).
    3. Your "worst-case" balance (Balance - Potential Loss).

Safety Monitoring and Alerts

Beyond simply displaying numbers, the script includes a built-in risk management feature:

  • Exposure Warning: The tool constantly monitors your potential loss relative to your total account size.
  • Visual Alert: If the calculated potential loss exceeds a specific safety threshold (specifically, if the loss would represent more than 20% of your current account balance), the script triggers a visual warning on the chart. This serves as a high-visibility alert to notify you that your current risk exposure may be reaching dangerous levels.

Summary for the User

In essence, this tool provides a "what if" snapshot of your trading activity. It allows you to see the maximum possible gain and the maximum potential drawdown of your entire portfolio at a glance, helping you stay aware of your risk exposure while you trade.

Orders Execution
Checks for the total of open orders
7 Views
0 Downloads
0 Favorites
Exp_Ind-_FutureProfit_v_CodeBase
//+------------------------------------------------------------------+
//|                                           Exp - FutureProfit.mq4 |
//|                                       Copyright © 2009, expforex |
//|                                        http://www.expforex.at.ua |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, expforex"
#property link      "http://www.expforex.at.ua"
#property indicator_chart_window
int start()
  {
   Stamp2();
   int k;
   double Balance=0,profit=0,stop=0;

double b,a;
//----
  for (int i=0; i<OrdersTotal(); i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
    double tick=MarketInfo(OrderSymbol(), MODE_TICKVALUE)*OrderLots();
if (OrderType()==OP_BUY)
   {
      if(OrderTakeProfit()!=0)
    {
 
    a=  (OrderTakeProfit()-OrderOpenPrice())/MarketInfo(OrderSymbol(),MODE_POINT);
    b= a*tick;
    profit=profit+b;
 }
    if(OrderStopLoss()!=0)
    {
    a=  (OrderOpenPrice()-OrderStopLoss())/MarketInfo(OrderSymbol(),MODE_POINT);
    b= a*tick;
    stop=stop+b;
    }
   } 

if (OrderType()==OP_SELL)
   {
      if(OrderTakeProfit()!=0)
    {
    
    a=  (OrderOpenPrice()-OrderTakeProfit())/MarketInfo(OrderSymbol(),MODE_POINT);
    b= a*tick;
    profit=profit+b;
    }
        if(OrderStopLoss()!=0)
    {

    a=  (OrderStopLoss()-OrderOpenPrice())/MarketInfo(OrderSymbol(),MODE_POINT);
    b= a*tick;
    stop=stop+b;
     }
   } 


}
}
   
//----
   ObjectDelete("Original");
   ObjectDelete("Original3");

   ObjectCreate("Original", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Original","Áàëàíñ="+DoubleToStr(AccountBalance(),2)+" Ïðè tp="+DoubleToStr(profit+AccountBalance(),2)+" Ïðè sl="+DoubleToStr(AccountBalance()-stop,2), 10, "Arial Bold", Green);
   ObjectSet("Original", OBJPROP_CORNER, 0);
   ObjectSet("Original", OBJPROP_XDISTANCE, 300);
   ObjectSet("Original", OBJPROP_YDISTANCE, 10);

   ObjectCreate("Original3", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Original3","Ñóììà t/p"+DoubleToStr(profit,2)+" Ñóììà s/l="+DoubleToStr(stop,2), 10, "Arial Bold", Green);
   ObjectSet("Original3", OBJPROP_CORNER, 0);
   ObjectSet("Original3", OBJPROP_XDISTANCE, 300);
   ObjectSet("Original3", OBJPROP_YDISTANCE, 25);



if (AccountBalance()-stop<=(AccountBalance()/100)*20)
{
   ObjectDelete("Original");
   ObjectCreate("Original", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Original","Áàëàíñ="+DoubleToStr(AccountBalance(),2)+" Ïðè tp="+DoubleToStr(profit+AccountBalance(),2)+" Ïðè sl="+DoubleToStr(AccountBalance()-stop,2)+" WARNING! STOPOUT ", 10, "Arial Bold", Red);
   ObjectSet("Original", OBJPROP_CORNER, 0);
   ObjectSet("Original", OBJPROP_XDISTANCE, 200);
   ObjectSet("Original", OBJPROP_YDISTANCE, 10);

   ObjectCreate("Original3", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Original3","Ñóììà t/p"+DoubleToStr(profit,2)+" Ñóììà s/l="+DoubleToStr(stop,2), 10, "Arial Bold", Green);
   ObjectSet("Original3", OBJPROP_CORNER, 0);
   ObjectSet("Original3", OBJPROP_XDISTANCE, 300);
   ObjectSet("Original3", OBJPROP_YDISTANCE, 25);

}
   ObjectCreate("Original2", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Original2","Ðàçðàáîòêà: http://expforex.at.ua", 15, "Arial Bold", Green);
   ObjectSet("Original2", OBJPROP_CORNER, 2);
   ObjectSet("Original2", OBJPROP_XDISTANCE, 300);
   ObjectSet("Original2", OBJPROP_YDISTANCE, 10);


   return(0);
  }
//+------------------------------------------------------------------+




void Stamp2(){

   ObjectCreate("Original", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Original", " ---http://Expforex.at.ua---", 10, "Arial Bold", Red);
   ObjectSet("Original", OBJPROP_CORNER, 2);
   ObjectSet("Original", OBJPROP_XDISTANCE, 200);
   ObjectSet("Original", OBJPROP_YDISTANCE, 10);


}



Comments