Hi and good morning,
have a look at the MQL4\Include\MovingAverages.mph - maybe this could help you.
Best regards
That's interesting I tried to populate my Buffer with the MA_arrays, but they don't get updated to the current bar.
and I put this into this loop, like I did for " somearray__to_take_average_of "
ArraySetAsSeries( somearray__to_take_average_of, true); int UnchangedBars = IndicatorCounted(); int ChangedBars= Bars - UnchangedBars; for (int q=ChangedBars-1; q >= 0; q--) { BUFFER[q]= ExponentialMA[q, InpMAperiod, BUFFER[q-1], somearray__to_take_average_of ] }
If I remove the ''static'' in the LWMA, then I get an error '' zero divide''' at line
The "zero divide" is easy to solve without static.
if(weightsum != 0)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I want to use LWMA (the official LWMA in Custom Moving Averages.mq4) twice with two PERIODS, one short and one long, and those averages will be in 2 buffers, SHORTBUFFER and LONGBUFFER, to print them. BUT, LWMA has a "static int" and so the results of the first SHORTBUFFER are messed up. The results of the LONGBUFFER are fine.
so first I just define my arrays
and I populate the buffers like this
CalculateLWMA(rates_total,prev_calculated, ""Some Generic array of which I want LWMA with short period", SHORTBUFFER, InpMAPeriodSHORT );
CalculateLWMA(rates_total,prev_calculated, ""Some Generic array of which I want LWMA with long period", LONGBUFFER, InpMAPeriodLONG );
[If I reverse the order of the calls, ie first populating LONGBUFFER, then SHORTBUFFER, then it is the LONGBUFFER which has garbage values]
and i modify slightly the official LWMA to get
If I remove the ''static'' in the LWMA, then I get an error '' zero divide''' at line