Indicators: Ichimoku code for beginners by William210

 

Ichimoku code for beginners by William210:

Ichimoku beginner tutorial to learn how to code in MQL5

Ichimoku code for beginners by William210

Author: Gerard Willia G J B M Dinh Sy

 
becase im a beginer
 

Hello

Everything's fine?

While making the code for the use of iAlligator(), I realized that the code could be optimized on copying data to buffers

My code for the Alligator in codebase 

The correction is done on this part

   if ( CopyBuffer( g_ptIshimoku, 2, - g_kijun_sen, rates_total, g_BuffSenkou_Span_A) < 0)
   {
      PrintFormat("Error retrieving data for SENKOU A");
      return (0);
   }
  
   if ( CopyBuffer( g_ptIshimoku, 3, - g_kijun_sen, rates_total, g_BuffSenkou_Span_B) < 0)
   {
      PrintFormat("Error retrieving data for SENKOU B");
      return (0);
   }

And specifically on these 2 copybuffers that are shifted to have the illusion of a prediction.

In this syntax, at each pass, all the history is copied into the buffer, while only a new bar is added. 

That's too bad


Optimization is quite simple.

We form a loop that will go through the entire history with the right positioning thanks to Oncalculate's system constants

        /* Copies of new bars only */
        for(int i = prev_calculated;i < rates_total; i++)

et de changer les copybuffer
                        if ( CopyBuffer( g_ptIshimoku, 2, i - g_kijun_sen, rates_total, g_BuffSenkou_Span_A) < 0) 
                        {
                           PrintFormat("Error retrieving data for SENKOU A");
                           return (0);
                        }               

                        if ( CopyBuffer( g_ptIshimoku, 3, i - g_kijun_sen, rates_total, g_BuffSenkou_Span_B) < 0) 
                        {
                           PrintFormat("Error retrieving data for SENKOU B");
                           return (0);
                        }

This syntax only copies the new bar, which saves resources and speed.


Don't forget to put stars for the SEO of my code

Alligator code for beginners by William210
Alligator code for beginners by William210
  • www.mql5.com
Alligator beginner tutorial to learn how to code in MQL5
 
Hello to all, Thank you for your valuable work. A question: How can I fill the space in the cloud - like the indicator used in Metatrader - with dots? (instead of solid color) Thank you.