Ztrader – Moving Average (3)


As market always says the price and turnover shall confirm each other, there are many indicators taking consideration of the turnover rather than just look at the price alone.


Richard Arms had proposed a moving average calculation, called Volume Adjusted Moving Average. The idea is, on a high turnover trading day, the price on that day is more significant than the price on a low turnover day.


Let’s look at this chart. On early Feb, there was a 58M shares -8% at closing selling down day. This selling was significant. Although the stock price rebounds a bit in the coming few days, the turnover was small. The real selling was coming after that. On April 9, there was a 17% gap up with 71M shares. This is the beginning of a strong rising trend.




If use two SMA lines, 10 days and 20 days:



Since SMA only consider the price but not the volume, it would not tell the significant of early Feb selling day. In the above chart there are total 6 crossings of the fast and slow SMA lines. Note that there are two crossings in Feb. The April 9 event is recognized by these SMA lines on time.


In the following chart, two VAMA is used:


Since the early Feb sell off is significant, VAMA is able to recognize it and both trend lines were not affected by the fake rebound in Feb. There are total 4 crossings in the above chart. The April 9 event is recognized by these VAMA lines on time.


In this particular example, VAMA seems works better, more accurate, and yet produce fewer fake signals.


To reduce fake signals, how about using a slower SMA line ? If 10 day with 30 day SMA line is used, fewer signals are generated with bigger time lags.






Another stock , the SMA lines did a good catch this time.



VAMA lines seems do a bad job:



However, if you look at the green line above, while the stock price kept going up, the trading volume was going down (indicate by the red line). Price and Volume not confirming each other, the VAMA lines thus do not follow the stock price. It gave a very early alert already. By observing the gaps between the stock price and trend line, the price volume divergence is clearly identified.


In conclusion, the VAMA lines in these two cases are very useful. Valuable information shall be easily obtained from it, because it is in the stock price domain and at the same time embedded with volume information.


