Download MetaTrader 5
To add comments, please log in or register
Share links from other resources. Now they have a description.
mar
1143
mar 2014.05.15 21:23 

Hey guys,

I try to optimize my indicators a little bit by implementing new MQL4 code. I have some general questions about data types. When I need a high or low of a bar, I used the data type double. But now I see that float uses only 4 bytes instead of 8 bytes used by double. When it comes to prices, can I just replace double with float? And what happens when I need to convert it into a string? Can I still use DoubleToStr, even when I use float?

whroeder1
13610
whroeder1 2014.05.16 00:13  
  1. Ignore the char, short, float, etc unless you are dealing with passing a structure to some API
  2. Why are you concerned with 4 bytes?
  3. A Float has ~7 digits of accuracy. so a (5 digit broker's) JPY price has 100.001 has 6 digits. Do you really want to loose precision on price?
  4. a float will be cast to double and passed to DoubleToStr.
mar
1143
mar 2014.05.16 05:42  

Ok, then I will forget about optimizing the code. My idea was to get more familiar with the new MQL4 and therefore I wanted my old indicators to be adapted to new MQL4. My girl-friend is learning Java at the university right now and we talked about different data types and how to cast them. That was the reason why I generally thought about optimizing my code. I didn't know that Float has ~7 digits of accuracy. So you are absolutely right not to use it.

Thanks!

Halley
198
Halley 2014.05.16 08:27  
mar:

Ok, then I will forget about optimizing the code. My idea was to get more familiar with the new MQL4 and therefore I wanted my old indicators to be adapted to new MQL4. My girl-friend is learning Java at the university right now and we talked about different data types and how to cast them. That was the reason why I generally thought about optimizing my code. I didn't know that Float has ~7 digits of accuracy. So you are absolutely right not to use it.

Thanks!


Even the Java developers have a saying "first make it working then optimize - if you still have time left" :)
/
To add comments, please log in or register