StockFetcher Forums · General Discussion · Twiggs money flow<< >>Post Follow-up
rarya
7 posts
msg #66174
Ignore rarya
8/14/2008 8:03:19 AM

http://www.incrediblecharts.com/technical/twiggs_money_flow.php

Can can anyone provide any insight in how to code up this indiciator.

Thanks

guru_trader
485 posts
msg #66259
Ignore guru_trader
modified
8/16/2008 3:31:16 AM

This is basically it, according to the article ...

[edit: Formula A: ( [ (C-TRL) - (TRH-C) ] / TR ) * Volume ]

Fetcher[
/* Twiggs Money Flow using Formula A: ( ( (C-TRL) - (TRH-C) ) / TR ) * Volume */

/* Basic Criteria */
and chart-length is 120 days
and not otcbb
and avgvol(120) > 54321
and close > 1

/* According to the article and formula provided here ... http://www.incrediblecharts.com/technical/twiggs_money_flow.php */

/* True Range High */
and set{TRH, max( close 1 day ago, high ) }
and add column TRH

/* True Range Low */
and set{TRL, min( close 1 day ago, low ) }
and add column TRL

/* True Range */
and set{ TR, TRH - TRL }
and add column TR

/* Calculate ADV */
and set{ num1, close - TRL }
and set{ num2, TRH - close }
and set{ num3, num1 - num2 }
and set{ TRmax, 999999 }
and set{ deno1, max( TR, TRmax) }
and add column deno1
and set{ num4, num3 / deno1 }
and set{ ADV, num4 * volume }
and add column ADV

/* Calculate WV (uumm = not sure what was intended by the formua, read the footnote in the article) */
and set{ uumm, volume 1 day ago * 0 }
and set{ WV, volume + uumm }

/* Exponentially Smoothed ADV */
and set{ cema_ADV, cema( ADV, 27 ) }
and add column cema_ADV

/* Exponentially Smoothed wV*/
and set{ cema_WV, cema( WV, 27 ) }
and add column cema_WV

/* Twiggs Money Flow */
and set{TMF, cema_ADV / cema_WV }
and add column TMF
and draw TMF line at 0
]




[edit: Formula B: [ (C-TRL) - (TRH-C) ] / (TR * Volume) ]

Fetcher[
/* Twiggs Money Flow using Formula B: ( (C-TRL) - (TRH-C) ) / (TR * Volume) */

/* Basic Criteria */
and chart-length is 120 days
and not otcbb
and avgvol(120) > 54321
and close > 1

/* According to the article and formula provided here ... http://www.incrediblecharts.com/technical/twiggs_money_flow.php */

/* True Range High */
and set{TRH, max( close 1 day ago, high ) }
and add column TRH

/* True Range Low */
and set{TRL, min( close 1 day ago, low ) }
and add column TRL

/* True Range */
and set{ TR, TRH - TRL }
and add column TR

/* Calculate ADV */
and set{ num1, close - TRL }
and set{ num2, TRH - close }
and set{ num3, num1 - num2 }
and set{ TRmax, 999999 }
and set{ deno1, max( TR, TRmax) }
and add column deno1
and set{ deno2, deno1 * volume }
and set{ ADV, num3 / deno2 }
and add column ADV

/* Calculate WV (uumm = not sure what was intended by the formua, read the footnote in the article) */
and set{ uumm, volume 1 day ago * 0 }
and set{ WV, volume + uumm }

/* Exponentially Smoothed ADV */
and set{ cema_ADV, cema( ADV, 27 ) }
and add column cema_ADV

/* Exponentially Smoothed wV*/
and set{ cema_WV, cema( WV, 27 ) }
and add column cema_WV

/* Twiggs Money Flow */
and set{TMF, cema_ADV / cema_WV }
and add column TMF
and draw TMF line at 0
]



Note: I left out a few if-then statements, but they didn't seem essential. Perhaps I'll have time to code those in later. The divergences are nice.



