I am completely lost - page 3

 
FMIC there are THINGS in that documentation that don't QUITE make sense. Whoever wrote that thing clearly was writing it for an intended audience who had never even written a program in gwbasic or pseudocode let alone exposure to higher level programming concepts. Or at least the intention of the author was for it to be comprehensible to such people, not necessarily for it to be exclusively directed at such people. I am inclined to skip the parts about if/else statements and for loops and what a variable is, for crying out loud, so no, not reading it start to finish. YET when I skip past those parts, in the next sections, the author couldn't quite successfully see it from the perspective of a relative beginner because someone like me comes along who has some limited programming experience and the pieces still don't fit together once it gets to a certain point in the literature. Here's another example. The datetime data type. I go here: http://msdn.microsoft.com/en-us/library/system.datetime_members%28v=VS.90%29.aspx and I see that datetime variables are by standard much more complicated than what this documentation says. For instance, it contains information on the MILLISECONDS. It can be any year up to AD 9999. Yet this documentation SUGGESTS it is different, but it doesn't go into sufficient detail. Perhaps it is not the standard C++ datetime variable but something specific to MQL4 then? The number of seconds since the beginning of 1970, valid up to the end of 2037. Now, there happens to be very nearly 2^31 seconds in that interval of time. That suggests it is a signed long integer - since an unsigned long integer would actually make it into the 22nd century starting from 1970. Can I actually USE it in arithmetic operations AS IF it was a signed long integer? It doesn't say. It is ambiguous. It COULD be a glorified stringlike variable, just with certain constraints on what the string can be. It also shows a few incomplete ways to use it. But it isn't explicit enough about all the ways it may be accessed or manipulated. Can I just use it in integer arithmetic alongside ints? If I read the time index of a sample, can I just subtract one from a 1-minute chart from another 1-minute chart and if they are consecutive minutes, expect them to differ by 60 (possibly plus or minus 1)?

There was that other thing I already had an issue with - the description of the ArrayCopySeries is ambiguous. It suggests in parts that array[] is written to in some parts, but in other parts, it suggests it isn't. And I look it over and I absolutely do not understand the purpose of the function if it does NOT copy the currency data into array.

Here's another thing I'd like to know. It says that a EA can have 3 main functions. init, deinit, and start. init is run once when it is first run, start is run whenever there is a new tick, and it doesn't say a thing about deinit. The example here https://book.mql4.com/samples/expert doesn't even HAVE an init. It has a start. It has some complicated things for apparently handling errors like Fun_Error whatever all that does. No init. What about variables. Are variables defined within init still valid when it is done and when "start" runs? Or should they be declared outside both variables? Are the variables declared within start cleared every time start runs again? Are variables declared outside of it? I hope not! I'm not even quite sure I'm allowed to ALTER the variables that are declared outside of any function. They seem like they may all be global static variables from what I've seen.

By the way, are currency symbols used in functions like iTime supposed to be in single quotes or double quotes. "USDCHF" or 'USDCHF'. A thousand little things like this. Any one of them will I'm sure cause it to not be compiled when I get to the end. And with a thousand different little incidental things wrong, there will be do debugging it.

RaptorUK oh of COURSE you don't have any obligation to help me. And if your idea of a good time is trolling people on forums, mocking them for being on a forum asking for help when CLEARLY the purpose of going on any forum in the first place is to troll people, then I see you are indeed both enjoying yourself and fulfilling what you believe to be the correct role of a forum user. As for me, if I was QUALIFIED to help anyone, by answering a question I could answer, I hypothetically may well be willing to do that. I know a great deal about arcane mathematics, not so much about programming. For instance, if you had a dozen indicators which were not statistically independent, I know how to optimally combine them into a composite indicator in a way which compensates for the fact that they are statistically dependent. Of course I'm certainly not going to help YOU with anything now. By golly, if I saw you with your foot stuck in railroad tracks, I'd say "I COULD help you, but what's in it for ME?"

 
zortharg:
FMIC there are THINGS in that documentation that don't QUITE make sense. ...

I had no difficulty reading all the book from start to finish, despite being well versed in High-Level and Low-Leval languages.

I am 45 years old and have been a software developer by trade since 1986 also having a B.Sc in Engineering (Low Current Electronics). I am proficient in C, C++, C#, Pascal, Cobol, Fortran, Perl and many others that have long since disappeared. I am also well versed in Assembler programming for x86, Z-80, Pics and many other architectures. Again, I say, that I had no difficulty reading and learning MQL4.

So, all I can conclude is that your High-and-mighty attitude of criticising the documentation, instead of focusing on the actual goal of learning MQL, can only mean one thing - You are actually more stupid than the non-programmers for which the documentation was written for.

