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
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Ichimoku code for beginners by William210:
Ichimoku beginner tutorial to learn how to code in MQL5
Author: Gerard Willia G J B M Dinh Sy