MiniVirtualAccount – library MetaTrader 4

Author:

Russell

At times one wants to see how an EA is performing without the clutter from other EA’s you’re running. MiniVirtualAccount (MVA) monitors data in your EA. Like EA Balance, EA equity, EA profit, etc.

Full List:

MVA_BALANCE
MVA_PROFIT
MVA_MARGIN
MVA_FREEMARGIN
MVA_EQUITY
MVA_TOTAL_SELL
MVA_TOTAL_BUY
MVA_LOT_PROFIT

Example code:


#include <MVA_v1.0.3.mqh>


extern string General = "---------------";
extern int    Slippage = 2;
extern int    MagicNumber = 74783;
//etc

int giSlippage, giMagicNumber; 


int init(){
      
   giSlippage     = Slippage;
   giMagicNumber  = MagicNumber;    
   //etc

   MVA_init(giMagicNumber);
 
   return(0);
}

int deinit(){
   return(0);
}

int start(){
   
   //manage trades SL + TP   
   
   MVA_main(0, giMagicNumber, PUT); 
   
   if (start_filter() == FALSE){
      showComments();
      return(0);
   }

   
   double ldFreeMargin = MVA_main(MVA_FREEMARGIN, giMagicNumber);
   double ldEquity = MVA_main(MVA_EQUITY, giMagicNumber);
   double ldLots = lotSize(ldFreeMargin, ldEquity, giMagicNumber);
   if (ldLots == 0){
      showComments();
      return(0);
   }
    
   // other code to open

   showComments();
   return(0);
}

void showComments(){
   
   if (IsOptimization() == FALSE){
      Comments(StringConcatenate(
      "Balance : ",    MVA_main(MVA_BALANCE,     giMagicNumber),
      "\nEquity : ",     MVA_main(MVA_EQUITY,      giMagicNumber),
      "\nMargin : ",     MVA_main(MVA_MARGIN,      giMagicNumber),
      "\nFreeMargin : ", MVA_main(MVA_FREEMARGIN,  giMagicNumber)));      
   }
}

📈 ROBOTFX MetaTrader Expert Advisors and Indicators to maximize profits and minimize the risks