Hi !
So I created a simple Itchimoku strategy, with 5 iCustom functions.
Unfortunately, although all values printed from iCustom functions work correctly, one "Itchim4", which is supposed to print a certain value of S&P500, prints "0" at the beginning. ( I have attached screenshot if these values below in the "Przechwytywanie.PNG" file).
Could you please help me with removing the 0 from the result?
I did not run your code but it looks like the line which prints is:
Print("Ichimoku = ",Itchim0," ",Itchim1," ",Itchim2," ",Itchim3," ",Itchim4,"",Itchim5);
I suggest you use PrintFormat - more control over decimals, field width, leading 0's, sign etc. It is all in the documentation but here is an example:
#define def_decimalPlaces 3 PrintFormat("Ichimoku = %+.*f %+.*f %+.*f %+.*f %+.*f %+.*f", def_decimalPlaces, Itchim0, def_decimalPlaces, Itchim1, def_decimalPlaces, Itchim2, def_decimalPlaces, Itchim3, def_decimalPlaces, Itchim4, def_decimalPlaces, Itchim5 );
Asterisk has been broken in MT4 for a very long time. | PrintFormat("<%.*f>", 4, 0.1234567); // testscr: < .*f> |
Asterisk work around. | string format=StringFormat("<%%.%if>", 4); PrintFormat(format, 0.1234567); // testscr: <0.1235> |
or | string format="<%."+string(Digits())+"f>"; PrintFormat(format, 0.1234567); // testscr: <0.12346> |
Thank you for your reply!
I applied your advice and it works correctly in every case, apart from the "Itchim4" function, so the value which I have been struggling with from the beginning.
Here, the PrintFormat prints value: "0.0000".
Do you have maybe any other ideas on how to delete the 0, which is printed before the correct value?
Hi !
So I created a simple Itchimoku strategy, with 5 iCustom functions.
Unfortunately, although all values printed from iCustom functions work correctly, one "Itchim4", which is supposed to print a certain value of S&P500, prints "0" at the beginning. ( I have attached screenshot if these values below in the "Przechwytywanie.PNG" file).
Could you please help me with removing the 0 from the result?
Print("Ichimoku = ",Itchim0," ",Itchim1," ",Itchim2," ",Itchim3," ",Itchim4,"",Itchim5);
It prints 0 for Itchim4, then it prints 4069.775 for Itchim5. There is no space between the 2 numbers.
Can I just add the importance of using meaningful variable names in your codes, especially when you want other people's help.
Itchim0=iCustom(NULL,0,"Ichimoku",7,24,46,0,0); Itchim1=iCustom(NULL,0,"Ichimoku",7,24,46,1,0); Itchim2=iCustom(NULL,0,"Ichimoku",7,24,46,2,0); Itchim3=iCustom(NULL,0,"Ichimoku",7,24,46,3,0); Itchim4=iCustom(NULL,0,"Ichimoku",7,24,46,4,0); Itchim5=iCustom(NULL,0,"Ichimoku",7,24,46,5,0); Print("Ichimoku = ",Itchim0," ",Itchim1," ",Itchim2," ",Itchim3," ",Itchim4,"",Itchim5);
These variable names are not helpful as you are unlikely to remember what they represent especially if they are used later in your code.
Usually when I see something like this, I will read no further.
With itchimoku you should use the obvious variable names like kijun, tenkan, spanA etc.
That way you know instantly what they represent and the code is much easier to read.
Also, when printing it is better to do
Print("kijun=",kijun," tenkan=",tenkan); //etc
You would have spotted your error immediately.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi !
So I created a simple Itchimoku strategy, with 5 iCustom functions.
Unfortunately, although all values printed from iCustom functions work correctly, one "Itchim4", which is supposed to print a certain value of S&P500, prints "0" at the beginning. ( I have attached screenshot if these values below in the "Przechwytywanie.PNG" file).
Could you please help me with removing the 0 from the result?