Problems with Ichimoku

 

Hi

Sorry if this is not the correct sub-forum for this question, I am unsure of the exact nature of my issue. Whether it is an indicator issue, strategy tester or MT5.

I have recently had an issue on one symbol, where the Ichimoku indicator does not seem to work as expected. I was running an EA I'm working on, in real time, on a demo account. It has been working on various symbols for over a month. However, yesterday on a new symbol it did something very odd and repeatedly opened and then closed a trade until I shut it down. I should have debugged in real time, but unfortunately I was not able to, so I have been trying to use the strategy tester to see what went wrong. 

When stepping through my code, which works as I would expect for other symbols, this new symbol is giving strange results with the Ichimoku. Values for aspects of the cloud often returning as DBL_MAX for this symbol, where they are fine for other symbols. When I look at the Strategy tester's Ichimoku display it does look 'unformed', the cloud display starts on the right, but Senkou Span B ends before it reaches the current bar, and Senkou Span A only manages to reach the middle of the chart . However, when I check the real time display for the same time period it looks fine.

Possibly irrelevant but I also found that IchimokuIndicator.ChinkouSpan(iBarToUseForProcessing+25) and  IchimokuIndicator.ChinkouSpan(iBarToUseForProcessing) will both return DBL_MAX on various symbols. I now check for the close 25 bars as I cannot rely on Chinkouspan values. 

At the moment I can't see how this would have caused the original problem of multiple trades opening and closing, but I can't test that as the values for Ichimoku are incorrect.   

So I am wondering why the discrepancy between yesterdays real time and the strategy tester for the last few weeks of the same time period? Would would the cloud calculations fail in the strategy tester but work on the real time chart?  


Thank you in advance for those that take the time to reply.

 
  1. It's not returning DBL_MAX, it's returning EMPTY_VALUE. Different meaning, same value.

  2. Do you really expect an answer? There are no mind readers here and our crystal balls are cracked, so we can't see your machine.
         How To Ask Questions The Smart Way. (2004)
              Be precise and informative about your problem

    We can't see your broken code.

    Always post all relevant code (using Code button) or attach the source file.

 
William Roeder #:
  1. It's not returning DBL_MAX, it's returning EMPTY_VALUE. Different meaning, same value.

  2. Do you really expect an answer? There are no mind readers here and our crystal balls are cracked, so we can't see your machine.
         How To Ask Questions The Smart Way. (2004)
              Be precise and informative about your problem

    We can't see your broken code.

    Always post all relevant code (using Code button) or attach the source file.

Hi William

Thank you for taking the time to reply and highlighting that it's returning EMPTY_VALUE. I know it's naïve of me but I did hope someone more experienced and knowledgeable about this platform might have been able to point me in the right direction.

You suggest my code is broken, are you able to explain how the 'broken code' of my EA may make a difference in how the Ichimoku Indicator displays on the Strategy Tester over using the indicator on the real time chart? Which bit of my code would be relevant to that?


This is the code in my EA that initiates the indicator:

WeeklyIchimokuIndicator[symbolLoop] = new CiIchimoku();
         //this is instead of buuffers holding values   
         if(!WeeklyIchimokuIndicator[symbolLoop].Create(symbolArray[symbolLoop], PERIOD_W1, 9, 26, 52))
            {
             string outputMessage = "";
            
            if(GetLastError() == 4302)//the most common error
               outputMessage = "Symbol needs to be added to the MarketWatch";
            else
               StringConcatenate(outputMessage, "(error code ", GetLastError(), ")");
  
            MessageBox("Failed to create handle of the Daily Ichimoku indicator for " + symbolArray[symbolLoop] + "/" + EnumToString(Period()) + "\n\r\n\r" + 
                        outputMessage +
                        "\n\r\n\rEA will now terminate.");
                   
            //Don't proceed
            return(false);
            }











The 'Broken Ichi' image attached, is what that code creates ONLY (I've tested 100's others) on the EBAY symbol for WEEKLY time period. As you can see the cloud is not displayed fully.

The 'Working Ichi' image attached is what I see when I drag the Ichimoku indicator from MT5's navigator to the weekly EBAY chart. As you can see the cloud looks valid.

So repeating myself I know, but as hopefully you can see, the cloud is not displayed properly on the EA's version.

I assume this is why my code to read the indicator:

WeeklyIchimokuIndicator[symbolIndex].Refresh(-1);
   
   //values for current Kumo (the Ichi cloud) the shaded area
   double senkouSpanA_AtCurrPrice          =WeeklyIchimokuIndicator[symbolIndex].SenkouSpanA(iBarToUseForProcessing);// Senkou Span A (that defines the boundary of the kumu) at the current bar
   double senkouSpanB_AtCurrPrice          =WeeklyIchimokuIndicator[symbolIndex].SenkouSpanB(iBarToUseForProcessing);// Senkou Span B (that defines the other boundary of the kumu) at the current bar

   //predicted values
   double senkouSpanA_AFuture                =WeeklyIchimokuIndicator[symbolIndex].SenkouSpanA(iBarToUseForProcessing-26);
   double senkouSpanA_AFutureMinus1          =WeeklyIchimokuIndicator[symbolIndex].SenkouSpanA(iBarToUseForProcessing-25);//looking to get slope of senkouspan A
   double senkouSpanB_AtFuture               =WeeklyIchimokuIndicator[symbolIndex].SenkouSpanB(iBarToUseForProcessing-26);  

   //values for the chikou span trend filter - the yellow line
   double chikouSpan_mostRecent              =WeeklyIchimokuIndicator[symbolIndex].ChinkouSpan(iBarToUseForProcessing+25);//some say this should be +25 but forum people says shift is already accounted for, either way it seems unreliable
   
   double senkouSpanA_AtMostRecentChikouSpan =WeeklyIchimokuIndicator[symbolIndex].SenkouSpanA(iBarToUseForProcessing+26);
   double senkouSpanB_AtMostRecentChikouSpan =WeeklyIchimokuIndicator[symbolIndex].SenkouSpanB(iBarToUseForProcessing+26);
   
   double tenkanSen   = WeeklyIchimokuIndicator[symbolIndex].TenkanSen(iBarToUseForProcessing);  
   double kijunSen   = WeeklyIchimokuIndicator[symbolIndex].KijunSen(iBarToUseForProcessing);      
   double prev_TenkanSen   = WeeklyIchimokuIndicator[symbolIndex].TenkanSen(iBarToUseForProcessing+1);  

is returning values of EMPTY_VALUE for some aspects rather than a valid value.

Thank you for sharing your time and experience.

Files:
Broken_Ichi.JPG  229 kb
Working_Ichi.JPG  177 kb
Reason: