Issue with CHIKOUSPAN_LINE

 
ichiHandle=iIchimoku(NULL,0,tenkan_sen,kijun_sen,senkou_span_b);

/////////////////////////////////////

double GetIchi(const int buffer,const int index)
  {

   double Ichimoku[1];
   ResetLastError();

   if(CopyBuffer(ichiHandle,buffer,index,1,Ichimoku)<0)
     {
      return(0.0);
     }
   return(Ichimoku[0]);
  }

double Chiko=GetIchi(CHIKOUSPAN_LINE,1);
double Ten=GetIchi(TENKANSEN_LINE,1);

Hi

I have this code and tenkan(and other lines) give me a right number like: 1796.84000000 but chiko line give me weird number like this:

1797837654782487239838475546179126438923985281308142746314871387413629181284137038568723562825372865487563487564785634785638756873465873465837465837456837456873456834756837456834756348756381476534865.000000


What is the problem?

 
Ali D32:
ichiHandle=iIchimoku(NULL,0,tenkan_sen,kijun_sen,senkou_span_b); ///////////////////////////////////// double GetIchi(const int buffer,const int index)   {    double Ichimoku[1];    ResetLastError();    if(CopyBuffer(ichiHandle,buffer,index,1,Ichimoku)<0)      {       return(0.0);      }    return(Ichimoku[0]);   } double Chiko=GetIchi(CHIKOUSPAN_LINE,1); double Ten=GetIchi(TENKANSEN_LINE,1);

Good-looking code!

NOTE: Traders and coders are working for free:

  • if it is interesting for them personally, or
  • if it is interesting for many members on this forum.

Freelance section of the forum should be used in most of the cases.

Trading applications for MetaTrader 5 to order
Trading applications for MetaTrader 5 to order
  • 2024.12.12
  • www.mql5.com
The largest freelance service with MQL5 application developers
 
Oleksandr Medviediev #:

Good-looking code!

NOTE: Traders and coders are working for free:

  • if it is interesting for them personally, or
  • if it is interesting for many members on this forum.

Freelance section of the forum should be used in most of the cases.

Iam programmer and i don't want to order ea. i just have a simple question.

I am confused. should i ask my question in other section?

 
Ali D32 #: I am confused. should i ask my question in other section?

Please show how you are outputting that number. Your code only shows how you are obtaining it, not how you are outputting it.

If possible, provide sample code that can compile and be run by others to replicate the issue.

 
Fernando Carreiro #:

Please show how you are outputting that number. Your code only shows how you are obtaining it, not how you are outputting it.

If possible, provide sample code that can compile and be run by others to replicate the issue.

Just print

Print("Ten: " + DoubleToString(Ten));
Print("Chiko: " + DoubleToString(Chiko));


I create a test ea, put the complete code on it.

Files:
Test.mq5  2 kb
 
Ali D32 #: Just print. I create a test ea, put the complete code on it.

Please show your own log output results first so we can see what you are getting, Show a screenshot of the chart and log output, and remember to inform us of which Symbol and Timeframe you are using it on.

 
Fernando Carreiro #:

Please show your own log output results first so we can see what you are getting, Show a screenshot of the chart and log output, and remember to inform us of which Symbol and Timeframe you are using it on.

I sent complete source of EA, Did you see that? output is ok for you?

it's my output:

metatrader 5

XAUUSD M30

output

 
Ali D32 #: I sent complete source of EA, Did you see that? output is ok for you? it's my output:  metatrader 5 XAUUSD M30

At bar shift 1, there is no "Chikou Span". Based on your Indicator parameters, it is only present at bar shift 26 onwards.

int g_hIchimoku;

int OnInit() {
   g_hIchimoku = iIchimoku( _Symbol, _Period, 9, 26, 52 );
   if( g_hIchimoku == INVALID_HANDLE ) return INIT_FAILED;
   return INIT_SUCCEEDED;
};

double GetIchimoku( const int nBuffer, const int nIndex ) {
   if( BarsCalculated( g_hIchimoku ) > 1 ) {
      double adbIchimoku[ 1 ];
      if( CopyBuffer( g_hIchimoku, nBuffer, nIndex, 1, adbIchimoku ) > 0 )
        return adbIchimoku[ 0 ];
   };
   return EMPTY_VALUE;
  }

void OnTick() {
   double dbTenkansenLine = GetIchimoku( TENKANSEN_LINE,   1 ),
          dbChikouSpan    = GetIchimoku( CHIKOUSPAN_LINE, 26 );
   Print( "Tenkansen Line: ", dbTenkansenLine );
   Print( "Chikou Span:    ", dbChikouSpan    );
};


 
Fernando Carreiro #:

At bar shift 1, there is no "Chikou Span". Based on your Indicator parameters, it is only present at bar shift 26 onwards.


My BAD!

thought shift is index of chiko line and start from 0.

Thank you for your attention