Questions from Beginners MQL5 MT5 MetaTrader 5 - page 631

 
Artyom Trishkin:
I have a hard time looking at the code on a tablet, but the answer is - write the value of X in the buffer.

Recorded. It works. How to get five decimal places in the indicator in the calculations, as in the terminal of the broker five-digit quote bid and ask prices five-digit to be and in the display of their indicator? A screenshot is attached.

I have got five characters in comments on the left with white characters on the screen by the code: (but in indicator when I fill buffers, it still shows four digits NormalizeDouble (ExtMapBuffer2[0],Digits) - does not help.

  Comment(
              "tickCounter = ", tickCounter, "\n",
              "secondCounter, time_s  = ",    NormalizeDouble(time_s,2) , "\n",
            
              "ExtMapBuffer1[0] = ", DoubleToStr(ExtMapBuffer1[0],Digits) , "\n",
              "ExtMapBuffer2[0] = ", DoubleToStr(ExtMapBuffer2[0],Digits) , "\n",
              "ExtMapBuffer1[1] = ", DoubleToStr(ExtMapBuffer1[1],Digits) , "\n",
              "ExtMapBuffer2[1] = ", DoubleToStr(ExtMapBuffer2[1],Digits) , "\n",
              "ExtMapBuffer1[2] = ", DoubleToStr(ExtMapBuffer1[2],Digits) , "\n",
              "ExtMapBuffer2[2] = ", DoubleToStr(ExtMapBuffer2[2],Digits) , "\n",


 
Roman Shiredchenko:

Recorded. It works. How to get the indicator to display five decimal places in calculations, as in the broker's terminal five-digit quote bid and ask prices to be five-digit and in their indicator display? A screenshot is attached.

I tried to show five-digit quotes in the left comment with white symbols on the screen. (But in the indicator when I fill the buffers, it still shows four digits NormalizeDouble (ExtMapBuffer2[0],Digits) - does not help.


IndicatorSetInteger(INDICATOR_DIGITS,_Digits);

or

IndicatorDigits(_Digits);

 

And here, for average speed specifically indicated filling the indicator array ExtMapBuffer_Ave_Speed[0]= NormalizeDouble(X,1);

But it still draws zeros to 4 decimal places... How do I make it display five decimal places?

 
Alexey Viktorov:

IndicatorSetInteger(INDICATOR_DIGITS, _Digits);

or

IndicatorDigits(_Digits);

Senc. It's all working!
 
Roman Shiredchenko:
Cenk. It's all working!
Sorry I forgot to put it in OnInit()
 
Alexey Viktorov:
Sorry I forgot to put it in OnInit()

It turns out we have a "reply" queue here ;)

Didn't have time...

 
Alexey Viktorov. Artyom Trishkin
Sorry, I forgot to write it in OnInit()

That's understandable. Senc. Maybe you can give me a hint...

The MA has been applied to tick indicator from the terminal navigator. How do I get its values in the EA?

If you can just poke your nose in where to read about it.

I seem to recall... through iMAOnArray?


 
Roman Shiredchenko:

That's understandable. Senc. There may be some other tips...

The MA is applied from the terminal navigator to the tick indicator. How to get its values in the Expert Advisor?

You may just poke your nose where to read about it.

I seem to recall... through iMAOnArray?


iMAOnArray should be entered in the tick indicator and output in it in the additional buffer.

Or, in a new indicator, first you should read the contents of the tick indicator buffers into the calculation buffer, and then put iMAOnArray on it.

 
Artyom Trishkin:

1. iMAOnArray should be written into tick indicator and output in it into additional buffer.

Or, in a new indicator, first you should read the contents of tick indicator buffers into the calculation buffer, and then apply iMAOnArray to it.

Thank you. Artyom. So 1.
 

I cannot achieve equality of MA (colour Gold) period 1 values (on the chart) from Bid (green - it is not visible because of the MA line) and its same MA (1) values calculated via iMAonArray() from the Bid price indicator buffer.

      double MA_0=iMAOnArray(ExtMapBuffer1,0,MA_Period,0,MODE_EMA,0); 
      double MA_1=iMAOnArray(ExtMapBuffer1,0,MA_Period,0,MODE_EMA,1); 
      double MA_2=iMAOnArray(ExtMapBuffer1,0,MA_Period,0,MODE_EMA,2); 
   
       


     if (time_s!=0) 
       Comment(
              "tickCounter = ", tickCounter, "\n",
              "secondCounter, time_s  = ",    NormalizeDouble(time_s,2) ,   "\n",
            
           ...
              "ExtMapBuffer_MA[0] = ", DoubleToStr(MA_0,Digits),"\n",
              "ExtMapBuffer_MA[1] = ", DoubleToStr(MA_1,Digits),"\n",
              "ExtMapBuffer_MA[2] = ", DoubleToStr(MA_2,Digits),"\n",

green arrows - equal values - as they should be. Red arrows - different values. Should be the same as the green ones.


the top three arrows should have numbers ONE, but they are different... Can you tell me the reason for the discrepancy...


Reason: