Stock Market Tools (12) - A Better OBV and Time Segmented Money Flow

Part 1: A Better OBV

In the classical OBV (On-Balance Volume) indicator, it simply takes the idea from traditional tape reading - treat the "up tick" as Buy, "down tick" as Sell, and it assumes no change in price as neutral* (*which is not the case in tape reading).

When it comes to interpret the daily volume as such, errors will add up cumulatively.  For example, there are days when a Doji Star with high volume just merely one cent higher than yesterday price and the whole day volume would be taken as a BUY Volume....


Here is a gentlemen, William C. Garrett, attempted to break down the daily volume into two parts in his book - "Torque Analysis of Stock Market Cycle".   And, I think it makes sense.



.


William showed his method in Fig. 4.3 in his book, and we can derive the formula from it as follows:
He made the assumption that the trading volume is about linear over the trading hour, and thus it can derive how the paths the stock was traveled and workout the Buy Volume and Sell Volume accordingly as shown in the below chart:


.
Now a better OBV formula can be written as the cumulative number of  (Buy Volume - Sell Volume).
It should named as Garrett OBV.
And, it can multiply the daily average price to it and named as Garrett Money Flow.

The following chart shows the plot of it and the comparison to Classical OBV.

(Click on the Chart to Zoom in)












.
Part 2: Time Segmented Money Flow

There is a proprietary volume indicator known as Time Segmented Volume (TSV).  Since it is proprietary, probably the public would not know about the exact formula.  But the concept is not difficult.

Let say for the Classical way of plotting of OBV, there is no clear sign for both entry and exit.  We can then fix a look back period to compare it accumulation/distribution over it's own historical value.  One simple way is to perform a MACD operation on the Garrett Money Flow.  

Now we can compare the Garrett Money Flow Indicator to the Classic MACD indicator.  In the above chart, they are using the same look back period for short MA, long MA and Signal.
From the chart, there are some very interesting point to take note.
Since the Volume Action is taken into account in this new indicator together with price.  The Time Segmented Money Flow behave differently at couple of  place on the above chart.
For examples:  On March, April and July, the RED Line maintain above the Zero line to prevent any short trades - this happened as a result of  more Buying Volume than Selling Volume.

Note on Divergence:
When using a indicator as Time Segmented Money Flow, divergence would surely occur on and off.  This is where Wyckoff 3rd principle comes into play - "Effort vs Result" that is not matching.  Meaning that the cumulation of shares goes in one direction while the price goes another direction.









"It ain't what you don't know that gets you 
into trouble.  It's what you know 
for sure that just ain't so." 
- Mark Twain



Attached is the AFL formula:

//------------------------------------------------------------------------------
//  Formula Name  : OGTS Time Segmented Money Flow
//  Author        : KH Tang
//  Company       : Wealth Resonance
//  Last Update   : 15 Jan 2014
//  Date Updated  : 22 Nov 2013 // Update with opening price as direction*
//  Origin date   : 5 Jun 2007
//  Origin        : KH Tang
//  Version       : 1.01
//  Level         : Volume Analysis
//  Description   : Key Usages:
//                : 1.Tape Reading for Direction of Breakout in Trading Range
//                : 2.Tape Reading for Divergence in Trending
//        : Note: Enhancement to include Opening price as direction.
//------------------------------------------------------------------------------
 
procedure BackgroundSetting()
{
 
SetChartBkGradientFill( ParamColor("BackgroundTop", colorSkyblue),
        ParamColor("BackgroudBottom", colorWhite),ParamColor("TitleBlock",colorWhite));
}
 
 
SetBarsRequired( -2, -2 );
_SECTION_BEGIN("Display Setting");
GraphXSpace = 10;
Backgroundsetting();
_SECTION_END();//Display Setting
 
