Topic: Using OnTimer versus OnTick with an MT4 Expert Advisor
Recently on another forum I posted a comment / question about the use of OnTimer versus OnTick. Below is a link. I'm posting this partly so you can read my description and partly to check out the response. Make sure there are no children in the room...
The fellow who runs the blog has a love / hate relationship with MT4. On one hand his life revolves around MT4, but on the other he hates it. He even changed some of the words in my post -- e.g. changing "MT4 Strategy Tester" to "Empty4Shit Tester". Very strange...
Anyways -- it reminded me what a pleasure it is to come here, even though sometimes I get frustrated
http://www.stevehopwoodforex.com/phpBB3/viewtopic.php?f=5&t=5498
I've posted before about the use of OnTimer versus OnTick in Portfolio Maker. And until a couple of weeks ago people had reported conflicting observations. However, recently I found/solved the problem that makes use of OnTimer more reliable. Depending on your opening postion, the generated *.mq4 code may perform the following check:
bool isNewBar=(barTime<dataMarket.BarTime && dataMarket.Volume<5);
However, the condition "dataMarket.Volume<5" usually returns 'false' when OnTimer is used -- hence, the strategy doesn't trade as often as the OnTick version. Changing the above line to:
bool isNewBar=(barTime<dataMarket.BarTime);
now results in OnTimer working more reliably.
Actually, a few months ago Popov had pointed-out the above line of code to me -- but I didn't make the connection.