chetron
2,817 posts
msg #66261
Ignore chetron
8/16/2008 7:47:51 AM

hey guru,
tmf only comes in 2 flavors for me, 0 and -0. is this right?
also deno1 is always 999999. am i doing something wrong?


tia chetron

guru_trader
485 posts
msg #66274
Ignore guru_trader
modified
8/16/2008 12:32:08 PM

I created another version of the TWF but that didn't match the "Metastock Formula" written on the website so I changed it up.

I do have a question about one part of the formula that is not clear ...

is it this? Formula A: ( [ (C-TRL) - (TRH-C) ] / TR ) * Volume

or this? Formula B: [ (C-TRL) - (TRH-C) ] / (TR * Volume)

the filter above was written in the style of Formula A, I'll post Formula B above also.

============================

From http://www.incrediblecharts.com/technical/twiggs_money_flow.php

MetaStock® Formula

{2003-09-24}
periods:=Input("TMF periods",1,100,21);
TRH:=Max(Ref(C,-1),H);
TRL:=Min(Ref(C,-1),L);
TR:=TRH-TRL;
ADV:=((C-TRL)-(TRH-C))/If(TR=0,999999,TR)*V;
WV:=V+(Ref(V,-1)*0);
If (Wilders(WV,periods) =0,0,Wilders(ADV,periods)/Wilders(WV,periods))

Line 6: WV
I have received several queries regarding line 6: WV:=V+(Ref(V,-1)*0).
The first day for TRH and TRL is day #2 because the calculation requires Closing Price from the previous day. WV brings Volume into line with this, so that the first day of Volume used is day #2.

I received several emails from one reader who insisted that it makes no difference if you substitute V for WV in line 7. The difference is only noticeable in the first few months of data; it gradually fades with exponential smoothing.

============================

guru_trader
485 posts
msg #66275
Ignore guru_trader
modified
8/16/2008 1:25:06 PM

Work in progress ... I revised the filter a little ...

Fetcher[
/* Twiggs Money Flow */

/* Basic Criteria */
and chart-length is 120 days
and not otcbb
and avgvol(120) > 54321
and close > 1

/* According to the article and formula provided here ... http://www.incrediblecharts.com/technical/twiggs_money_flow.php */

/* True Range High */
and set{TRH, max( close 1 day ago, high ) }
and add column TRH

/* True Range Low */
and set{TRL, min( close 1 day ago, low ) }
and add column TRL

/* True Range */
and set{ TR, TRH - TRL }
and add column TR

/* Calculate ADV */
and set{ num1, close - TRL }
and add column num1
and set{ num2, TRH - close }
and add column num2
and set{ num3, num1 - num2 }
and add column num3
and set{ TRmax, 999999 }
and add column TRmax
and set{ deno1, TRmax }
and add column deno1
and set{ num4, num3 / deno1 }
and add column num4
and set{ temp_ADV, num4 * volume }
and add column temp_ADV
and set{ ADV, temp_ADV * 100000 }
and add column ADV

/* Calculate WV (uumm = not sure what was intended by the formua, read the footnote in the article) */
and set{ uumm, volume 1 day ago * 0 }
and set{ WV, volume + uumm }

/* Exponentially Smoothed ADV */
and set{ cema_ADV, cema( ADV, 27 ) }
and add column cema_ADV

/* Exponentially Smoothed wV*/
and set{ cema_WV, cema( WV, 27 ) }
and add column cema_WV

/* Twiggs Money Flow */
and set{TMF, cema_ADV / cema_WV }
and add column TMF
and draw TMF line at 0
]



guru_trader
485 posts
msg #66278
Ignore guru_trader
modified
8/16/2008 3:19:11 PM

Here it is with a CEMA crossover ...