25 thoughts on “Ztrader – Moving Average (3)

  1. I accidentally ran into your blog today. Very surprise to know that you are building you own trading system from scratch. Nice!! Keep up with the good work!!
    I’m also from HK, have used almost all commercially available trading systems over the years such as multicharts, ninjatrader, tradestation, openquant, amibroker, mathlib,etc…
    Anyway, check out John Ehlers super smooth filters, i found it much more responsive that anything else such as VAMA/SMA. Here’s the link:

    I’m interested in your trading system too, do you still open for beta??

    1. thank you for the information.
      I tried John Ehlers indicators before, not much good findings. Will try again.

      The current web base system development is stopped. I am now focusing on the new system which is not open.

  2. ok, pls keep me in touch with your new system when you open for beta.
    I enjoyed your blog, very nice indeed. Very rare to find someone in HK with similar hobbies and experience: programmer+stock+FA->TA+tradingsystem+solo!!

  3. no, i dont have a blog. unlike you, i’m not a good writer at all
    email me and we can keep in touch, i think we have lots in common

  4. Hi Cheung & mb,

    As mentioned in another post here, currently my system is an Excel/VBA based system. Looking for direction to upgrade/improve it for higher speed and further development. It can be:

    1.100% DIY system — rewrite the current system with PHP or other suitable language, driven by a MySQL engine.

    2. Implement the current strategies using platforms like Tradestation, etc.

    how do you guys think which one is a better direction ?

    1. definitely not php + SQL engine.
      tradestation shall be very good platform, but I don’t know the cost and data.

      how to put up a sound strategy is an issue. Usually you need to test, adjust and visualize the problem, so a good charting system is also required.

  5. I’ll keep on using my own charting system which is 100% tailor made. It is almost the master of all my development.

    BTW, can you elaborate more why “definitely” not php+ sql ? Would love to know more.Thanks.

  6. forget about tradestation because it can only can trade US stock and futures and it’s a decade old technology

    try to get an account with interactivebroker, which can trade HK/US market and you can use their API/DDE to hookup in your excel. But it’s quite slow….

    Or, you can use third party solution like ninjatrader, multicharts, etc… they can connect to interactivebrokers through api easily

    word of advice, don’t spend all your time ‘reinventing the wheel’ (like myself in the past), use whats available right now to push your trading idea out as fast as possible, backtest it, paper run it and live trading it

    without ever going into real live trading, you really cant tell if your trading idea is good or not…. there are so many unavoidable mistakes you can make during backtesting such as ‘curve fitting’ ‘peaking into future’ ‘slippage’ etc…

    also, don’t get stuck in the “programmer” habbit (again, like myself in the past) …..making good looking charts and UI or perfect backtest engine doesn’t mean making good profit, only good ‘real’ trading strategy make good profit !!

    keep it up!! cheer!!

  7. thanks for mb’s sharing. If write good programs can make money, all programmers are very rich now.

    Can u tell me any reasons to use php ?

    1. Though I studied EE in university (many many years ago), I am not an engineer nor programmer. I focused on fundamental when I was young. I switched to relying on TA after I become a full time daddy. I have gone through all the “problems” mentioned in mb’s post.

      I use php/vba simply because I can master them better and I don’t have much time to learn another programming language.

  8. php originally designed for simple web page processing.
    You should look for:
    1. available numerical processing modules
    2. multi-threading capability
    3. easy of debugging and development

    To use SQL, it has a lot of overhead. My system can load all > 1600 stocks for 5 year data in 11 seconds with file based storage. If I use SQL, it takes a few minutes for 3 years data.

    To do a linear regression, python takes a few line of code. I don’t know if there is such a library in php ?

    1. Load 1600+ stocks for 5 years in 11 second ?? It is amazing (to me) !! I don’t have much files to handle when I was trading index/futures only. Situation changed dramatically when I modified my system to trade stocks. Develop the new stock trading system based on the old future trading system is the root cause of the low processing speed. It looks something like that:
      1. Load basic terms and parameters
      2. Load strategies
      3. Open share historical data file in Excel format.
      4. Generate Long/Short signal.
      5. Record result. Close file.
      6. Repeat step 3 ~ 5 until all shares are checked.

      It takes about 10~11 min to process 1000+ stocks. It is still ok as I am trading frequently. However, it is really a big big problem for strategy evaluation and back testing (for shares).

      I think storing data in excel format and too many open/close file are the main causes of the low speed. Any hints ? It seems you load all share price data and store them in memory in form of an array or something like that ?

      BTW, PHP can do most of the jobs except it is not very thread safe.

  9. In this case if php can do the job, why asking ? Just use it.

    excel, very slow. Store in flat file will save 99% of time already.

    for performance reason, you shall consider to load the files and keep in memory. It is a waster of resource to keep load again and again.

  10. agree with clcheung, if you dealing with tick data, just store flat file easiest and lowest overhead; if dealing with eod data, can use any nosql such as mongodb or redis; i personally use redis now to read in all necessary data to memory for processing later; excel/vba is probably the slowest way to backtest idea, it can ran out of memory easily; so my advice is cut back on stocks (100+ max.) if you use excel/vba

    clcheung: have u ever try to process trade tick data on hsi futures from hkex? it’s quite a challenging, i tried some high freq analysis on hsi futures with tick data and just exhaustive to run… but quite educational !!! now, imagine bid-ask level tick data anaylsis ….. 🙂

    1. Thanks for sharing, will keep all these in mind when I start the modification later next year.

      mb: are you building your own system or using a commercial platform right now ? I tried ninjatrader a few years ago. What is your suggestion if I want to evaluate this possibility again now ? Thanks.

  11. clcheung: i meant hsi future tick data, which include every single trade on the hsi future

    ben: no, i try not to reinvent the wheel, i use multicharts primary for frontend trading, for risk management i have my own database setup, i spend all my programming time on risk management, not frontend

    1. Thanks mb. So you suggest multicharts over the others ? You buy the lifetime version or annual subscription ?

  12. to ben:
    1) multicharts is most advance in GUI and scripts
    2) lifetime
    3) because its much easier and convenience to do it myself

    1. Thanks mb.

      Could you please share with us where and how you get the future tick data ? A few years ago, I wrote program to record the per minute open, high, low and close HSI future data for short term day-trade strategy. It could make some money but unfortunately not big money.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s