MT5 In-built functions (ie. iCCI, iStdDev, iMA) do not work. Please help!

 
Hi MQL5 Community, 

I'm stuck in a slump. I'm new to creating EAs, and while attempting to put something together I noticed that the iCCI(), iStdDev(), and iMA() in-built methods do not change values over time during back testing. 

To further isolate the issue, the back testing was run over this very simple EA 'test 00.mq5' and prints values for the above per tick. These values do not match the visual on-chart indicators at all.

A few details (could be irrelevant) about my account and configurations for backtesting: 

  • Account Type: Demo on AdmiralMarkets-Demo
  • Timeframe: 15 minute
  • Date: Custom period - 2023.04.01 - 2024.01.30
  • Forward: No
  • Delays: 20 ms
  • Modelling: Every tick based on real ticks
  • Deposit: 10000, Leverage: 1:50
  • Optimization: Disabled, Visual Mode: Yes 

They also return the same values over time in Journal, snippet of Journal is attached below. Here is a sample message: 

 "2024.02.02 15:00:27.503       2023.04.05 00:12:41   cciValue: 10.0 stdDev: 11.0 SMA: 12.0")

This is the script. 

//+------------------------------------------------------------------+
//|                                                      Test 00.mq5 |
//|                                  Copyright 2024, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2024, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   double cciValue_indicator = iCCI(_Symbol, PERIOD_M15, 50, PRICE_TYPICAL);
   double stdDev = iStdDev(_Symbol, PERIOD_M15, 50, 0, MODE_SMA, PRICE_CLOSE);
   double SMA = iMA(_Symbol, PERIOD_M15, 50, 0, MODE_SMA, NULL);
   
   Print("cciValue: ", cciValue_indicator, "stdDev: ", stdDev, "SMA: ", SMA);
   
   
//---
  }

I was hoping some of you experts could answer my questions: 

  1. What are the in-built functions dependent on? (ie. "Quality" of broker data?)
  2. Why do they keep outputting the same values over time?
  3. How can I fix this issue? 
Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • 2024.02.02
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
Files:
 
Cosmic Wang:
Hi MQL5 Community, 

I'm stuck in a slump. I'm new to creating EAs, and while attempting to put something together I noticed that the iCCI(), iStdDev(), and iMA() in-built methods do not change values over time during back testing. 

To further isolate the issue, the back testing was run over this very simple EA 'test 00.mq5' and prints values for the above per tick. These values do not match the visual on-chart indicators at all.

A few details (could be irrelevant) about my account and configurations for backtesting: 

  • Account Type: Demo on AdmiralMarkets-Demo
  • Timeframe: 15 minute
  • Date: Custom period - 2023.04.01 - 2024.01.30
  • Forward: No
  • Delays: 20 ms
  • Modelling: Every tick based on real ticks
  • Deposit: 10000, Leverage: 1:50
  • Optimization: Disabled, Visual Mode: Yes 

They also return the same values over time in Journal, snippet of Journal is attached below. Here is a sample message: 

This is the script. 

I was hoping some of you experts could answer my questions: 

  1. What are the in-built functions dependent on? (ie. "Quality" of broker data?)
  2. Why do they keep outputting the same values over time?
  3. How can I fix this issue? 
The compiler is giving you warnings, respect them.

To fix your issue:
Read the manual.

And:
 
Dominik Egert #:
The compiler is giving you warnings, respect them.

To fix your issue:
Read the manual.

And:
I absolutely do respect feedback from the compiler. However, the compiler has not given me any warnings. But I appreciate the links to the documentation. Cheers Dominik. 
 
Dominik Egert #:
The compiler is giving you warnings, respect them.

To fix your issue:
Read the manual.

And:
Upon reading the documentation, I believe I've correctly applied the use of these methods in OnTick(). Do you have any other feedback that could be helpful? 

Cheers. 
 
Cosmic Wang #:
Upon reading the documentation, I believe I've correctly applied the use of these methods in OnTick(). Do you have any other feedback that could be helpful? 

Cheers. 
This is giving warnings (on MQL5):
double SMA = iMA
EDIT:

You are not reading the documentation.

These functions give a handle, you use the handle in CopyBuffer to get the data.

You create the handle only once, usually in OnInit.
 
Dominik Egert #:
This is giving warnings (on MQL5):
EDIT:

You are not reading the documentation.

These functions give a handle, you use the handle in CopyBuffer to get the data.

You create the handle only once, usually in OnInit.
Okay, I did not understand the documentation. I have implemented the technical indicators correctly with the appropriate CopyBuffer to retrieve the data I need, thank you so much for leading me in the right direction!