You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
be careful with such a statement. there's always a logical reason to run sleep(). in Tester and even in indicators.
Take a look at what TimeSeconds() gives you, then think about what TimeCurrent() gives you . . . which one do you need and why ?
Simon,
Returns the amount of seconds elapsed from the beginning of the minute for the specified time.
"which one do you need and why ?" - Simon
I'd use both of e'm in concert, cause they go hand-in-hand. - Nathan
TimeSeconds(datetime time) requires a variable placed inside its braces. TimeCurrent() is then placed within these braces, which presents me viable solution. I've done this b4 but didn't understand why returned time values appeared to skip and pause (due to lack of an active tick/ticks).
What say you to this?
Thank you.
William,
Thank you for expounding on this subject.
My interpretation of "2." is, when a tick is created, the return function is called. Next the Start() function is called directly after calling the return(0) function which triggers execution of the program once more. Is this interpretation of this portion of 2. correct?
"If you compute for 5 minutes", how can I be sure the EA will compute for five minutes (even if the EA computes for five minutes, I don't believe this will guarantees a tick will be created. Probability of a tick creation is increased)?
Apologies, I am having difficulty reading this:
"If you compute for 5 minutes and return the volume (tick count) on the next call will be +1. In a live chart, if you compute for 5 minutes, then you will miss 5 minutes of ticks and on the M1 several new bars will have formed."
Many thanks for your response.
I didn't say there was no logical reason to use sleep(), there are many, I said there was no reason to expect sleep() to work in the Strategy Tester. Does it work in an Indicator running on a Strategy Tester chart, I don't know, maybe it does . . . does it work in an EA running in the Strategy Tester, as far as I know, no it doesn't. Can an EA running in the Strategy Tester be made to pause ? yes it can.
Simon,
"Can an EA running in the Strategy Tester be made to pause ? yes it can."
Could you please express your thoughts regarding this method you'd use to "pause" an EA in the tester?
Thank you
William,
So, a new tick calls the start() function in an EA, yes?
My question to you is this, "Do you know of any other way to call the start() function besides that of a new tick? Possibly a consistent repetitive action to substitute a calling for Start()?"
(I'm thinkin', is there a way to consistently track seconds that don't depend on ticks)
"...The next tick is created when it does."
I believe what you meant to write was, "At the creation of a new tick, Start() is then executed." ;)
So, you say an EA can't be paused or sleep in the tester, yes?
I'll review the link you provided but in the mean-time, can you please expound on this method of "pressing a pause button to pause the tester" after an EA being tested returns from start?
When run in the tester, would this method simulate the performance of the EA being paused for a decided segment of time in "real time" on a live account?
I understand tester has limitations and "work-arounds" must be used for simulation of "real time" performance.
Much gratitude William.
Also, do you mind if I just call you Will? It'd save me a sec. of time every message. Your call.
I like a feature your EA possesses and this is, "I wanted to close all orders before end of the week (market close Friday,) to prevent loss should the market gap over the week end, by passing the SL."
(Clapping hands with joy.) Hahaha! ;) By adding this feature to your EA, you cut unnecessary losses but this is different than what I attempt to do presently. Presently I am trying to track seconds of time consistently without the need of ticks to update the seconds. I wish for a different means to update the Start() function, Understood?
Thank you
Presently I am trying to track seconds of time consistently without the need of ticks to update the seconds. I wish for a different means to update the Start() function, Understood?
I suspect that what you are trying to do is a flawed solution to your problem due to lack of understanding. Why do you need to know the second from one second to the next if price hasn't changed for 30 seconds ? when price changes you get a tick.
A point of clarification of what WHRoeder said, all the ticks are created before the Strategy Tester starts calling/executing them, they are saved to a .fxt file in tester/history, the ST calls a first tick and this in turn causes start() to be executed, the next tick isn't called/used until start() has finished executing, it's very important to understand this. Only when start() has finished will the next tick be used so the EA can call start() again. When the ST is run on full speed it is the speed at which start() runs that governs the speed of the ST, so a very simple start() function will allow the ST to run very quickly, a complex start() function will cause the ST to run slower.
In a Live/Demo situation if the start() function is very complex and takes a long time to run, perhaps a few tenths of a second, it is possible that the next tick can arrive before start() has completed, in this situation the tick will be missed and will not cause start() to be called . . . . this CANNOT happen with the ST.
Simon,
"Can an EA running in the Strategy Tester be made to pause ? yes it can."
Could you please express your thoughts regarding this method you'd use to "pause" an EA in the tester?
"which one do you need and why ?" - Simon
I'd use both of e'm in concert, cause they go hand-in-hand. - Nathan
TimeSeconds(datetime time) requires a variable placed inside its braces. TimeCurrent() is then placed within these braces, which presents me viable solution. I've done this b4 but didn't understand why returned time values appeared to skip and pause (due to lack of an active tick/ticks).
I suspect that what you are trying to do is a flawed solution to your problem due to lack of understanding. Why do you need to know the second from one second to the next if price hasn't changed for 30 seconds ? when price changes you get a tick.
A point of clarification of what WHRoeder said, all the ticks are created before the Strategy Tester starts calling/executing them, they are saved to a .fxt file in tester/history, the ST calls a first tick and this in turn causes start() to be executed, the next tick isn't called/used until start() has finished executing, it's very important to understand this. Only when start() has finished will the next tick be used so the EA can call start() again. When the ST is run on full speed it is the speed at which start() runs that governs the speed of the ST, so a very simple start() function will allow the ST to run very quickly, a complex start() function will cause the ST to run slower.
In a Live/Demo situation if the start() function is very complex and takes a long time to run, perhaps a few tenths of a second, it is possible that the next tick can arrive before start() has completed, in this situation the tick will be missed and will not cause start() to be called . . . . this CANNOT happen with the ST.
Simon,
I suspect that what you are trying to do is a flawed solution to your problem due to lack of understanding. Why do you need to know the second from one second to the next if price hasn't changed for 30 seconds ? when price changes you get a tick.
I'll admit I do have a lack of understanding, that is why I'm discussing the topic in the MQL4 forum. I wish to save price whenever it changes (i understand how to do this). Also, I understand how to save prices every second consistently on a LIVE/DEMO chart using Sleep(). Objective: I wish to consistently track seconds (without tracking seconds based on creation of ticks) up to max of a minute or less, then reset tracked seconds to zero. I understand why I wish to accomplish this objective. The reason being, I need to test an EA in the tester and can't use Sleep() while testing. What to do right? Gathering options.
Details then hm? ;)
Code a timer (usable in tester) to an EA. This timer counts up from 0-30 or down from or 30-0. While this time is counting up/down, I have a separate vector tracking price action (a very large size vector).
My conditions are such,
If price does travels x points (within 0-30 or 30-0 seconds), make decision.
If price doesn't travel x points (within 0-30 or 30-0 seconds), ArrayInitialize().
What say you to this Simon?
Thank you