Download MetaTrader 5

Account Balance

To add comments, please log in or register
Publish your article. Millions of traders are looking for good ideas!
Herbie 2015.05.10 20:32 

Hi there,


I tried to display the time and Balance, but I am seeing nothing.

 void OnTick()


//--  The algorithm  ----------------------------------------------------   3  ---


   Print("Time=",TimeCurrent(),"Account balance=",AccountBalance());

Any ideas?



Ali Akcaagac
Ali Akcaagac 2015.05.10 21:57  
//| Custom indicator iteration function                              |
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[])
   double accountBalance = AccountBalance();
   datetime timeCurrent = TimeCurrent();
   string timeString = TimeToString(timeCurrent);
   string textValue = StringFormat("AccountBalance: %.2f - TimeCurrent: %s", accountBalance, timeString);
//--- return value of prev_calculated for next call

Try this. Just nailed it into the Metaeditor.

1) Create a custom indicator with a name of your choice.

2) Put the code with the yellow background inside the OnCalculate(); function of your indicator. Compile and insert the indicator into a chart.

Now you can do this as Script as well with the OnStart(); function. This only run one time. The OnTick(); function only works in the expert advisor. Hope this get's you going.

Cristiano Konrad
Cristiano Konrad 2015.05.12 19:22  
To add comments, please log in or register