ArrayResize(KAMA,MK_Period+5);
ArrayResize(MK,5);
Counted_bars=IndicatorCounted(); // Number of counted bars
i=Bars-Counted_bars-1; // Index of the first uncountedwhile(i>=0) // Loop for uncounted bars
{KAMA[i] = ...
MK[i] = iM ...
Your chart may have thousands of Bars, but you are assigning those thousands to KAMA[] that has only MK_Period+5 elements and MK[] that has only five..
Your chart may have thousands of Bars, but you are assigning those thousands to KAMA[] that has only MK_Period+5 elements and MK[] that has only five..
yes, as i only want enough KAMA[] data to calculate momentum over it, and i only need 3 MK[] data to decide whether to buy, sell or nothing. if this is what i want to achieve, did i do the correct thing? or will i be saving the oldest data and need to set array as series to have it work under FIFO and have always the latest 5 (or MK_Period+5)? thanks
Your chart may have thousands of Bars, but you are assigning those thousands to KAMA[] that has only MK_Period+5 elements and MK[] that has only five..
Do you think this is correct or should i opt for a "for" loop?
while(i>=0 && i<=MK_Period+5) // Loop for uncounted bars
{KAMA[i] = iCustom(NULL,0,"kaufman-adaptive-moving-average",K_Period,K_Fast,K_Slow,5,i); //array containing KAMA data
i--; } // Calculating index of the next bar;}while(i>=0 && i<=5)
{MK[i] = iMomentumOnArray(KAMA,50,MK_Period,i); //array containing MomentumKAMA data
i--; }
xavilin: Do you think this is correct or should i opt for a "for" loop?
A while loop and a for loop are interchangeable
After the first loop i will be -1. What do you think the second loop will do?
so restarting i would be the answer? thanks! it costed a bit, but finally came to the correct thing, didn't i? thousands of thanks, your bare phrases made me think and search a lot.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
yes, as i only want enough KAMA[] data to calculate momentum over it, and i only need 3 MK[] data to decide whether to buy, sell or nothing. if this is what i want to achieve, did i do the correct thing? or will i be saving the oldest data and need to set array as series to have it work under FIFO and have always the latest 5 (or MK_Period+5)? thanks
Do you think this is correct or should i opt for a "for" loop?
so restarting i would be the answer? thanks! it costed a bit, but finally came to the correct thing, didn't i? thousands of thanks, your bare phrases made me think and search a lot.