Download MetaTrader 5
To add comments, please log in or register
Unable to find the answer to your question? Use the search!
Herbie
8
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  ---

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

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

Any ideas?

 

Herbie 


Ali Akcaagac
169
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);
   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.

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