Value of Indicator in EA is far different from indicator on chart

 

HI

I'm new in MQL5 programming 

I start writing EA based on Ichimoku indicator signal

but the output of the EA for Ichimoku parameter is far different from indicator values on chart

my code just for test is as below

//+------------------------------------------------------------------+
//|                                                     Ichimoku.mq5 |
//|                                  Copyright 2022, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
int Ichimoku;
int FileHandler;
double Tenkan_sen[];
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   Ichimoku=iIchimoku(NULL,PERIOD_CURRENT,9,26,52);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   CopyBuffer(Ichimoku,0,0,100,Tenkan_sen);
   Print("Tenken-sen Value is = "+Tenkan_sen[0]);
  }
//+------------------------------------------------------------------+
 
You need to set ArraySetAsSeries to true. In OnInit
 
pennyhunter #:
You need to set ArraySetAsSeries to true. In OnInit
Thank a lot
 
Tenkan_sen[0]

Is a value 99 bars ago

Tenkan_sen[99]

Is the current value