iCustom delivers wrong values - page 2

 

The Data window reports the bar's value at mouse point/hover. While the Journal will print at incoming tick. Not a good idea (a poor choice) when the values you want to see comes from a loop. The journal tab will certainly lags & shows an unfinished data on top of unfinished data.

Have a look at the same problem a while back. Hope it helps.

PS: Double check also that your iCustom quantity & inputs in indicator match those in the EA.

 
cameofx:

The Data window reports the bar's value at mouse point/hover. While the Journal will print at incoming tick. Not a good idea (a poor choice) when the values you want to see comes from a loop. The journal tab will certainly lags & shows an unfinished data on top of unfinished data.

Have a look at the same problem a while back. Hope it helps.

PS: Double check also that your iCustom quantity & inputs in indicator match those in the EA.


Hi cameofx,

thanks for answering, my problem is a little bit different. I printed my indicator values at Bar3. However in the Data Windows with the mouse point on same bar as the printout, the values are differents. I thought that if I print for example tha value iCustom(NULL,0,"My Indicator",0,3) at 02:25 in a 5 min chart and compare it with Data Window at 2:10 the values should match. In my case it doesn't. Am I wrong?

 

thanks for answering, my problem is a little bit different. I printed my indicator values at Bar3. However in the Data Windows with the mouse point on same bar as the printout, the values are differents. I thought that if I print for example tha value iCustom(NULL,0,"My Indicator",0,3) at 02:25 in a 5 min chart and compare it with Data Window at 2:10 the values should match. In my case it doesn't. Am I wrong?

To my knowledge, the time on the left side of the Journal doesn't correlate with the 'Bar Time' (i.e. the 5 min bar Open time) if that's what's you meant.

Try this instead:

Since we need to make sure we're comparing values of the same bar from both the EA and Indy, print the bar count/index and the TimeToStr(Time[i],TIME_DATE|TIME_SECONDS); along with the values. And the Open[i] value for comparison control.
Don't forget to NormalizeDouble the values to the same digits.

Of course also 'label' them with 'EA' or 'Indy'. Then print them both either with Alert() or Print().
[Added] Don't print inside a loop with 'i' !! But print just the index you need (3).

The point is to make a valid comparison.

 
cameofx:

To my knowledge, the time on the left side of the Journal doesn't correlate with the 'Bar Time' (i.e. the 5 min bar Open time) if that's what's you meant.

Try this instead:

Since we need to make sure we're comparing values of the same bar from both the EA and Indy, print the bar count/index and the TimeToStr(Time[i],TIME_DATE|TIME_SECONDS); along with the values. And the Open[i] value for comparison control.
Don't forget to NormalizeDouble the values to the same digits.

Of course also 'label' them with 'EA' or 'Indy'. Then print them both either with Alert() or Print().
[Added] Don't print inside a loop with 'i' !! But print just the index you need (3).

The point is to make a valid comparison.


That is what I did, I didn't used the journal for comparisons, I prit it to a file, then compared for same time. Let me show you the printed file and attached is the indicator. After running go to the Data Window and compare boths results for same time. In my chart they are differents.

2010.09.17 - 02:45:00 - - - *******************New Bar************************************
2010.09.17 - 02:45:00 - - - upper1=1.30910 lower1=1.30769
2010.09.17 - 02:45:00 - - - open1=1.30807 high1=1.30954
2010.09.17 - 02:45:00 - - - low1=1.30804 close1=1.30929
2010.09.17 - 02:45:00 - - - upper2=1.30813 lower2=1.30708
2010.09.17 - 02:45:00 - - - open2=1.30801 high2=1.30840
2010.09.17 - 02:45:00 - - - low2=1.30790 close2=1.30805
2010.09.17 - 02:45:00 - - - upper3=1.30795 lower3=1.30700
2010.09.17 - 02:45:00 - - - open3=1.30765 high3=1.30822
2010.09.17 - 02:45:00 - - - low3=1.30756 close3=1.30800
2010.09.17 - 02:50:00 - - - *******************New Bar************************************
2010.09.17 - 02:50:00 - - - upper1=1.30920 lower1=1.30764
2010.09.17 - 02:50:00 - - - open1=1.30928 high1=1.30939
2010.09.17 - 02:50:00 - - - low1=1.30889 close1=1.30908
2010.09.17 - 02:50:00 - - - upper2=1.30910 lower2=1.30769
2010.09.17 - 02:50:00 - - - open2=1.30807 high2=1.30954
2010.09.17 - 02:50:00 - - - low2=1.30804 close2=1.30929
2010.09.17 - 02:50:00 - - - upper3=1.30813 lower3=1.30708
2010.09.17 - 02:50:00 - - - open3=1.30801 high3=1.30840
2010.09.17 - 02:50:00 - - - low3=1.30790 close3=1.30805
2010.09.17 - 02:55:00 - - - *******************New Bar************************************
2010.09.17 - 02:55:00 - - - upper1=1.30925 lower1=1.30759
2010.09.17 - 02:55:00 - - - open1=1.30907 high1=1.30939
2010.09.17 - 02:55:00 - - - low1=1.30859 close1=1.30892
2010.09.17 - 02:55:00 - - - upper2=1.30920 lower2=1.30764
2010.09.17 - 02:55:00 - - - open2=1.30928 high2=1.30939
2010.09.17 - 02:55:00 - - - low2=1.30889 close2=1.30908
2010.09.17 - 02:55:00 - - - upper3=1.30910 lower3=1.30769
2010.09.17 - 02:55:00 - - - open3=1.30807 high3=1.30954
2010.09.17 - 02:55:00 - - - low3=1.30804 close3=1.30929
2010.09.17 - 03:00:00 - - - *******************New Bar************************************

This is my start() in the EA.

