This forum is in read-only mode now. You may discuss your questions on forums of MQL4.community and MQL5.community

iCCI problem in strategy tester


Back to topics list
avatar
10
thebts 2007.06.23 14:21 
I have an ea that is using iCCI function.
If I put the ea on daily period in the tester and i use a 1 hour timeframe in iCCI then it allways returns 0. It does the same for 4 hour as well.
I am using build 206 dated 6th June.
here is a cut down version of what i do that reproduces the problem:

#property copyright ""
#property link      ""
int init()
{
 return(0);
}
int deinit()
{
   return(0);
}
int start()
{
   double cci = iCCI(NULL, PERIOD_H1, 7, PRICE_TYPICAL, 1);
   Comment(DoubleToStr(cci,4));
   return(0);
}


avatar
4464
Slawa 2007.06.25 11:13 
Make sure that h1 chart is open.
Try to comment returned value from GetLastError() function
avatar
10
thebts 2007.06.25 14:18 
Not sure what you mean by "make sure h1 chart is open"

It is in strategy tester as i said, not in normal operation. Visual mode is on - that's how i can see the comments. As i said period is Daily or H4.

How do i open H1 chart in strategy tester when it is doing a daily or H4 test?

i added your getlasterror. it says it was error 4054

Make sure that h1 chart is open.
Try to comment returned value from GetLastError() function
avatar
4464
Slawa 2007.06.25 14:34 
It means "just open h1 chart". And note that your h1 data can cover not all daily data. (for example daily data begins from 1999.01.01 and hourly data begins from 2004.01.01)
avatar
10
thebts 2007.06.25 15:40 
But doesn't the strategy tester user fractals to fill in the missing data so that it behaves like ticks?

If it works like you say then there must be another function that will tell you if you have enough data to call an indicator.


It means "just open h1 chart". And note that your h1 data can cover not all daily data. (for example daily data begins from 1999.01.01 and hourly data begins from 2004.01.01)
avatar
4464
Slawa 2007.06.25 16:19 
avatar
10
thebts 2007.06.26 00:47 
These articles do not answer the question that this issue has led me to which is:

In an ea how do i test if an indicator will have enough data to succeed?


avatar
3289
Rosh 2007.06.26 09:40 
Attach this EA:

//+------------------------------------------------------------------+
//|                                                       thebts.mq4 |
//|                      Copyright © 2007, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.ru/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/forum/3132//"

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
  string CommString;
  int err;
//----
   double cci = iCCI(NULL, PERIOD_H1, 7, PRICE_TYPICAL, 1);
   CommString=DoubleToStr(cci,4);
   err=GetLastError();
   if (err!=0)  CommString=StringConcatenate(CommString,"  error code = ", err);
   Comment(CommString);
//----
   return(0);
  }
//+------------------------------------------------------------------+



avatar
10
thebts 2007.06.26 14:14 
And do what?
I already did this. That's how i knew it was error 4054.
It does not answer my question unless you are suggesting that i check the get last error every time i call an indicator. This is a very bad anti pattern.
I should either be able to test the data somehow or i should be able to do a try/catch (yes i know try/catch is not part of the language).



Attach this EA:

//+------------------------------------------------------------------+
//|                                                       thebts.mq4 |
//|                      Copyright © 2007, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.ru/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/forum/3132//"

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
  string CommString;
  int err;
//----
   double cci = iCCI(NULL, PERIOD_H1, 7, PRICE_TYPICAL, 1);
   CommString=DoubleToStr(cci,4);
   err=GetLastError();
   if (err!=0)  CommString=StringConcatenate(CommString,"  error code = ", err);
   Comment(CommString);
//----
   return(0);
  }
//+------------------------------------------------------------------+



avatar
3289
Rosh 2007.06.26 14:49 
It's very strange. My backtest in visual mode pass done. See picture.



Without visual mode back testing also correct as well. Did you have H1 time frame history on your hard disk?
Back to topics list  
Download MetaTrader 5 (450 Kb, web installer) — a new terminal for financial markets