Yeah, the downloaded code is correct.
I tested it out and it works.
Did you set an appropriate level in the indicator menu properties before it ran?
I tested it on GBPUSD with a value of 1.37 and the Delta was calculated correctly.
Yes, it's a bug in the sample code that is shown. If the delta is positive the price is obviously above the level. The mq4 file is correct.
Ah of course the error is mine. The level should be 1.1735.
Apologies.
I am testing on EURUSD with a level of 1.7351 and look at the Delta values. I will try with GBPUSD.
It's right, by my calculations.
Bid = 1.175
Level = 1.7351
Result = Bid - Level = -0.5601
Result / Point = -0.5601 / 0.00001 = -56010
The result is slightly off (-56010 vs -56013), but that can be explained by the fact that Bid (1.175) is probably not as precise due to the output being displayed.
Ah of course the error is mine. The level should be 1.1735.
Apologies.
NP, cheers.
It's right, by my calculations.
Bid = 1.175
Level = 1.7351
Result = Bid - Level = -0.5601
Result / Point = -0.5601 / 0.00001 = -56010
The result is slightly off (-56010 vs -56013), but that can be explained by the fact that Bid (1.175) is probably not as precise due to the output being displayed.
Yes you are correct. I simply was using a level very far above the correct price. May I ask if the number of digits precision has any effect on all of this?
int Delta=NormalizeDouble((Bid-Level)/Point,5);
would work just the same, or not?
https://book.mql4.com/variables/arrays
I am working through this example in the book. The website code is reproduced for your convenience however it differs from the download code stringarray.mq4
I believe both examples are erroneous.
Is this book even a good way to learn MQL?
BTW, as to answer your question: I'm not a fan of books / reading when starting off. I prefer videos because they tend to be targeted more towards absolute beginners.
Once you have a solid foundation / understanding, then books / reading are good because they help fill in the gaps by providing the finer details that the videos left out.
With that said, MQL is built on top of C++, so, if you know C++, you should be able to transition smoothly.
Or, if you've already learned any programming language, transitioning won't be as tough, it's just learning the syntax and how C++/MQL does things.
But if this is your first language, MQL / C++ aren't exactly beginner friendly.
If you're looking for good resources, there's tons of C++ tutorials on YouTube that start you off with the basics to help you build a foundation of not just C++, but of programming altogether.
BTW, as to answer your question: I'm not a fan of books / reading when starting off. I prefer videos because they tend to be targeted more towards absolute beginners.
Once you have a solid foundation / understanding, then books / reading are good because they just help fill in the gaps by providing the finer details that the videos left out.
With that said, MQL is built on top of C++, so, if you know C++, you should be able to transition smoothly.
Or, if you've already learned any programming language, transitioning won't be as tough, it's just learning the syntax and how C++/MQL does things.
But if this is your first language, MQL / C++ aren't exactly beginner friendly.
If you're looking for good resources, there's tons of C++ tutorials on YouTube that start you off from the basics to help you build a foundation of not just C++, but of programming altogether.
Thanks. Do you have a video series that you recommend in particular for c++?
I would say I'm no longer a complete beginner but I have little practical experience. I think the MQL book is good as it doesn't go too quickly between concepts but it has some elementary errors which is very frustrating for beginners who can't be sure if it's their own fault.
Also it's not quite English, sort of a pseudo-translation.
Still I think learning directly what we want to do is often the best approach as a general C++ course will not deal with practical trading considerations. I only wish there was an MQL5 book along the same lines as the MQL4 version, preferably with updated corrected lessons.
May I ask if the number of digits precision has any effect on all of this?
would work just the same, or not?
In this particular case, no.
int Delta
An int is a whole number, so when you assign it a value from a double (a decimal number), it will be typecast (converted) into the datatype of int.
But, even if Delta were a double, there' s just zeros left after dividing by Point, so it'll be something like 85.0.
However, if you hadn't divided by Point, then setting the precision of NormalizeDouble would come into play.
Leaving the line in question for your convenience:
int Delta=NormalizeDouble((Bid-Level)/Point,0);
In this particular case, no.
An int is a whole number, so when you assign it a value from a double (a decimal number), it will be typecast (converted) into the datatype of int.
But, even if Delta were a double, there' s just zeros left after dividing by Point, so it'll be something like 85.0.
However, if you hadn't divided by Point, then setting the precision of NormalizeDouble would come into play.
Leaving the line in question for your convenience:
That makes sense. Thank you, Alexander.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am working through this example in the book. The website code is reproduced for your convenience however it differs from the download code stringarray.mq4
I believe both examples are erroneous.
Is this book even a good way to learn MQL?
It seems that
should actually be
as we want to know if the delta between the price level and the bid level is nothing or negative. This is correct in the download code example.
Similarly
should be
as we want to know if delta exceeds the max array value
In the download code this has also been correted.
However the program still does not peform correctly. The Delta value calculated is wildly inaccurate, always negative and much larger than reality.
The equation seems correct. Is it a problem with NormalizeDouble?