//+------------------------------------------------------------------+
//|                                           Mn Show Profit Code.mq4 |
//+------------------------------------------------------------------+
#property copyright "Mn"

#property indicator_chart_window

extern int mCorn = 3, mtextSize = 18, mXDist = 1, mYDist = 1;
extern color mCol1 = Blue, mCol2 = Red;
extern string mFont = "Arial";

//+------------------------------------------------------------------+
   
int init()
 { 
   ObjectCreate("mShowProf", OBJ_LABEL, 0, 0, 0, 0, 0);
   ObjectSet("mShowProf", OBJPROP_CORNER, mCorn);
   ObjectSet("mShowProf", OBJPROP_XDISTANCE, mXDist);
   ObjectSet("mShowProf", OBJPROP_YDISTANCE, mYDist);
   ObjectSetText("mShowProf", " ", mtextSize, mFont, CLR_NONE);

  return(0); 
 }
 
//-----------------------------------------------+ 
int start()
 {
   color mTextCol;
   double mProf = 0;

   for(int i = 0; i < OrdersTotal(); i++)
     {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == false) break;
      if(OrderSymbol() == Symbol() && OrderType() < 2)
        {
          mProf = mProf + OrderProfit();
        }
     }
   if(mProf < 0) mTextCol = mCol2; 
   else mTextCol = mCol1;
   
   ObjectSetText("mShowProf", DoubleToStr(mProf, 2), mtextSize, mFont, mTextCol);
   if(mProf == 0) 
     ObjectSetText("mShowProf", " ", mtextSize, mFont, CLR_NONE);

  return(0);
 }
 
//-----------------------------------------------+
int deinit()
 {
  ObjectDelete("mShowProf");
  
  return(0);
 }

//-----------------------------------------------+