If you think that MetaTrader and MQL is so beneath you, then why are you here? Seriously! Why?

There are many other trading applications and algorithmic systems out there. Pick one and go trouble them!

By the way, "RaptorUK" is a MODERATOR on the forum. YOU ARE the TROLL here!

This is my last post on this thread! You are not worth the effort.

 
zortharg:

RaptorUK oh of COURSE you don't have any obligation to help me. And if your idea of a good time is trolling people on forums, mocking them for being on a forum asking for help when CLEARLY the purpose of going on any forum in the first place is to troll people, then I see you are indeed both enjoying yourself and fulfilling what you believe to be the correct role of a forum user. As for me, if I was QUALIFIED to help anyone, by answering a question I could answer, I hypothetically may well be willing to do that. I know a great deal about arcane mathematics, not so much about programming. For instance, if you had a dozen indicators which were not statistically independent, I know how to optimally combine them into a composite indicator in a way which compensates for the fact that they are statistically dependent. Of course I'm certainly not going to help YOU with anything now. By golly, if I saw you with your foot stuck in railroad tracks, I'd say "I COULD help you, but what's in it for ME?"

Perhaps you should explain this comment of yours ?

The audacity of the people on this forum!


Many people on this forum give up their free time to try and help . . . and you come along and expect to be helped as if it were a right ! I think everyone would be happy to help you until you demonstrated your attitude . . . you should show a little humility when asking for help.

You can label me however you wish, I really don't care, I know why I am here and some people even thank me for trying to help . . . I guess that is beyond you.

 
zortharg:

So I have to download the historical prices one time at a time with iclose then? https://docs.mql4.com/series/iClose The problem with that as I see it is that the data can update while I'm in the middle of downloading it. It would be very nice to download the whole thing as a block. I GUESS I can download the time with iTime and THEN use iclose and THEN use iTime again on the same index and if it has changed, then it has begun a new bar time interval and I have to go back an index number. Am I reasoning that correct or is there something I don't understand?


Why would a function call ArrayCopySeries() require you to copy the series yourself?

You declare the array but dont need to specify the size.

When ever you access the array, mql does "magic" and (hopefully) the right value pops out in the right place.

There is an example on the page.

Having said that,the on-line documentation is out of sync at the moment, so use the Help in the metaeditor as your primary reference.

Stare at the example until it makes sense!

 
zortharg:
The datetime data type. I go here: http://msdn.microsoft.com/en-us/library/system.datetime_members%28v=VS.90%29.aspx and I see that datetime variables are by standard much more complicated than what this documentation says. For instance, it contains information on the MILLISECONDS. It can be any year up to AD 9999. Yet this documentation SUGGESTS it is different, but it doesn't go into sufficient detail. Perhaps it is not the standard C++ datetime variable but something specific to MQL4 then? The number of seconds since the beginning of 1970, valid up to the end of 2037. Now, there happens to be very nearly 2^31 seconds in that interval of time. That suggests it is a signed long integer - since an unsigned long integer would actually make it into the 22nd century starting from 1970. Can I actually USE it in arithmetic operations AS IF it was a signed long integer? It doesn't say. It is ambiguous. It COULD be a glorified stringlike variable, just with certain constraints on what the string can be. It also shows a few incomplete ways to use it. But it isn't explicit enough about all the ways it may be accessed or manipulated. Can I just use it in integer arithmetic alongside ints? If I read the time index of a sample, can I just subtract one from a 1-minute chart from another 1-minute chart and if they are consecutive minutes, expect them to differ by 60 (possibly plus or minus 1)?

Why so many words to ask a simple thing :)

Old MQL: https://docs.mql4.com/dateandtime A group of functions providing the working with data of the datetime type (integer representing the amount of seconds elapsed from midnight, 1 January, 1970).

New MQL: https://www.mql5.com/en/docs/basis/types/integer/datetime - The datetime type is intended for storing the date and time as the number of seconds elapsed since January 01, 1970. This type occupies 8 bytes of memory.

Most languages that used the old 32bit integer to store time, have moved to 64 bit, to avoid ruin when year 2038 comes around.

You just add and subtract like you guess. But keep it as a datetime datatype, and avoid temptation to store in in a long variable.

 

THANK YOU ydrol!

Hmmmmm. I don't know if static_cast even exists in mql4, but can I just use any regular arithmetic operations on datetimes then, so long as I save the result in another datetime? Like if X[] is an array of datetimes, and I want to work with the minute number, I could take Y=(X[17]+30)/60 so long as Y is a datetime and not a long? Right? Or rather, I would maybe take Y=(X[17]-X[16]+30)/60 because it would be bad if X[17] was 29 mod 60 and X[16] was 30 mod 60, it would think they were 2 minutes apart if I did it the first way.

