Account Balance

Back to topics list To post a new topic, please log in or register
avatar
3
awkWard 2015.05.10 22:32
 

Hi there,

 

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

 void OnTick()

  {

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

   Alert("aaaaaa",TimeToStr(TimeCurrent()),AccountBalance());

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

Any ideas?

 

Herbie 


 

avatar
145
aakcaagac 2015.05.10 23: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);
   Comment(textValue);
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

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.

avatar
21
CristianoKonrad 2015.05.12 21:22 #
 
.
Back to topics list  

To add comments, please log in or register