To specify an algo’s active time I have normally used
time >= 080000 and time <210000
Then I got it in my head that i could save a lot of zeros by using this instead:
hour >= 8 and hour <21
The two seemed to be interchangeable, until just now when I found an algo that returns completely different results for time as opposed to hour.
Do they mean different things then? Couldn’t find an answer in the manual.
000030 is greater than 21, but not than 210000!
As Roberto points out – it depends on the time frame that you run your strategy on. On a 1 hour based strategy there is only a candle every hour so TIME = 080000 is the same as HOUR = 8 but on a 1 minute time frame there are 59 candles in between where HOUR = 8 but TIME does not equal 080000.
OK, got it. Hour =8 includes everything in the 8th hour up to the last candle before 9.
Second question: the main reason I changed was not of course to save zeros, but because it made it easier to optimize on the half hour. How would I check a range of times eg 170000 to 230000 by half hour? Steps of 3000 won’t work.
What I had been doing is running it twice, first on the hour 170000 to 230000, then on the half hour 173000 to 233000 — both by steps of 10000.
Is there a better way?
I use 10000 steps (1 hour), so you can use 3000 (30 minutes), provided your TF ends on a 30-minute boundary, that is it must not have to be greater than 30 minutes.
I use 10000 steps (1 hour), so you can use 3000 (30 minutes)
But that would give you times such as:
170000
173000
176000 (not a valid time)
179000 (not a valid time)
182000
You will have an awful lot of tests with no results to run through.
Perhaps optimising with two variables would be better and more efficient. MyHour 0 to 23 in steps of 1 and MyMinute 0 to 1 step 1 and then add the following to the start of your strategy:
extra = 0
if myminutes = 1 then
extra = 3000
endif
mytime = (myhour * 10000) + extra
80000 is obviously not the same number as 8! 😉
80000 is obviously not the same number as 8
Yes, my bank manager has been patiently trying to explain that to me.
Perhaps optimising with two variables would be better and more efficient. MyHour 0 to 23 in steps of 1 and MyMinute 0 to 1 step 1 and then add the following to the start of your strategy:
Very clever! I’ll try that, thanks.
Vonasi code above added as Log 205 here …
Snippet Link Library
Vonasi code above added as Log 205 here …
Snippet Link Library
It’s a treasure ! thx Grahal for the link