Oh man, the code I have made so far is so long already, and all that's done is to read in the data and now I have to compensate for the data skipping minutes (or the whole weekend!) by shifting the data around more and interpolating, I wonder what the odds are this turkey's going to work when I'm done with it, ha ha. All from a matlab program which shows that I finally have a trading method which can beat the spread/commission, but putting it into actual practice is something else.

To everyone who is not ydrol, ok, I am declaring you the winners of your respective p***ing contests, so congratulations and since you win, you can stop posting on this thread now.

 

Hmmmmm. I don't know if static_cast even exists in mql4, but can I just use any regular arithmetic operations on datetimes then, so long as I save the result in another datetime?

If the result of your arithmetic is still a point in time (ie still a value that is number of seconds since 1970), then keep it as a datetime, otherwise you can cast it to a long or int. (You dont have to but it will avoid confusion later)

Doesnt help to antagonise everyone, just change approach to get the help you want :)

 

Well after writing some code it does indeed seem very hard for me to avoid saving arithmetic results with datetimes as inputs into ints. But static_cast<long> would theoretically work as it would in C++? I don't see any mention in the docs.

Oh, by the way, time zone. Is it UTC? That book just keeps saying the number of seconds since January 1, 1970 at 0:00. I could assume that it is UTC like UNIX time, except that we've already established that there are at least some discrepancies between the "datetime" variables here and what C++ uses (no milliseconds for instance) - which admittedly itself isn't UNIX time, but is called "datetime" nonetheless - so just because it superficially resembles UNIX time because of starting at the beginning of 1970, I shouldn't assume that's what it is. Is it necessarily UTC or is it possible that every broker could have their own offset based on their own time zone and that I need to have it in the code for it to figure out where the start of the week, modulo 10080 minutes, is, based on the data? The point being, to know the time modulo 10080 when trading starts and ends, since the market is only open 7200 out of those 10080 minutes, so that it can wind down the positions as the weekend is approaching, and not begin full throttle right at the beginning or MUCH worse, to make drastic trading decisions based on discontinuities in prices between the end of one week and the beginning of the next, or even to be oblivious to hiatuses when determining info like volatility - which I define to be mean square change in price after 1 minute - and then I add 1/4 times the mean square change in price after 2 minutes and 1/9 times the mean square change in price after 3 and 1/16 times the mean square change in price after 4 and then multiply the whole thing by 1/(1+1/2+1/3+1/4)=0.48.

Hey what can I say, I came in asking for help and they were nasty and antagonizing to me from the get-go. If someone asks for help, what I do is I either don't give it to them or I give it to them. If I don't know the answer to a question someone asks, I don't make small talk instead of answering it, and if I don't want to take the time to answer the question properly, I don't take the time to mock them for asking it or give them a useless non-answer. Leeway on that last one for someone asking a question they should know the answer to if they have lived on the planet Earth for more than a day, or if the question is rhetorical and especially if designed to be insulting to a certain group of people. I'm a get to the point sort of individual and I operate on a tit-for-tat code of ethics. I'm polite to people until they're nasty to me and then I stop being polite, and I'm also honest to people until they lie, cheat and steal from me and then my default code of civil behavior is out the window and I will lie, cheat and steal in exchange and will show no pity or restraint. It may be a simplistic way of looking at the world but I'm stubborn and unforgiving.

But to you, thank you for your help. And if there is something I can help you with, ask away. Not that I assume you're looking for help with anything I could help with.

 
zortharg:

Well after writing some code it does indeed seem very hard for me to avoid saving arithmetic results with datetimes as inputs into ints. But static_cast<long> would theoretically work as it would in C++? I don't see any mention in the docs.

Oh, by the way, time zone. Is it UTC?


It's timezone independent . . . how many seconds are there between 2pm and 3pm ? you don't need to know the timezone to answer 3600 . . . if it help just assume that the start time, Midnight 1st Jan 1970 and the time you are interested in are both in the same timezone.
 

EDIT: Oops, as has been pointed out, there is no specific timezone for datetime. It depends on where you obtained it from! (this causes needless complication, unlike UnixTime on which it was ultimately based!).

The timezone for datetime (seconds past 1970) is based on UTC. Just like Unix time. It is UnixTime - 64 bit unix time.

Unile true UTC, Unix time ignore leap seconds (see 1st paragraph) and such so modulo arithmetic works for minutes, and hours.

datetime - datetime = long (seconds duration) - although as far as trading is concerned it will be an int pretty much most of the times that I can envisage!

datetime +/- seconds(long) = datetime(another date)

datetime +/- seconds(int) = datetime(another date)

Reason: