Can I have an indicator refresh by time not by tick?

 

Hi Everybody.


Is there a way to set indicators to refresh every 200ms vs. every tick/new quote?


Programing and testing during the weekend at this moment is impossible. =/


Thanks.

 

Try the following.


CB


start()
 {
  while (!IsStopped())
   {
     ...
     sleep(200);
   }
 }
 
cloudbreaker wrote >>

Try the following.

CB

Excuse my butting in but hit me be reading "..set indicators to refresh.."

fwiw, since no exit, data can become out of date in the programs series arrays...

Where put RefreshRates() is somewhat subjective, but [at least] within the loop ;)


start()
{
  while (!IsStopped())
   {
     ...
     sleep(200);
     //---- refresh price data
     RefreshRates();
   }
}

"Programing and testing during the weekend at this moment is impossible. "

Not totally -

1. if attach indicator to chart it will still plot/do its biz on available data.

2. if run script it will, just like indicator work.

3. if use Strategy Tester it will run... and should it make use of iCustom() and the target is an indicator, it will be loaded do its biz eg, plots. Which will be seen when "Open chart" button is clicked.

Just no live data feed so no forwards stuff but backwards up to last open market data tick, which also can be refreshed/brought up to date at any time via RtClick-"Refresh"

I am programming and testing [and crying:] right now. LOL, my cpu is s.l.o.w. and tester likewise, so this gets keyed in :o)

 
Isn't there an issue with using sleep() in indicators? Thinking it doesn't work.
 
Ruptor wrote >>
Isn't there an issue with using sleep() in indicators? Thinking it doesn't work.

Well... gotta wait till Monday - but remember other threads talking about the pros and cons of the while(true) idea.

I favour the hit 'n run MT classical style, so staying put is not my scene but there ya go!

 
Ruptor:
Isn't there an issue with using sleep() in indicators? Thinking it doesn't work.

Yep, you're right. Wasn't thinking indicators. Was thinking in terms of EA.


CB

 
#include <WinUser32.mqh>
#define  CHART_CMD_UPDATE_DATA            33324
int start()
{
   while (!IsStopped())
   {
      int hwnd = WindowHandle(Symbol(), Period());
      PostMessageA(hwnd,WM_COMMAND,CHART_CMD_UPDATE_DATA,0);
      Sleep(2000);
   }
  return(0);
}

Put this scirpt in scripts folder. And attach it on your chart. Your indicator would be refreshed by every 2sec.

But I think Strategy Tester is better solution.

Using Visual mode,Drop your indicator in the tester chart.

 

mmhhh, just a little thought about it.

If you are on higher time frames and you want it ti refresh every minute you could use iVolume.

for(i=.......)
    {
     if(limit=1 && iVolume(NULL,1,0)<=1)
     {your code};
    }

I am unexpirienced and new to MQL but sometimes I'm lucky and it works :D . What do the others think?

But I have to say using the Sleep() function definitely is more elegant.

 

This topic cought my interest actually...

What about using the TimeCurrent() function in conjunction with the %-Operator?

for(i=....)                                                      //your normal iteration function at the beginnig of the Calculation                                                
    {
     if(limit<=1 && TimeCurrent()%Refreshingperiodinseconds=0)
     {your code}
    }
This shall work...because everytime you have the seconds, counted from 00:00 January, 1 1970, divided by your given refreshing rate without a remainder the function operates.
 

ErrorProgrammer, give it a try. Slot it into a test indicator and let us know how it goes.


CB

 

Thanks everybody, I can now resume programming.


For some reason I though looping an indicator would drag down the system... well I guess not so much for a quadcore 2.4Ghz. My thinking was aligned with programing PICmicro MCUs, those little guys are standerd at 8Mhz and timing sensitive applications must be coded with that limitation in mind.

Reason: