Problem with Moving Average

 

Hi I tryed to show the value of moving averge, I used this: 

 double maValueH4 = iMA(_Symbol, PERIOD_H4, 50,0,  MODE_SMA, PRICE_CLOSE);
 double maValueH1 = iMA(_Symbol, PERIOD_H1, 50,0,MODE_SMA, PRICE_CLOSE);
 double maValueM30 = iMA(_Symbol, PERIOD_M30, 50,0, MODE_SMA, PRICE_CLOSE);
 double maValueM15 = iMA(_Symbol, PERIOD_M15, 50,0, MODE_SMA, PRICE_CLOSE);
 double maValueM5 = iMA(_Symbol, PERIOD_M5, 50,0, MODE_SMA, PRICE_CLOSE);
 
 string stringmaValueH4 = DoubleToString(maValueH4,8);
 string stringmaValueH1 = DoubleToString(maValueH1,8);
 string stringmaValueM30 = DoubleToString(maValueM30,8);
 string stringmaValueM15 = DoubleToString(maValueM15,8);
 string stringmaValueM5 = DoubleToString(maValueM5,8);

     
  ObjectSetString(0, "maH4", OBJPROP_TEXT, "MA H4:  " +  stringmaValueH4);
  ObjectSetInteger(0, "maH4", OBJPROP_COLOR, clrGreen);
  
  ObjectSetString(0, "maH1", OBJPROP_TEXT, "MA H1:  " + stringmaValueH1);
  ObjectSetInteger(0, "maH1", OBJPROP_COLOR, clrGreen);
  
  ObjectSetString(0, "maM30", OBJPROP_TEXT, "MA M30:  " + stringmaValueM30);
  ObjectSetInteger(0, "maM30", OBJPROP_COLOR, clrGreen);
  
  ObjectSetString(0, "maM15", OBJPROP_TEXT, "MA M15:  " + stringmaValueM15);
  ObjectSetInteger(0, "maM15", OBJPROP_COLOR, clrGreen);
  
  ObjectSetString(0, "maM5", OBJPROP_TEXT, "MA M5:  " + stringmaValueM5);
  ObjectSetInteger(0, "maM5", OBJPROP_COLOR, clrGreen);
  

and the result is14.00000


but it shuold be like: 1,2543

what is wrong?

Moving Average - Trend Indicators - Technical Indicators - Price Charts, Technical and Fundamental Analysis - MetaTrader 5 Help
  • www.metatrader5.com
The Moving Average Technical Indicator shows the mean instrument price value for a certain period of time. When one calculates the moving average...
Files:
Bez_tytuzu.jpg  17 kb
 
pietramarek: Hi I tryed to show the value of moving averge, I used this:  and the result is14.00000 but it shuold be like: 1,2543 what is wrong?

Is this ChatGPT code? If so, please, don't request help for ChatGPT (or other A.I.) generated code. It generates horrible code, mixing MQL4 and MQL5.

In MQL5, Indicator functions return a handle (int), not a data value (double). You must use CopyBuffer to obtain the data values.

Please reference the documentaion:

Reason: