by Steve0001 » Mon Nov 09, 2015 2:32 pm
Hi Apprentice,
I became interested in VSA (and this indicator in particular) when I came across this thread a few weeks ago. From the limited reading I have done about VSA, I learned that (1) there are several variations of the same basic strategy (varying rules) and that (2) most proponents of the strategy seem to have a hard time specifying it in a concise, well-defined set of rules. I see from earlier posts that this indicator is the result of your hard work translating a user-supplied indicator from another programming language (which had no documentation). All this makes it a challenge to understand exactly what this indicator is doing - and to understand why some no-supply or no-demand indications get erased upon redraw.
I started having a look at the LUA file to analyze what it is doing, but it is (as you note) long and tedious and difficult to completely understand every detail. Disclaimer: I don't know LUA very well, but years ago I wrote quite a few programs and subroutines in C and C++ (I know LUA is somehow related C / C++), so LUA doesn't look totally alien to me.
My understanding of this VSA implementation is incomplete, but this is what I THINK: It looks for no-supply / no-demand candidates by looking at the last 3 completed candles (and also the still-open candle). (1) It looks for the most recently completed candle to have less volume than either of the previous two candles. (2) It looks for the most recently completed candle to have a smaller range than the previous candle (spread or range = high minus low). (3) It looks for the most recently completed candle to show signs of reversal (like having a wick) [I refrain from "spelling out" the exact conditions; they are somewhat complicated]. (4) Further, it looks for the current (incomplete) candle to be the reverse color (compared to the most recently closed candle). If all these conditions are met, the most recently completed candle can be identified as a "no-supply / no-demand candidate" and marked accordingly on the chart (providing a timely signal to traders), but (5) it still needs to be confirmed by the close of the current candle (which is still open). I suspect this is where the re-paint issue arises - when the current candle temporarily shows a reversed color and gets a tentative NS/ND label, but finally closes the wrong color (the same color as the previous candle - which was the no-supply / no-demand candidate) and the indicator fails to erase the tentative NS/ND label which failed to be confirmed. Many people wait for a current candle to close and provide NS/ND confirmation; others look simply for the current candle to engulf the candidate NS/ND (while not yet closed). One way to test this hypothesis would be to make it mark with a different color any NS/ND candles which are the most recent candle (and see if those tentative marks are the ones that are wrong and disappear on re-draw). Those most recent candles seem to be the ones that get labeled with the 'Plot(LT,period,"NoDemand")' and 'Plot(HT,period,"NoSupply")' lines in the indicator code.
When looking at historical data in the chart, the indicator analyzes all sets of four consecutive candles in the chart.
This implementation of VSA does some things I find odd, like testing whether the VSA candidate is a zero-body doji (Is it really significant if a candle close is exactly equal to its open, as opposed to being a pip or a few pips different?). I am still sifting through it, but it also seems to look for candles meeting the same conditions (or almost the same conditions) which are NOT zero-body dojis (so why bother with the zero-body doji / NOT zero-body doji test, if that is true?). I will have to have a closer look at it. It has also occurred to me that we could try to improve on the reversal candle tests if we didn't like them or thought we had a better idea (but any such indicator should be clearly identified as a variant; I am still interested in experimenting with the best VSA algorithms).
I also suspect the code could have been written much more compactly using loop structures and thereby also be much easier to understand (I see lots of at least superficially repetitive code).
Steve0001