//William C. Garrett's Approximation:
//GPaths   = IIf(C>Ref(C,-1),((H-Ref(C,-1))+(H-L)+(C-L)),IIf(C
//GUpShare = IIf(C>Ref(C,-1),((H-Ref(C,-1))+(C-L)),IIf(C
//GDnShare = IIf(C>Ref(C,-1),(H-L),IIf(C
 
 
//Expansion for clarity:
PathA1= Ref(C,-1)-L;
PathB1= H-L;
PathC1= H-C;
Path1 = PathA1+PathB1+PathC1;
UpShare1 = PathB1;
DnShare1 = PathA1+PathC1;
 
PathA2= H-Ref(C,-1);
PathB2= H-L;
PathC2= C-L;
Path2 = PathA2+PathB2+PathC2;
UpShare2 = PathA2+PathC2;
DnShare2 = PathB2;
 
Paths  = IIf(C<Ref(C,-1),Path1,    IIf(C>Ref(C,-1),Path2,   1));
UpShare= IIf(C<Ref(C,-1),UpShare1,IIf(C>Ref(C,-1),UpShare2,0));
DnShare= IIf(C<Ref(C,-1),DnShare1,IIf(C>Ref(C,-1),DnShare2,0));
 
FlowFactor = Avg;
 
FlowIn  = UpShare/Paths*Volume*FlowFactor;
FlowOut = DnShare/Paths*Volume*FlowFactor;
NetFlow = FlowIn - FlowOut;
TotalFlow = Cum(NetFlow );
 
 
PlotType = ParamList("Type of Chart Plotting:","Cumulative|Time Segmented",1);
LBP = Param("LBP for Time Segmented Plot",26,10,50,1);
FastSmoothMF     = EMA(TotalFlow,int(LBP/2));
SlowSmoothMF   = EMA(TotalFlow,LBP);
 
DailyNetFlow= IIf(NetFlow==0,MA(Netflow,30),NetFlow);
 
if(PlotType=="Cumulative")
{
    Plot(TotalFlow ,"Garrett Money Flow",colorRed,styleThick);
}
else if (PlotType=="Time Segmented")
{
    TSMF=FastSmoothMF - SlowSmoothMF;
    Plot(TSMF,"Time Segmented Money Flow",colorRed,styleThick);
    Plot(0,"",colorBlack);
    TSMFsig = EMA(TSMF,9);
    Plot(TSMFsig,"Sig",colorBlue);
     
    Histogram = TSMF-TSMFSig;
 
    Plot(Histogram,"Histogram",colorBlack,styleHistogram);
 
}



Home

11 Comments->:

Unknown said...

Thanks for Sharing again..and trying so hard to understand your idea...wanna meet you one day :D

Anonymous said...

Thank you... have you shared other Amibroker work?

KH Tang said...

Good day, Anonymous
I mostly share ideas and seldom posting code. There are just too many sites you can get coding or write it yourself.

Anonymous said...
This comment has been removed by the author.
Anonymous said...

impressed wid ur imagination.
how to contact u thru email?

KH Tang said...

Good day, Punter Pocket
You may leave your email. :-)

Anonymous said...

thks!
punterpocket@gmail.com

Unknown said...

Wow! It is a wonderful and modern website about financial markets. It is very useful for us. So, I loved it. Many, many thanks to you for creating such an informative website. If you would like more information about this please visit stock market news The advantage of these stock market news is they allow for a vast amount of customization by the user. That same advantage can create a disadvantage for some users. Those users may not really know what they are looking for or what data criteria might produce a stock market news of stocks that present the highest possible probability of a successful stock trade.

Unknown said...

At this moment, It is an excellent and informational website about financial markets. It is very useful for us. So, I loved it. Many, many thanks to you for creating such an informative website. If you would like more information about this please visit stock market news The advantage of these stock market news is they allow for a vast amount of customization by the user. That same advantage can create a disadvantage for some users. Those users may not really know what they are looking for or what data criteria might produce a stock market news of stocks that present the highest possible probability of a successful stock trade.

Unknown said...

Wonderful one.

Zenforker said...

Thanks for sharing the idea and code. It inspired me to code my own and now I have a useful tool for my system.

Happy trading and 交易愉快!

Post a Comment