Problem using iCustom in EA and using it on the Chart - different results.

 

Hello, I know this is not a new question but I still don't get it how this can be. I need help.

I use iCustom to retrieve a result from a indicator. For example see the code below. 

void OnStart()
  {
//---
   
   double TrendTest = iCustom(NULL, PERIOD_CURRENT, "super_trend", 10, 3,7,0);
   double TrendTest2 = iCustom(NULL, PERIOD_CURRENT, "super_trend", 10, 3,7,10);
   Print("TrentTest 1: ",TrendTest);
   Print("TrentTest 2: ",TrendTest2);
   Alert("TrentTest 1 for buffer 7 current bar: ",TrendTest);
   Alert("TrentTest 2 for buffer 7 bar 10: ",TrendTest2);

However, the result differs from the results the indicator shows on the Chart itself. How do I know what is right. Can any one please explain to me why they differ from each other? What do I miss?

indicator on chart and result test script

Thanks a lot for the time and effort in answering this question.

Erik


<*.ex* file has been deleted>

Files:
super_trend.mq4  11 kb
 

maybe the indicator buffer is the problem because it shows different result on the chart and to the alert

try changing the buffer you should start with zero first.

on the data window:

0 SuperTrend  the buffer is = 0

Value 2 the buffer is = 1

Value 3  the buffer is = 2

Value 4 the buffer is = 3

Value 5 the buffer is = 4

Value 6 the buffer is = 5

Value 7 the buffer is = 6


i hope it works because that's the buffer that i follow when i use custom indicator



   double TrendTest = iCustom(NULL, PERIOD_CURRENT, "super_trend", 10, 3,7,0);
   double TrendTest2 = iCustom(NULL, PERIOD_CURRENT, "super_trend", 10, 3,7,10);
 

Karl thanks for the reply but I thought of that aswell but that doesn't explain the difference! 

Who can help please!!

again indicator on chart and results script

Used script for retrieve the values from the different buffers (i = buffers ; j = bar number):

 for(int i=6;i>=0;i--)
   {
   for(int j=2;j>=0;j--){
   double TrendTest = iCustom(NULL, PERIOD_CURRENT, "super_trend", 10, 3,i,j);
   Print("TrentTest %i: ",TrendTest, "  buffer: ",i, "  bar:", j);
   Alert("TrentTest %i: ",TrendTest, "  buffer: ",i, "  bar:", j);
   }
   };


OnChart the supertrend value = 1.28029

with iCustom the supertrend value = 1.28015


Is there someone who can explain this. Is het possible that there's a difference in moment of calculation - so that there can be a slight difference in price in the current bar? 

 
I still hope that someone can help me. 
Reason: