Hi
I am trying to quite OnCalculate
after the indicator is plotted and not to execute the code block
unless a new bar is received.
the following seams not to cut it.
Any ideas ples. thx
MQL5 Code:
int OnCalculate(const int rates_total,...
{
//---
if(!isNewBar())
return(0);
//do rest of block.
MQL5 Code:
bool isNewBar
(){ MqlRates rates
[]; static datetime dt_current
; static datetime dt_prev
; int copied
=CopyRates(NULL,0,0,1,rates
); if(copied
<=0) Alert("Error copying price data inside isNewBar",GetLastError()); //else Alert("Copied ",ArraySize(rates)," bars"); if(!dt_current
) { dt_current
= rates
[0].
time; dt_prev
= rates
[0].
time; return 1; } else if(dt_current
== dt_prev
) { return 0; } else return 1;}