Fetcher[
/* Twiggs Money Flow */

/* Basic Criteria */
and chart-length is 60 days
and not otcbb
and avgvol(120) > 54321
and close > 1

/* According to the article and formula provided here ... http://www.incrediblecharts.com/technical/twiggs_money_flow.php */

/* True Range High */
and set{TRH, max( close 1 day ago, high ) }
and add column TRH

/* True Range Low */
and set{TRL, min( close 1 day ago, low ) }
and add column TRL

/* True Range */
and set{ TR, TRH - TRL }
and add column TR

/* Calculate ADV */
and set{ num1, close - TRL }
and add column num1
and set{ num2, TRH - close }
and add column num2
and set{ num3, num1 - num2 }
and add column num3
and set{ TRmax, 999999 }
and add column TRmax
and set{ deno1, TRmax }
and add column deno1
and set{ num4, num3 / deno1 }
and add column num4
and set{ temp_ADV, num4 * volume }
and add column temp_ADV
and set{ ADV, temp_ADV * 1000000 }
and add column ADV

/* Calculate WV (uumm = not sure what was intended by the formua, read the footnote in the article) */
and set{ uumm, volume 1 day ago * 0 }
and set{ WV, volume + uumm }

/* Exponentially Smoothed ADV */
and set{ cema_ADV, cema( ADV, 27 ) }
and add column cema_ADV

/* Exponentially Smoothed wV*/
and set{ cema_WV, cema( WV, 27 ) }
and add column cema_WV

/* Twiggs Money Flow */
and set{TMF, cema_ADV / cema_WV }
and add column TMF
and draw TMF line at 0

and set{ cema_TMF, cema(TMF, 45)}
and draw cema_TMF on plot TMF
]



rarya
7 posts
msg #66289
Ignore rarya
modified
8/16/2008 6:17:35 PM

Hey Guru,

Thanks for the input

this was my take on it, not as robust as yours

Fetcher[
set{ATRH,max(High,prior day close)}
set{ATRL,Min(Low,prior day Close)}
Set{BP,Close-ATRL}
Set{SP,ATRH-Close}

set{adnum,Bp-Sp}
set{ad2,adnum/atr(1)}
set{ad,ad2*volume}
set{tmfn,cema(ad,19)}
set{tmfd,cema(volume,19)}
set{tmf,tmfn/tmfd}

and draw TMF line at 0
add column TMF
]



Also in your CEMA calculations you use 27. how does wilders EMA of 21 days relate to EMA of 27?

Thanks in Advance

guru_trader
485 posts
msg #66290
Ignore guru_trader
modified
8/16/2008 6:23:52 PM

Apparently, Wilder's EMA(21) is equivalent to a regular EMA(27) according to the article you referred to ...

Source: http://www.incrediblecharts.com/technical/twiggs_money_flow.php

==============================================

*Welles Wilder's Indicators

TMF uses Welles Wilder's formula for calculating an exponential moving average:
1/14 of today's data + 13/14 of yesterday's average is a 14-day exponential moving average.

If you refer to Exponential MA Time Periods you will see that this equates to a normal 27-day exponential moving average.

Example
What Wilder's time period would equate to a normal EMA 15-day time period:
Wilder's time period = (n + 1) / 2 = (15 + 1) / 2 = 8 days

==============================================

rarya
7 posts
msg #66294
Ignore rarya
modified
8/16/2008 7:09:16 PM

I think 14 becomes 27
Wilders TP = (n+1)/2
(14*2)-1 = n

I think 21 becomes 41



StockFetcher Forums · General Discussion · Twiggs money flow<< >>Post Follow-up

*** Disclaimer *** StockFetcher.com does not endorse or suggest any of the securities which are returned in any of the searches or filters. They are provided purely for informational and research purposes. StockFetcher.com does not recommend particular securities. StockFetcher.com, Vestyl Software, L.L.C. and involved content providers shall not be liable for any errors or delays in the content, or for any actions taken based on the content.


Copyright 2016 - Vestyl Software L.L.C.Terms of Service | License | Questions or comments? Contact Us
EOD Data sources: DDFPlus & CSI Data Quotes delayed during active market hours. Delay times are at least 15 mins for NASDAQ, 20 mins for NYSE and Amex. Delayed intraday data provided by DDFPlus