I need to memorize the value of the initial account balance in a variable V at the first start of the expert

To add comments, please log in or register
Algo
12
Algo  

I need help

In my expert I need to memorize the value of the initial account balance in a variable V at the first start of the expert in order to use this value and compare it with the account equity at each tick.

So if the account equity at a certain time t is greater than the value of the initial account balance , previously stored in the variable V, I close all active orders.


Thank you

Samih Abdelli
179
Samih Abdelli  
Algo:

I need help

In my expert I need to memorize the value of the initial account balance in a variable V at the first start of the expert in order to use this value and compare it with the account equity at each tick.

So if the account equity at a certain time t is greater than the value of the initial account balance , previously stored in the variable V, I close all active orders.


Thank you


//+------------------------------------------------------------------+
int OnInit()
  {
   GlobalVariableSet("OldBalance",AccountBalance());
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,const int prev_calculated,
                const datetime &time[],const double &open[],
                const double &high[],const double &low[],
                const double &close[],const long &tick_volume[],
                const long &volume[],const int &spread[])
  {
   if(AccountEquity()>=GlobalVariableGet("OldBalance"))
     {
      // some code here
     }
  }
//+------------------------------------------------------------------+

}
MANDAR SHENDGE
56
MANDAR SHENDGE  
Samih Abdelli:


Hi Friends,


I have set my Original account balance and Lots Current in GlobalVariable.

The issue is, when I migrate to VPS, my global variable Original account balance or Lots Current or may be both are reset to 0.

Does anyone has this experience or fix of such issue ?

Thanks in advance for your reply and help.


Mandar

Algo
12
Algo  
Samih Abdelli:


Thanks Samih! Reflect on your code :)

To add comments, please log in or register