Download MetaTrader 5

Why Chekou value is always 0 ?

To add comments, please log in or register
AYMERIC75
112
AYMERIC75  

I used the following EA to display the value of Chikou_span at 10:03:03 on August 12th 2014...

double Chinkou_value =iIchimoku(NULL,0,9,26,52, MODE_CHINKOUSPAN, 1);

int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {
//---
   
  }

int start()
{
  
   if (DayOfYear() == 224 && Hour() == 10 && Minute() == 3 && Seconds()==3)
   {
   
      ObjectCreate("name",OBJ_TEXT,0,Time[0],Bid);
      ObjectSetText("name","chikou value =  " + Chinkou_value, 12, "Times NewRoman", Red);
 
   }
     
return 0;
}



and as you can see on the image the value displayed is 0 apparently but you can also see that the value on the graph (the green curve) is obviously not 0...

If you have any idea, you're welcome....

AYMERIC75
112
AYMERIC75  




Sorry i forgot the screen print...

Keith Watford
Moderator
8293
Keith Watford  

It is because the ChinkouSpan is simply the current bid shifted backwards by the Kijun period (default 26). The Object was created when the bar was current, so no value.

So when the bar is current, Chinkou will not have a value. You are checking later, when the chart has moved on by more than the Kijun period, so it now has a value. 

AYMERIC75
112
AYMERIC75  
Thank you but how can i do so that the object created take into acount the bar that appears 26 later ?
AYMERIC75
112
AYMERIC75  
Okay, i guess i must change Time[0] to something else in :
ObjectCreate("name",OBJ_TEXT,0,Time[0],Bid);
AYMERIC75
112
AYMERIC75  

Hm no apparently i must change the last value in the following line to something else,

double Chinkou_value =iIchimoku(NULL,0,9,26,52, MODE_CHINKOUSPAN, 1);

so i replaced the "1" by "26" and i obtain a value but still different that the value of the curve (1.36352 beside 1.33564)

double Chinkou_value =iIchimoku(NULL,0,9,26,52, MODE_CHINKOUSPAN, 26);


So what value should i put to obtain the exact same number of Chinkou on the graph ?

Keith Watford
Moderator
8293
Keith Watford  
AYMERIC:
Thank you but how can i do so that the object created take into acount the bar that appears 26 later ?


You cannot in real time, for that you would need to be able to see into the future.

You have to decide in what way you will use the ChinkouSpan.

Ie look at the last bar in the current chart and describe exactly how you use the ChinkouSpan in your strategy and code accordingly. 

AYMERIC75
112
AYMERIC75  
One of the criteria to get a buying signal with ichimoku is when the ChinkouSpan is above the Bid price, that the way i want to use the ChinkouSpan...
qjol
3245
qjol  
AYMERIC:
One of the criteria to get a buying signal with ichimoku is when the ChinkouSpan is above the Bid price, that the way i want to use the ChinkouSpan...


wrong

the Chinkou Span can never be higher or lower than the current bid

because the Chinkou Span == bid

what you are looking for is:

if (Bid < Close[25])

else if (Bid > Close[25])

or maybe

if (Bid < Low[25])

else if (Bid > High[25])

Keith Watford
Moderator
8293
Keith Watford  
GumRai:


You cannot in real time, for that you would need to be able to see into the future.

You have to decide in what way you will use the ChinkouSpan.

Ie look at the last bar in the current chart and describe exactly how you use the ChinkouSpan in your strategy and code accordingly. 


AYMERIC:
One of the criteria to get a buying signal with ichimoku is when the ChinkouSpan is above the Bid price, that the way i want to use the ChinkouSpan...

I said look at the last bar.

As the last bar does not have any value for the chinkouspan, how can it possibly be higher than the current bid price.

If you are unable to describe exactly how you will use the chinkouspan in real time, then there will be no way that you will be able to use it in your code. 

To add comments, please log in or register