[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Twiggs Money Flow formula



PureBytes Links

Trading Reference Links

Hi Jayson,
I was only joking with the "rub it in" comment. I appreciate all your 
input and thank you for all your help. The histogram is a good idea, 
it makes it easy to read.

One thing though, I have found that keeping the IIf statement in the 
line ADV=((C-TRL)-(TRH-C))/(IIf(TR==0,999999,TR))*V; makes a 
difference when there is a huge swing in volume but no change in 
price. I think that was part of Colin Twiggs intention to filter out 
such swings.

So the code I will use is:
pds=Param("TMF periods",21,1,100,1);
TRH=Max(Ref(C,-1),H);
TRL=Min(Ref(C,-1),L);
TR=ATR(1);
ADV=((C-TRL)-(TRH-C))/(IIf(TR==0,999999,TR))*V;
sadv=Wilders(Adv,pds);
svol=Wilders(V,pds);
TMF=sadv/svol;
_N( mstr = "("+WriteVal(pds,1.0) + ")" );
Plot(tmf,"Twiggs Money Flow"+mstr,IIf(tmf>0,colorGreen,colorRed),2);
GraphXSpace=5;

For Alan, the Param function was only introduced in AB version 4.25.0 
so if you do not have that version or later then you need to use 
pds=21; instead.

Best regards,
Anthony


--- In amibroker@xxxxxxxxxxxxxxx, "Jayson" <jcasavant@xxxx> wrote:
> Anthony,
> I was not trying to rub it in at all. As a past MS user I had the 
same
> problem understanding = and ==.  Any way, thanks for the link to 
the paper.
> I tried to follow the logic he explained in the the construction 
and found a
> different approach for translation in AB......
> 
> 
> pds=Param("TMF periods",21,1,100,1);
> TRH=Max(Ref(C,-1),H);
> TRL=Min(Ref(C,-1),L);
> tr=ATR(1);
> ADV=((C-TRL)-(TRH-C))/tr*V;
> sadv=Wilders(Adv,pds);
> svol=Wilders(V,pds);
> TMF=sadv/svol;
> Plot(tmf,"Twiggs Money Flow",IIf(tmf>0,colorGreen,colorRed),2);
> GraphXSpace=5;
> 
> 
> The resulting value is the same as the MS translation however it 
does not
> use the WV calculation that confused me and utilizes the built in 
ATR
> function. You might also enjoy the histogram variation as it clearly
> demonstrates accumulation versus distribution.
> 
> 
> Jayson
> -----Original Message-----
> From: Anthony [mailto:axon50@x...]
> Sent: Thursday, March 06, 2003 7:34 AM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: [amibroker] Re: Twiggs Money Flow formula
> 
> 
> Hi Jayson,
> No need to rub it in. Anthony F. has already pointed out my
> stupidity :(
> 
> Seriously though, there was a huge lag yesterday before posts were
> coming up so I guess you did not see my earlier admission of
> dumbness.
> 
> I remember all sorts of variations like .EQ. for "equals" and I
> always used to read := as "set to equal"
> Very confusing for an amateur. I have never used Metastock but its
> combination for "equals" seems easier to grasp.
> 
> Back to the topic. The formula now works and for those unfamiliar
> with it and would like to read more, check out
> http://www.incrediblecharts.com/technical/twiggs_money_flow.htm
> 
> Best regards,
> Anthony
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Jayson" <jcasavant@xxxx> wrote:
> > Anthony,
> > I also do not understand the logic behind line 6 however, I think
> the reason
> > your code is failing is due to  your use of the equal sign. When
> you set a
> > variable you use,  =  as in    x=c+1;
> > However when you are trying to use mathematical equal within the
> code you
> > must use == as in c==42
> >
> >       No Symbol Meaning
> >       1 ^ Exponentiation
> >       2 - Negation - Unary minus
> >       3 * Multiplication
> >       4 / Division
> >       5 + Addition
> >       6 - Subtraction
> >       7 < Less than
> >       8 > Greater than
> >       9 <=  Less than or equal to
> >       10 >= Greater than or equal to
> >       11 == Equal to
> >       12 != Not equal to
> >       13 & Bit-wise "And" (AFL 2.1+)
> >       14 | Bit-wise "Or" (AFL 2.1+)
> >       15 NOT Logical "Not"
> >       16 AND Logical "And"
> >       17 OR Logical "Or"
> >       18 = Variable assignment operator
> >
> >
> >
> > try....
> >
> >
> > periods=Param("TMF periods",21,1,100,1);
> > TRH=Max(Ref(C,-1),H);
> > TRL=Min(Ref(C,-1),L);
> > TR=TRH-TRL;
> > ADV=((C-TRL)-(TRH-C))/(IIf(TR==0,999999,TR))*V;
> > WV=V+(Ref(Volume,-1)*0);
> > TMF=IIf(WV==0,0,Wilders(ADV,periods)/Wilders(WV,periods));
> >
> > Plot(tmf,"",colorRed,1);
> >
> >
> > Jayson
> > -----Original Message-----
> > From: Anthony [mailto:axon50@x...]
> > Sent: Wednesday, March 05, 2003 8:32 PM
> > To: amibroker@xxxxxxxxxxxxxxx
> > Subject: [amibroker] Twiggs Money Flow formula
> >
> >
> > Hi all
> > I have seen people using this and became curious enough to check 
it
> > out. It is based on the theme of the Chaiken Money Flow Index but 
is
> > designed to better handle price gaps and volume spikes. Colin 
Twiggs
> > is behind it.
> >
> > He has given a Metastock formula for it:
> > 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(WV=0,0,Wilders(ADV,periods)/Wilders(WV,periods))
> >
> > Now even though I cannot work out what the sixth line is supposed 
to
> > represent you would think that this was easy enough for me to
> > translate but whatever I have done is wrong:
> > periods=Param("TMF periods",21,1,100,1);
> > TRH=Max(Ref(C,-1),H);
> > TRL=Min(Ref(C,-1),L);
> > TR=TRH-TRL;
> > ADV=((C-TRL)-(TRH-C))/(IIf(TR=0,999999,TR))*V;
> > WV=V+(Ref(Volume,-1)*0);
> > TMF=IIf(WV=0,0,Wilders(ADV,periods)/Wilders(WV,periods));
> >
> > Any thoughts appreciated
> >
> > Regards
> > Anthony
> >
> >
> >       Yahoo! Groups Sponsor
> >             ADVERTISEMENT
> >
> >
> >
> >
> > Send BUG REPORTS to bugs@xxxx
> > Send SUGGESTIONS to suggest@xxxx
> > -----------------------------------------
> > Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
> > (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> > --------------------------------------------
> > Check group FAQ at:
> > http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> >
> > Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service.
> 
> 
>       Yahoo! Groups Sponsor
>             ADVERTISEMENT
> 
> 
> 
> 
> Send BUG REPORTS to bugs@xxxx
> Send SUGGESTIONS to suggest@xxxx
> -----------------------------------------
> Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
> (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> --------------------------------------------
> Check group FAQ at:
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> 
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/