int start()
  {
       double upper1,lower1,open1,high1,low1,close1;
       double upper2,lower2,open2,high2,low2,close2;
       double upper3,lower3,open3,high3,low3,close3;       
       RefreshRates();
      bool New_Bar;
      New_Bar=IsNewBar();
      if (New_Bar)
       { 
         upper1=NormalizeDouble(iCustom(NULL,0,"Simple Donchian Std Dev",periods,shift,BandPeriod,const,1,1),Digits);
         lower1=NormalizeDouble(iCustom(NULL,0,"Simple Donchian Std Dev",periods,shift,BandPeriod,const,2,1),Digits); 
         open1=NormalizeDouble(iOpen(NULL,0,1),Digits);
         high1=NormalizeDouble(iHigh(NULL,0,1),Digits);
         low1=NormalizeDouble(iLow(NULL,0,1),Digits);
         close1=NormalizeDouble(iClose(NULL,0,1),Digits);
                          
         upper2=NormalizeDouble(iCustom(NULL,0,"Simple Donchian Std Dev",periods,shift,BandPeriod,const,1,2),Digits);
         lower2=NormalizeDouble(iCustom(NULL,0,"Simple Donchian Std Dev",periods,shift,BandPeriod,const,2,2),Digits); 
         open2=NormalizeDouble(iOpen(NULL,0,2),Digits);
         high2=NormalizeDouble(iHigh(NULL,0,2),Digits);
         low2=NormalizeDouble(iLow(NULL,0,2),Digits);           
         close2=NormalizeDouble(iClose(NULL,0,2),Digits);
         
         upper3=NormalizeDouble(iCustom(NULL,0,"Simple Donchian Std Dev",periods,shift,BandPeriod,const,1,3),Digits);
         lower3=NormalizeDouble(iCustom(NULL,0,"Simple Donchian Std Dev",periods,shift,BandPeriod,const,2,3),Digits); 
         open3=NormalizeDouble(iOpen(NULL,0,3),Digits);
         high3=NormalizeDouble(iHigh(NULL,0,3),Digits);
         low3=NormalizeDouble(iLow(NULL,0,3),Digits);           
         close3=NormalizeDouble(iClose(NULL,0,3),Digits);         
                
         log("*******************New Bar************************************"); 
         log("upper1="+DoubleToStr(upper1,Digits)+" lower1="+DoubleToStr(lower1,Digits));
         log("open1="+DoubleToStr(open1,Digits)+" high1="+DoubleToStr(high1,Digits));
         log("low1="+DoubleToStr(low1,Digits)+" close1="+DoubleToStr(close1,Digits));
         log("upper2="+DoubleToStr(upper2,Digits)+" lower2="+DoubleToStr(lower2,Digits));
         log("open2="+DoubleToStr(open2,Digits)+" high2="+DoubleToStr(high2,Digits));
         log("low2="+DoubleToStr(low2,Digits)+" close2="+DoubleToStr(close2,Digits)); 
         log("upper3="+DoubleToStr(upper3,Digits)+" lower3="+DoubleToStr(lower3,Digits));
         log("open3="+DoubleToStr(open3,Digits)+" high3="+DoubleToStr(high3,Digits));
         log("low3="+DoubleToStr(low3,Digits)+" close3="+DoubleToStr(close3,Digits));                                          
       }// if (New_Bar)      
   return(0);
  }
//+------------------------------------------------------------------+
 

Try these on M1... they confirmed identical values on my test. Whenever I need to verify something I usually stripped it down to one buffer like this & work my way to more array/variable etc. Hope this helps.

//+------------------------------------------------------------------+
//|                                                   Test1 - EA.mq4 |
//+------------------------------------------------------------------+

extern string IndyName = "Test1 - Indy";
extern int    IndyPeriod = 5;
extern int    BarToCheck = 3;
extern int    AddPrecision = 2;

int start()
{
   double dValue, dOpen;
   string sTime;
      
      dValue = NormalizeDouble(iCustom(NULL,0,IndyName,IndyPeriod,0,BarToCheck),
                               Digits+AddPrecision);
      dOpen  = NormalizeDouble(iOpen(NULL,0,BarToCheck),Digits+AddPrecision);
      sTime  = TimeToStr(iTime(NULL,0,BarToCheck),TIME_DATE|TIME_SECONDS);
      
   if (NewBar())
      Alert ( "=============== NEW BAR! =================");   

      Alert ( "==========================================");   
      Alert
      (  
         "EA ---- BarToCheck : " + BarToCheck + 
         " / Open : " +
         DoubleToStr(dOpen,Digits+AddPrecision) + 
         " / VALUE : " +
         DoubleToStr(dValue,Digits+AddPrecision) + 
         " / Time[" + BarToCheck +"] : " + sTime
      );

   return(0);
}
//+------------------------------------------------------------------+
bool NewBar()
{
   static int lastTime;
   if (lastTime != Time[0]) 
   { lastTime = Time[0]; return(true); }
   return(false);
}

PS : Make sure the Indy file name matches, attaching file names without underscore gets renamed I forgot.

PPS : I use Alert() with sound disabled. Tools >> Options >> Evants >> untick 'Enable' box.

Files:
 
cameofx:

Try these on M1... they confirmed identical values on my test. Whenever I need to verify something I usually stripped it down to one buffer like this & work my way to more array/variable etc. Hope this helps.

PS : Make sure the Indy file name matches, attaching file names without underscore gets renamed I forgot.

PPS : I use Alert() with sound disabled. Tools >> Options >> Evants >> untick 'Enable' box.


Thank you, nice tool. I can see there is no errors in the values that the indicator return to the alert window. So, what is causing the wrong values ended up in the log file? Is it some kind of delay? Is Alert faster than Print? Can you shed some light on this.
Reason: