WMA little slow

Weighted Moving Average bit slow compare to other moving average & I need WMA :sob: as its important part of my coding strategy. Can’t WMA be little faster?
any alternative :space_invader: like for example Wilders(100) == EMA(199)

@Fossil I don't know why in your case there is such discrepancy in execution times between WMA and other averages. In my case it is not as big:


...but most importantly, you didn't tell us why it bothers you so much? :wink: If your code seems sluggish it is most probably because of something else ...

1 Like

May be you used value less than 15,, use 100+ value with WMA...


Is not that much of big deal but still this WMA speed troublesome & it’s the main ingredient :grin: of my secret sauce.
After much testing with different Moving Average, WMA work best with rest of my code.

@Fossil, one of the many great things about AmiBroker is that @Tomasz has put so much effort into making it as efficient as possible. I can say with a great deal of confidence that you will not find a way to implement a faster version of WMA that is still computationally correct.

1 Like

Yes, I have used the default settings ...

I have asked, why does it bother you, because I still can't imagine a situation in which you notice this 35 milliseconds delay... Are you running this code 10 times per second or (the worst case scenario) inside a loop or what? :wink:

Even if you are a prop-trader or a scalper - average human reaction time is about 200-250ms.

For example, you can test your reaction time Here --> My record 216 ms :slight_smile:

1 Like

While WMA is slower than other MA functions (its calculation is more complex) I will not rely too much on a single execution Check&Profile result. Better evaluate the average Time per Call.

The speed displayed depends also on the number of loaded bars (images grabbed using 2 different tickers).



Anyway, I agree with @mradtke!

1 Like

@mradtke Complete agree with you :+1: but trust me I am not complaining, it just simple query.

@Milosz I am way slower than you :sob:
The code run fine every day (no delay), just ask to find alternative of WMA and yes you are right this milliseconds difference doesn’t matter that much.

@beppe in my code I am not using WMA inside loop :sunglasses:

1 Like

Well, let's just say I have a faster mouse :smiley: Here's the proof that I was not lying:


... but if you want to know the truth, I master my skills playing every day Buttons Hunter - The Game for AmiBroker 6.25. That's the key to "outstanding" mind-eye-hand coordination :wink:

But I'm sure, many users will beat me ...

1 Like

Contrary to other averages, WMA is not single loop. MA, EMA, Wilders are all implemented as single loop so their complexity is constant regardless moving average period. WMA is two loops (nested) hence it is slower. 100-bar WMA is approximately 100 times slower than MA.

1 Like