“
TD Sequential And Ermanometry For Intraday Traders.”
The Ermanometry study (Figure 2) contains formula parameters to set the start date, start time, first wave period, and second wave period with options to show the Erman segments and Coles segments, which may be configured through the Edit Chart window. This TDSetup study (Figure 3) also contains formula parameters to configure the price source, period, exhaustion period, buy setup, and sell setup colors.
Figure 2: eSIGNAL, TD Setup
Figure 3: eSIGNAL, Ermanometry STUDY
To discuss this study or download a complete copy of the formula code, visit the Efs Library Discussion Board forum under the Forums link from the support menu at www.esignal.com, or visit our Efs KnowledgeBase at www.esignal.com/support/kb/efs/. The eSignal formula scripts (Efs) are also shown here for copying and pasting, and can can be downloaded here: Ermanometry.efs and TDSetup.efs.
TD Sequential
“
TD Sequential And Ermanometry For Intraday Traders,” is available for instant download from Wealth-Lab’s “Open strategy” dialog. The code is also shown below.
Users should be aware that with methods without a rock-solid starting point, it’s an open question as to whether automatic line placement on the chart removes the subjectivity. And one thing’s for sure: If you draw enough lines on a chart, some of them are bound to hit important turning points.
A sample chart is shown in Figure 4.
Figure 4: WEALTH-LAB, ERMANOMETRY. Here is a sample Wealth-Lab Developer 6.2 chart showing the Ermanometry/Coles barchart markup applied to a daily chart. The Erman bars are red and the Coles series are blue.
_TD_Seq_Setup (Indicator){ TASC Article, September 2011 }{ Tom DeMark TD Sequential Setup }inputs: Price( Close ), DotOffsetTicks( 5 ) ;variables: MyTick( MinMove / PriceScale ), LongCount( 0 ), ShortCount( 0 ) ;LongCount = Iff( Price < Price[4], LongCount + 1, 0 ) ;ShortCount = Iff( Price > Price[4], ShortCount + 1, 0 ) ;{ Buy Setup }if LongCount = 9 and Price[9] > Price[13] then Plot1( L - DotOffsetTicks * MyTick, "TD Buy SU" )else NoPlot( 1 ) ;{ Sell Setup }if ShortCount = 9 and Price[9] < Price[13] then Plot2( H + DotOffsetTicks * MyTick, "TD Sell SU" )else NoPlot( 2 ) ;_Ermanometry (Indicator){ TASC Article, September 2011 }{ Ermanometry - William Erman }inputs: StartBarDate( 1110101 ), { EasyLanguage bar Date for start bar } StartBarTime( 0900 ), { EasyLanguage bar Time for start bar } EF( 1 ), { number of bars of first leg } DE( 1 ), { number of bars of second leg } PlotColes( true ), { include plots for Coles additions } DotOffsetTicks( 5 ) ;variables: MyTick( MinMove / PriceScale ), StartBar( 0 ), X( 0 ), Ratio( 0 ), InverseRatio( 0 ), CD( 0 ), BC( 0 ), AB( 0 ), FG( 0 ), GH( 0 ), HI( 0 ), IJ( 0 ), FH( 0 ) ;if Date = StartBarDate and Time = StartBarTime then StartBar = CurrentBar ;X = Iff( StartBar > 0, CurrentBar - StartBar, 0 ) ;if DE > 0 then Ratio = EF / DE ;if Ratio > 0 then InverseRatio = 1 / Ratio ;CD = DE * InverseRatio ;BC = CD * InverseRatio ;AB = BC * InverseRatio ;FG = EF * Ratio ;GH = FG * Ratio ;HI = GH * Ratio ;IJ = HI * Ratio ;FH = SquareRoot( Power( FG, 2 ) + Power( GH, 2 ) ) ;{ Erman }Condition1 = X = IntPortion( FH ) ;Condition2 = X = IntPortion( GH ) ; Condition3 = X = IntPortion( HI ) ; Condition4 = X = IntPortion( IJ ) ; Condition5 = X = IntPortion( DE + EF + CD ) ; Condition6 = X = IntPortion( GH + HI + IJ ) ; Condition7 = X = IntPortion( CD + DE + EF + FG + GH + HI ) ; Condition8 = X = IntPortion( EF + FG + GH ) ;Condition9 = X = IntPortion( CD + DE + EF + FG + GH ) ;Condition10 = X = IntPortion( CD + DE + EF + FG + GH + HI ) ; Condition11 = X = IntPortion( GH + IJ + CD + AB + EF ) ;{ Coles }Condition12 = X = IntPortion( FH + FG + GH ) ;Condition13 = X = IntPortion( AB + BC + CD + DE ) ; Condition14 = X = IntPortion( AB + BC + CD + DE + GH ) ; Condition15 = X = IntPortion( FG + GH ) ; Condition16 = X = IntPortion( GH + HI ) ; Condition17 = X = IntPortion( FG + BC + CD ) ; Condition18 = X = IntPortion( FG + BC + CD + DE ) ; Condition19 = X = IntPortion( CD + BC ) ; Condition20 = X = IntPortion( DE + BC ) ; Condition21 = X = IntPortion( SquareRoot( Power(CD, 2) + Power( DE, 2 ) ) + CD + DE ) ; Condition22 = X = IntPortion( SquareRoot( Power(EF, 2) + Power( FG, 2 ) )+ EF + FG ) ; { Erman Condition }Condition23 = Condition1 or Condition2 or Condition3 or Condition4 or Condition5 or Condition6 or Condition7 or Condition8 or Condition9 or Condition10 or Condition11 ; { Coles Condition }Condition24 = Condition12 or Condition13 or Condition14 or Condition15 or Condition16 or Condition17 or Condition18 or Condition19 or Condition20 or Condition21 or Condition22 ;if Condition23 or ( PlotColes and Condition24 ) and StartBar > 0 then Plot1( L - DotOffsetTicks * MyTick, "Ermanometry" )else NoPlot( 1 ) ;
—Eugene
Figure 5: AMIBROKER, TD SEQUENTIAL. Here is a 30-minute British pound futures chart with a DeMark buy (green) and sell (red) Setup example.
LISTING 1// TD Sequential Setup Plot( C, "Price", colorBlack, styleCandle ); y = ParamField("Price field"); Buy = Sum( y < Ref( y, -4 ), 9 ) == 9 AND Ref( y, -9) > Ref( y, -13 ); Sell = Sum( y > Ref( y, -4 ), 9 ) == 9 AND Ref( y, -9) < Ref( y, -13 ); PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, L, H ) );LISTING 2// Ermanometry Plot( C, "Price", colorBlack, styleCandle ); dt = DateTime(); Start = dt == SelectedValue( dt ); EF = Param("Seed Seg EF", 48, 1, 900 ); DE = Param("Seed Seg DE", 40, 1, 900 ); Ratio = EF/DE; InverseRatio = 1/Ratio; x = BarsSince( start ); CD = DE * Inverseratio; BC = CD * Inverseratio; AB = BC * Inverseratio; FG = EF* Ratio; GH = FG * Ratio; HI = GH * Ratio; IJ = HI * Ratio; FH = sqrt( FG ∧ 2 + GH ∧ 2 ); Erman = x == int(FH) OR /* Erman */ x == int(GH) OR /* Erman */ x == int(HI) OR /* Erman */ x == int(IJ) OR /* Erman */ x == int(DE+EF+CD) OR /* Erman */ x == int(GH+HI+IJ) OR /* Erman */ x == int(CD+DE+EF+FG+GH+HI) OR /* Erman */ x == int(EF+FG+GH) OR /* Erman */ x == int(CD+DE+EF+FG+GH) OR /* Erman */ x == int(CD+DE+EF+FG+GH+HI) OR /* Erman */ x == int(GH+IJ+CD+AB+EF); /* Erman */ Plot( Erman, "Erman", colorRed, styleHistogram | styleOwnScale ); FH = sqrt( FG ∧ 2 + GH ∧ 2 ); Coles = x == int(FH+FG+GH) OR /* Coles */ x == int(AB+BC+CD+DE) OR /* Coles */ x == int(AB+BC+CD+DE+GH) OR /* Coles */ x == int(FG+GH) OR /* Coles */ x == int(GH+HI) OR /* Coles */ x == int(FG+BC+CD) OR /* Coles */ x == int(FG+BC+CD+DE) OR /* Coles */ x == int(CD+BC) OR /* Coles */ x == int(DE+BC) OR /* Coles */ x == int(sqrt(CD∧2+DE∧2)+CD+DE) OR /* Coles */ x == int(sqrt(EF∧2+FG∧2)+EF+FG); /* Coles */ Plot( Coles, "Coles", colorGreen, styleHistogram | styleOwnScale );
—Tomasz Janeczko, AmiBroker.com
NEUROSHELL TRADER: INTRADAY APPLICATION OF TD SEQUENTIAL AND ERMANOMETRY
The TD Sequential Setup and Ermanometry indicators described by Andrew Coles in his article in this issue, “TD Sequential And Ermanometry For Intraday Traders,” can be easily implemented with a few of NeuroShell Trader’s 800+ indicators. Select “New Indicator” from the Insert menu and use the indicator wizard to recreate the following indicators:
TD BuySetup: AND2( A=B( Sum( A<B(Price, Lag(Price,4) ), 9), 9), A>B( Lag(Price,9), Lag(Price,13) ) )TD Sell Setup: AND2( A=B( Sum( A>B(Price, Lag(Price,4) ), 9), 9), A<B( Lag(Price,9), Lag(Price,13) ) )Ratio: Divide( EF, DE )InverseRatio: Divide( 1, Divide( EF, DE ) )CD: Multiply2( DE, InverseRatio )BC: Multiply2( CD, InverseRatio )AB: Multiply2( BC, InverseRatio )FG: Multiply2( EF, Ratio )GH: Multiply2( FG, Ratio )HI: Multiply2( GH, Ratio )IJ: Multiply2( HI, Ratio )FH: SqrRt( Add2( Power(FG,2), Power(GH,2) ) )BarsSince: BarsSinceCond( And2( DateIS(Year, Month, Day), TimeIS(Hour, Minute, Second, 0.25)))Ermanometry Series Time Target: Or2(Or4(Or4(A=B(BarsSince,Quotient(FH,1)),A=B(BarsSince,Quotient(GH,1)),A=B(BarsSince,Quotient(HI,1)),A=B(BarsSince,Quotient(IJ,1))),Or4(A=B(BarsSince,Quotient(Add3(DE,EF,CD),1)),A=B(BarsSince,Quotient(Add3(GH,HI,IJ),1)),A=B(BarsSince,Quotient(Add2(Add3(CD,DE,EF),Add3(FG,GH,HI)),1)),A=B(BarsSince,Quotient(Add3(EF,FG,GH),1))),Or4(A=B(BarsSince,Quotient(Add2(CD,Add4(DE,EF,FG,GH))),1)),A=B(BarsSince,Quotient(Add3(CD,DE,Add4(EF,FG,GH,HI))),1)),A=B(BarsSince,Quotient(Add2(GH,Add4(IJ,CD,AB,EF)),1)),A=B(BarsSince,Quotient(Add3(FH,FG,GH),1))),Or4(A=B(BarsSince,Quotient(Add4(AB,BC,CD,DE),1)),A=B(BarsSince,Quotient(Add2(AB,Add4(BC,CD,DE,GH))),1)),A=B(BarsSince,Quotient(Add2(FG,GH),1)),A=B(BarsSince,Quotient(Add2(GH,HI),1))),),Or3(Or4(A=B(BarsSince,Quotient(Add3(FG,BC,CD),1)),A=B(BarsSince,Quotient(Add4(FG,BC,CD,DE)),1)),A=B(BarsSince,Quotient(Add2(CD,BC),1)),A=B(BarsSince,Quotient(Add2(DE,BC),1))),A=B(BarsSince,Quotient(Add3(SqrRt(Add2(Power(CD,2),Power(DE,2))),CD,DE),1)),A=B(BarsSince,Quotient(Add3(SqrRt(Add2(Power(EF,2),Power(FG,2))),EF,FG),1))))
Note that the BarsSinceCond indicator is found in the Advanced Indicator Set 2 add-on, while the DateIs and TimeIs indicators are found in the Advanced Indicator Set 3 add-ons.
Users of NeuroShell Trader can go to the Stocks & Commodities section of the NeuroShell Trader free technical support website to download a copy of this or any previous Traders’ Tips.
A sample chart is shown in Figure 6.
Figure 6: NEUROSHELL TRADER, TD SEQuENTIAL AND ERMANOMETRY. This sample NeuroShell Trader chart shows the TD Sequential Setup and the Ermanometry indicators.
MONEY FLOW INDICATORS
For this month’s Traders’ Tip, I will provide Aiq code based the July 2011 article by Markos Katsanos, “Comparing Seven Money Flow Indicators.”
The amount of code that I have converted is quite extensive and includes the seven money flow indicators as well as the code for the 14 systems that Katsanos used to make comparative tests of the seven indicators. All of the code and systems are set up as one Eds file, available for download from www.TradersEdgeSystems.com/traderstips.htm. The code is also shown here. Time did not permit me to run the comparative tests that were shown in the article.
! COMPARING SEVEN MONEY FLOW INDICATORS! Author: Markos Katsanos, TASC July 2011! Coded by: Richard Denning 7/17/2011! www.TradersEdgeSystems.com!Shown here is the AIQ code for the direction and divergence systems based !on the seven money-flow indicators discussed in Markos Katsanos' article in the !July 2011 issue of Technical Analysis of Stocks & Commodities, "Comparing Seven Money Flow Indicators." !Here are some notes on the systems from author Markos Katsanos:!The moving average period and money flow level parameters were optimized for each system.!All systems are similar and use only money flow criteria except for the volume oscillator,!which was used to confirm a price-based indicator.!There is no need to create any additional functions because all necessary code for the money!flow indicators is included in each system.!If you wish to replicate the tests, keep in mind that for the test to begin producing signals,!the indicators and linear regression should first be calculated, and this requires a number of!bars to be loaded first and the test start date to be adjusted backwards.!For all the following tests (except the VFI), I loaded 81 additional bars !(21 bars for the money flow + 60 bars for the moving average calculation) and moved the test !start date 81 trading days earlier to 07/07/2000, so that each test could start producing trades from 10/31/2000.!MONEY FLOW DIRECTION SYSTEMS!FVE direction test!INPUTS:MFPERIOD1 is 21.MABUY1 is 60.MASELL1 is 60.FVEBUY1 is 10.FVESELL1 is 0.XTIME is 42.SDBARS is 30.PREV is 7.SDCR1 is 0.5.!FVE CALCULATIONTP is ([High] + [Low] + [Close])/3.TP1 is valresult(TP,1).INTRA1 is LN([High])-LN([Low]).VINTRA1 is sqrt(variance(INTRA1,MFPERIOD1)).INTER1 is LN(TP)- LN(TP1).VINTER1 is sqrt(variance(INTER1,MFPERIOD1)).CUTOFF1 is 0.1*VINTRA1 + 0.1*VINTER1.MF1 is ([Close] - ([High] + [Low])/2)+ TP-TP1.FveFactor1 is iff( MF1>CutOff1*[Close],1,iff(MF1<-1*CutOff1*[Close],-1,0)).VolumePlusMinus1 is [Volume] * FveFactor1.VA is simpleavg([Volume],MFPERIOD1).FVEsum is Sum(VolumePlusMinus1,MFPERIOD1).FVE is iff( VA<>0,(FVEsum /(VA*MFPERIOD1))*100,0).avgFVE is simpleavg(FVE,MABUY1).avgFVEsell is simpleavg(FVE,MASELL1).!BUYSetup1 if FVE > avgFVE and valrule(FVE < avgFVE,1) and FVE>FVEBUY1 and FVE-valresult(FVE,PREV)> SDCR1*Sqrt(variance(FVE,SDBARS,1)).!BUY("MA") NEXT BAR AT CLOSE+.05*C/100 STOP;EntryPr is val([close],1)*(1+0.05/100).BUY_FVE if valrule(Setup1,1) and [high] > EntryPr.!SELLSELL_FVE if (FVE < avgFVEsell and valrule(FVE >= avgFVEsell,1) and FVE < FVESELL1) or {position days} >= XTIME.!VFI direction test!INPUTs:PERIOD2 is 130. MABUY2 is 40. MASELL2 is 30. MFBUY2 is 0. MFSELL2 is 0. !SDBARS is 30. !PREV is 7. SDCR2 is 0.! VFI CALCULATIONInter2 is iff(TP<>0 and TP1<>0,Ln(TP) - Ln(TP1), 0).VInter2 is sqrt(variance( Inter2, 30 )).CutOff2 is 0.2 * VInter2 * [Close].VAve2 is simpleavg([Volume],PERIOD2,1).VMax2 is VAve2 * 2.5.VC2 is iff([Volume] < VMax2 , [Volume], VMax2).MF2 is TP - TP1.DirectionalVolume2 is iff(MF2 > CutOff2, VC2, iff( MF2 < -CutOff2, -VC2, 0)).VFI is iff(VAve2<>0,Sum(DirectionalVolume2, PERIOD2) / Vave2,0). myVFI is expavg(VFI, 3).avgVFI is simpleavg(myVFI,MABUY2). avgVFIsell is simpleavg(myVFI,MASELL2). !BUYSetup2 if myVFI > avgVFI and valrule(myVFI <= avgVFI,1) and myVFI > MFBUY2 and myVFI-valresult(myVFI,PREV) > SDCR2*sqrt(variance(myVFI,SDBARS,1)).BUY_VFI if valrule(Setup2,1) and [high] > EntryPr.!SELLSELL_VFI if (myVFI < avgVFIsell and valrule(myVFI >= avgVFIsell,1) and myVFI < MFSELL2) or {position days} >= XTIME.!CMF direction test!INPUTS:MFPERIOD3 is 21. MABUY3 is 50. MASELL3 is 40. MFBUY3 is 5. MFSELL3 is -5. !XTIME is 42. !SDBARS is 30. !PREV is 7. SDCR3 is 1.!CMF CALCULATIONAccDist is iff( ([high] - [low])*[volume] <> 0,(([close]-[low])-([high]-[close])) / ([high] - [low]) * [volume],0).CMF is sum(AccDist, MFPERIOD3) / sum([volume], MFPERIOD3)*100 .avgCMF is simpleavg(CMF,MABUY3).avgCMFsell is simpleavg(CMF,MASELL3).!BUYSetUp3 if CMF > avgCMF and valrule(CMF <= avgCMF,1) and CMF > MFBUY3 AND CMF-valresult(CMF,PREV) > SDCR3*sqrt(variance(CMF,SDBARS,1)).BUY_CMF if valrule(SetUp3,1) and [high] > EntryPr. !EXITSELL_CMF if (CMF < avgCMFsell and valrule(CMF >= avgCMFsell,1) AND CMF < MFSELL3) or {position days} >= XTIME.!MFI direction test!INPUTS:MFPERIOD4 is 21. MABUY4 is 50. MASELL4 is 30. MFBUY4 is 50. MFSELL4 is 60. !XTIME is 42. !PREV is 7. SDCR4 is 1.!MFI CALCULATIONPosMF is iff(TP > TP1,TP*[volume],0).UpSum is Sum(PosMF,MFPERIOD4).!DnSum is Sum(NegMF,MFPERIOD4).MFI is UpSum/sum(TP*[volume],MFPERIOD4)*100.avgMFI is simpleavg(MFI,MABUY4).avgMFIsell is simpleavg(MFI,MASELL4).!BUYMFIr1 if MFI > avgMFI and valrule(MFI <= avgMFI,1).MFIr2 if MFI > MFBUY4.MFIr3 if MFI-valresult(MFI,PREV) > SDCR4*sqrt(variance(MFI,30,1)).MFIr4 if [high] > EntryPr.MFIdiff is MFI-valresult(MFI,PREV).MFIvar is SDCR4*sqrt(variance(MFI,30,1)).SetUp4 if MFI > avgMFI and valrule(MFI <= avgMFI,1) and MFI > MFBUY4 and MFI-valresult(MFI,PREV) > SDCR4*sqrt(variance(MFI,30,1)).BUY_MFI if valrule(SetUp4,1) and [high] > EntryPr.!EXITSELL_MFI if (MFI < avgMFIsell and valrule(MFI >= avgMFIsell,1) and MFI < MFSELL4) or {position days} >= XTIME.!OBV direction test!INPUTS:MABUY5 is 70. MAFAST5 is 5. MASELL5 is 30. !XTIME is 42. !PREV is 7. SDCR5 is 0.5.! OBV CALCULATIONHD is hasdatafor(252).OBV is sum(iff([Close] > val([Close],1),[Volume],-[Volume]),HD).avgOBV is simpleavg(OBV,MAFAST5).avgOBVbuy is simpleavg(OBV,MABUY5).avgOBVsell is simpleavg(OBV,MASELL5).!BUYSetUp5 if OBV > avgOBV and valrule(OBV <= avgOBV,1) and OBV-valresult(OBV,PREV) > SDCR5*sqrt(variance(OBV,30,1)) and OBV > avgOBVbuy.BUY_OBV if valrule(SetUp5,1) and [high] > EntryPr.!SELLSELL_OBV if OBV < avgOBVsell and valrule(OBV >= avgOBVsell,1) or {position days} >= XTIME.!VPT direction test!INPUTS:MABUY6 is 60. MAFAST6 is 5. MASELL6 is 40. !XTIME is 42. !SDBARS is 30. !PREV is 7. SDCR6 is 1.5.! VOLUME-PRICE TREND CALCULATIONVPT is sum([Volume]*([Close]/val([Close],1)-1),HD).avgVPT is simpleavg(VPT,MAFAST6).avgVPTbuy is simpleavg(VPT,MABUY6).avgVPTsell is simpleavg(VPT,MASELL6).!BUYSetup6 if VPT > avgVPT and valrule(VPT <= avgVPT,1) and VPT-valresult(VPT,PREV)> SDCR6*sqrt(variance(VPT,SDBARS,1)) and VPT>avgVPTbuy.BUY_VPT if valrule(SetUp6,1) and [high] > EntryPr.!SELLSELL_VPT if VPT < avgVPTsell or {position days} >= XTIME.!Volume oscillator direction test!INPUTS:MFBUY7 is 25. MFSELL7 is 25. !XTIME is 42. FastLen7 is 5. SlowLen7 is 21. MAPRICE7 is 50. MACSELL7 is 10.! VolumeOsc CALCULATIONVolumeOsc is (expavg([Volume],FastLen7) / expavg([Volume],SlowLen7)-1)*100.!BUYSetUp7 if VolumeOsc > MFBUY7 and valrule(VolumeOsc <= MFBUY7,1) and [Close] > simpleavg([Close],MAPRICE7).BUY_VolOsc if valrule(SetUp7,1) and [high] > EntryPr.!SELLSELL_VolOsc if [Close] < simpleavg([Close],MACSELL7) and VolumeOsc > MFSELL7 or {position days} >= XTIME. !FVE divergence test!INPUTS:!MFPERIOD is 21. LRSBARS is 40. STOCHBARS is 10. STAVGBARS is 6. !XTIME is 42. FVEBUY8 is 0. MASELL is 50.!STOCHASTICSTOCH is (simpleavg([Close]-loval([Low],STOCHBARS),3)*100)/(simpleavg(hival([High],STOCHBARS)-loval([Low],STOCHBARS),3)).STOCHAVG is simpleavg(STOCH,STAVGBARS).!BUYDV_BUY_FVE if Slope([Close],LRSBARS)<0 and Slope2(FVE,LRSBARS)>0 and STOCH > STOCHAVG and valrule(STOCH <= STOCHAVG,1) and FVE > FVEBUY8.!SELLDV_SELL_FVE if (Slope([Close],LRSBARS)>0 and Slope2(FVE,LRSBARS)<0 and FVE > simpleavg(FVE,MASELL) and valrule(FVE <= simpleavg(FVE,MASELL),1)) or {position days} >= XTIME.!VFI divergence test!INPUTs:!MFPERIOD is 130. !LRSBARS is 40. !STOCHBARS is 10. !STAVGBARS is 6. !XTIME is 42. MFBUY9 is 0. !MASELL is 50.!BUYDV_BUY_VFI if Slope([Close],LRSBARS)<0 AND Slope2(VFI,LRSBARS)>0 and STOCH > STOCHAVG and valrule(STOCH <= STOCHAVG,1) and VFI > MFBUY9.!SELLDV_SELL_VFI if (Slope([Close],LRSBARS)>0 and Slope2(VFI,LRSBARS)<0 and VFI < simpleavg(VFI,MASELL) and valrule(VFI >= simpleavg(VFI,MASELL),1)) or {position days} >= XTIME.!VPT divergence test!INPUTS:!LRSBARS is 40. !STOCHBARS is 10. !STAVGBARS is 6. !XTIME is 42. !MASELL is 50.!BUYDV_BUY_VPT IF Slope([Close],LRSBARS)<0 AND Slope2(VPT,LRSBARS)>0 and STOCH > STOCHAVG and valrule(STOCH <= STOCHAVG,1).!SELLDV_SELL_VPT if (Slope([Close],LRSBARS)>0 and Slope2(VPT,LRSBARS)<0 and VPT < simpleavg(VPT,MASELL) and valrule(VPT >= simpleavg(VPT,MASELL),1)) or {position days} >= XTIME.!Volume oscillator divergence test!INPUTS:!LRSBARS is 40. !STOCHBARS is 10. !STAVGBARS is 6. !XTIME is 42. !MASELL is 50. FastLen11 is 5. SlowLen11 is 21.!BUYDIV_BUY_VolOsc if slope([Close],LRSBARS)<0 AND Slope2(VolumeOsc,LRSBARS)<0 AND STOCH > STOCHAVG.!SELLDIV_SELL_VolOsc if (Slope([Close],LRSBARS)>0 AND Slope2(VolumeOsc,LRSBARS)<0 and [Close] < simpleavg([Close],MASELL) and valrule([Close] >= simpleavg([Close],MASELL),1)) or {position days} >= XTIME.!CMF divergence test!INPUTS:!MFPERIOD is 21. !LRSBARS is 40. !STOCHBARS is 10. !STAVGBARS is 6. !XTIME is 42. MFBUY12 is 0. !MASELL is 50.!BUYDIV_BUY_CMF if Slope([Close],LRSBARS)<0 AND Slope2(CMF,LRSBARS)>0 and STOCH > STOCHAVG and valrule(STOCH <= STOCHAVG,1) and CMF > MFBUY12.!SELLDIV_SELL_CMF if (Slope([Close],LRSBARS)>0 AND Slope2(CMF,LRSBARS)<0 and CMF > simpleavg(CMF,MASELL) and valrule(CMF <= simpleavg(CMF,MASELL),1)) or {position days} >= XTIME.!MFI divergence test!INPUTs:!MFPERIOD is 21. !LRSBARS is 40. !STOCHBARS is 10. !STAVGBARS is 6. !MASELL is 50. !XTIME is 42.!BUYDIV_BUY_MFI if Slope([Close],LRSBARS)<0 and Slope2(MFI,LRSBARS)>0 and STOCH > STOCHAVG and valrule(STOCH <= STOCHAVG,1).!SELLDIV_SELL_MFI if (Slope([Close],LRSBARS)>0 and Slope2(MFI,LRSBARS)<0 and MFI < simpleavg(MFI,MASELL) and valrule(MFI < simpleavg(MFI,MASELL),1)) or {position days} >= XTIME.!OBV divergence test!INPUTS:!LRSBARS is 40. !STOCHBARS is 10. !STAVGBARS is 6. !XTIME is 42. MASELL14 is 30.!BUYDIV_BUY_OBV if Slope([Close],LRSBARS)<0 and Slope2(OBV,LRSBARS)>0 and STOCH > STOCHAVG and valrule(STOCH <= STOCHAVG,1).!SELLDIV_SELL_OBV if (Slope([Close],LRSBARS)>0 and Slope2(OBV,LRSBARS)<0 and OBV < simpleavg(OBV,MASELL14) and valrule(OBV >= simpleavg(OBV,MASELL14),1)) or {position days} >= XTIME.ShowValues if 1.
TRADERSSTUDIO: MONEY FLOW INDICATORS
For this month’s Traders’ Tip, I will provide TradersStudio code for the July 2011 article by Markos Katsanos, “Comparing Seven Money Flow Indicators.” The amount of code that was converted is quite extensive and includes seven functions that compute the seven money flow indicators as well as the code for the 14 systems that were used to make comparative tests of the seven indicators. Time did not permit me to run the comparative tests that were shown in the article.
The code can be downloaded from the TradersStudio website at www.TradersStudio.com → Traders Resources → FreeCode or www.TradersEdgeSystems.com/traderstips.htm. The code is also shown below.
'COMPARING SEVEN MONEY FLOW INDICATORS'Author: Markos Katsanos, TASC July 2011'Coded by: Richard Denning 7/17/2011'www.TradersEdgeSystems.com' LINEAR REGRESSION FUNCTION 'Parameters' Y specifies which Price Of the asset Of interest is To be used' SLen the number Of trailing bars To consider' TargetB represents the number Of bars into the future Or back into the past' Returns a numeric value containing the current value Of the specified regression line at TargetB.' Changes values of variables rSqrd, slopeR, endVal to those the least squares line computed by the function' R squared (rSqrd) is the measure of how well the line fits the data (will vary from 0 (no fit) to 1.00 (perfect fit)' slope (slopeR) is the rise over run of the line' endVal is the value of the line at the current bar'the regression formulas can be checked using the Excel tutorial on linear regression found at:'http://phoenix.phys.clemson.edu/tutorials/excel/regression.htmlFunction LinearRegSRV(Y As BarArray, SLen, TargetB, ByRef rSqrd, ByRef slopeR, ByRef endVal) As BarArray Dim X As BarArray Dim Num1 As BarArray Dim Num2 As BarArray Dim SumX As BarArray Dim SumSqrX As BarArray Dim SumY As BarArray Dim SumSqrY As BarArray Dim SumXY As BarArray Dim Slope As BarArray Dim Intercept As BarArray If SLen <= 0 Then LinearRegSRV = 0 Else SumX = 0 SumSqrX = 0 SumY = 0 SumSqrY = 0 SumXY = 0 'Sum2 = 0 For X = 0 To SLen - 1 SumX = SumX + X SumSqrX = SumSqrX + X * X SumY = SumY + Y[X] SumSqrY = SumSqrY + Y[X] * Y[X] SumXY = SumXY + X * Y[X] Next 'SumY = Summation(Price, SLen) 'SumBars = SLen * (SLen - 1) * .5 'SumSqrBars = (SLen - 1) * SLen * (2 * SLen - 1) / 6 'Sum2 = SumBars * SumY 'Num1 = SLen * Sum1 - Sum2 'Num2 = SumBars * SumBars -SLen * SumSqrBars 'slope If (SumSqrX - SumSqrY) <> 0 Then 'Slope = Num1 / Num2 Slope = (SumXY - SumX * SumY) / (SumSqrX - SumSqrY) Else Slope = 0 End If 'intercept Intercept = (SumY - Slope * SumX) / SLen slopeR = Slope 'R squared If (Sqr((SumSqrX - SumX*SumX)*(SumSqrY - SumY * SumY))) <> 0 Then rSqrd = (SumXY - SumX * SumY) / (Sqr((SumSqrX - SumX*SumX)*(SumSqrY - SumY * SumY))) Else rSqrd = 0 End If 'end value of linear regression line endVal = Intercept + Slope * (SLen - 1) 'projected value of linear regression line at target bar LinearRegSRV = Intercept + Slope * (SLen - 1 - TargetB) End IfEnd FunctionFunction STOCH_AVG(STOCHBARS,STAVGBARS,byref STOCH) As BarArray 'Dim STOCH As BarArray If BarNumber>STOCHBARS Then If Average(Highest(H, STOCHBARS, 0)-Lowest(L, STOCHBARS, 0), 3, 0)>0 Then STOCH=(Average(C-Lowest(L, STOCHBARS, 0), 3, 0)*100)/(Average(Highest(H, STOCHBARS, 0)-Lowest(L, STOCHBARS, 0), 3, 0)) Else STOCH=100 End If STOCH_AVG=Average(STOCH, STAVGBARS, 0) End IfEnd FunctionFunction Summation(Price As BarArray, Length) as bararray Dim Counter Dim CSum As BarArray Counter = 0 CSum = 0 CSum = 0 For Counter = 0 To Length - 1 CSum = CSum + Price[Counter] Next Summation = CSumEnd FunctionFunction FVE(MFPERIOD) Dim tp As BarArray Dim tp1 As BarArray Dim mf As BarArray Dim VolumePlusMinus As BarArray Dim FveSum As BarArray Dim ATRindi As BarArray Dim FveFactor As BarArray Dim intra As BarArray Dim inter As BarArray Dim vintra As BarArray Dim vinter As BarArray Dim cutoff As BarArray Dim va As BarArray tp=(H + L + C)/3 tp1=(H[1]+L[1]+C[1])/3 intra=Log(High)-Log(Low) vintra=StdDev(intra,MFPERIOD) inter=Log(tp)-Log(tp1) vinter=StdDev(inter,MFPERIOD) cutoff=0.1*vintra+0.1*vinter mf=(C - (H + L)/2)+ tp - tp1 If mf>cutoff*C Then FveFactor=1 Else If mf<-1*cutoff*C Then FveFactor=-1 Else FveFactor=0 End If End If 'If BarNumber> MFPERIOD Then VolumePlusMinus = Vol * FveFactor va=Average(Vol, MFPERIOD, 0) FveSum = Average(VolumePlusMinus,MFPERIOD,0)*MFPERIOD If va<>0 Then FVE=(FveSum /(va*MFPERIOD))*100 Else FVE=0 End If 'End IfEnd FunctionSub DIR_FVE_SYS(MFPERIOD, MABUY, MASELL, FVEBUY, FVESELL, XTIME, SDBARS, PREV, SDCR) 'MFPERIOD = 21 'MABUY = 60 'MASELL = 60 'FVEBUY = 10 'FVESELL = 0 'XTIME = 42 'SDBARS = 30 'PREV = 7 'SDCR = 0.5 Dim myFVE As BarArray Dim avgFVE As BarArray myFVE = FVE(MFPERIOD) avgFVE = Average(myFVE, MABUY, 0) If CrossesOver(myFVE,avgFVE ) And myFVE>FVEBUY And myFVE-myFVE[PREV]> SDCR*StdDev(myFVE,SDBARS,1) Then Buy("BUY_FVE_MA", 1, C + 0.05*C/100, Stop, Day) End If If CrossesUnder(myFVE, avgFVE) And myFVE < FVESELL Then ExitLong("MACROSS", "", 1, 0, Market, Day) End If If BarsSinceEntry -1 > XTIME Then ExitLong("XTIME", "", 1, 0, Market, Day) End IfEnd SubSub DIVERG_FVE_SYS(MFPERIOD, LRSBARS, STOCHBARS, STAVGBARS, XTIME, FVEBUY, MAsell) Dim myFVE As BarArray Dim stoch As BarArray Dim stochAvg As BarArray Dim rSqrd,slopeR,endVal,rSqrdFVE,slopeR_FVE,endValFVE,LRC,LR_FVE 'MFPERIOD = 21 'LRSBARS = 40 'STOCHBARS = 10 'STAVGBARS = 6 'XTIME = 42 'FVEBUY = 0 'MAsell = 50 myFVE = FVE(MFPERIOD) stochAvg=STOCH_AVG(STOCHBARS,STAVGBARS,stoch) LRC=LinearRegSRV(C, LRSBARS, 0, rSqrd, slopeR, endVal) LR_FVE=LinearRegSRV(myFVE,LRSBARS,0,rSqrdFVE,slopeR_FVE,endValFVE) If slopeR<0 And slopeR_FVE>0 And CrossesOver(stoch, stochAvg) And myFVE>FVEBUY Then Buy("BUY_FVE_DIV", 1, 0, Market, Day) End If If slopeR>0 And slopeR_FVE<0 And CrossesUnder(myFVE, Average(myFVE, MAsell, 0)) Then ExitLong("NEG_FVE_DIV", "", 1, 0, Market, Day) End If If BarsSinceEntry - 1 > XTIME Then ExitLong("XTIME", "", 1, 0, Market, Day) End IfEnd SubFunction VFI(PERIOD) Dim TP As BarArray Dim TP1 As BarArray Dim Inter As BarArray Dim VInter As BarArray Dim CutOff As BarArray Dim VAve As BarArray Dim VMax As BarArray Dim VC As BarArray Dim MF As BarArray Dim DirectionalVolume As BarArray Dim myVFI As BarArray TP=(High + Low + Close)/3 If TP > 0 And TP[1] > 0 Then Inter = Log(TP) - Log(TP[1]) Else Inter = 0 End If VInter = StdDev(Inter, 30) CutOff = .2 * VInter * Close VAve = Average(V, PERIOD, 1 ) VMax = VAve * 2.5 VC = IFF(V < VMax , V, VMax) MF = TP - TP[1] DirectionalVolume = IFF(MF > CutOff, +VC, IFF(MF < -CutOff, -VC, 0)) If VAve <> 0 Then myVFI = Summation(DirectionalVolume, PERIOD) / VAve Else myVFI = 0 End If myVFI = XAverage(myVFI, 3, 0) VFI = myVFIEnd FunctionSub DIR_VFI_SYS(PERIOD, MABUY, MASELL, MFBUY, MFSELL, XTIME, SDBARS, PREV, SDCR) Dim TP As BarArray Dim TP1 As BarArray Dim Inter As BarArray Dim VInter As BarArray Dim CutOff As BarArray Dim VAve As BarArray Dim VMax As BarArray Dim VC As BarArray Dim MF As BarArray Dim DirectionalVolume As BarArray Dim myVFI As BarArray 'PERIOD = 130 'MABUY = 40 'MASELL = 30 'MFBUY = 0 'MFSELL = 0 'XTIME = 42 'SDBARS = 30 'PREV = 7 'SDCR = 0 myVFI=VFI(PERIOD) 'If BarNumber>PERIOD+MABUY Then If CrossesOver(myVFI, Average(myVFI, MABUY, 0)) And myVFI>MFBUY And myVFI-myVFI[PREV]> SDCR*StdDev(myVFI,SDBARS,1) Then Buy("MA", 1, Close+.05*C/100, Stop, Day) End If 'End If If CrossesUnder(myVFI, Average(myVFI, MASELL, 0)) And myVFI < MFSELL Then ExitLong("", "", 1, 0, Market, Day) End If If BarsSinceEntry - 1 > XTIME Then ExitLong("XTIME", "", 1, 0, Market, Day) End IfEnd SubSub DIVERG_VFI_SYS(MFPERIOD, LRSBARS, STOCHBARS, STAVGBARS, XTIME, MFBUY, MASELL) Dim myVFI As BarArray Dim STOCH As BarArray Dim STOCHAVG As BarArray Dim rSqrd,slopeR,endVal,rSqrdVFI,slopeR_VFI,endValVFI,LRC,LR_VFI 'MFPERIOD = 130 'LRSBARS = 40 'STOCHBARS = 10 'STAVGBARS = 6 'XTIME = 42 'MFBUY = 0 'MASELL = 50 myVFI = FVE(MFPERIOD) STOCHAVG=STOCH_AVG(STOCHBARS,STAVGBARS,STOCH) LRC=LinearRegSRV(C, LRSBARS, 0, rSqrd, slopeR, endVal) LR_VFI=LinearRegSRV(myVFI,LRSBARS,0,rSqrdVFI,slopeR_VFI,endValVFI) 'If BarNumber>LRSBARS+MFPERIOD+30 Then If slopeR<0 And slopeR_VFI>0 And CrossesOver(STOCH, STOCHAVG) And myVFI>MFBUY Then Buy("BUY_VFI_DIV", 1, 0, Market, Day) End If If slopeR>0 And slopeR_VFI<0 And CrossesUnder(myVFI, Average(myVFI, MASELL, 0)) Then ExitLong("NEG_VFI_DIV", "", 1, 0, Market, Day) End If 'End If If BarsSinceEntry - 1 > XTIME Then ExitLong("XTIME", "", 1, 0, Market, Day) End IfEnd SubFunction CMF(MFPERIOD) Dim AccDist As BarArray If High - Low <> 0 And Vol <> 0 Then AccDist = ((C - L) - (H - C)) / (H - L) * Vol End If CMF = summation(AccDist, MFPERIOD) / summation(Vol, MFPERIOD) * 100End FunctionSub DIR_CMF_SYS(MFPERIOD, MABUY, MASELL, MFBUY, MFSELL, XTIME, SDBARS, PREV, SDCR) Dim AccDist As BarArray Dim myCMF As BarArray 'MFPERIOD = 21 'MABUY = 50 'MASELL = 40 'MFBUY = 5 'MFSELL = -5 'XTIME = 42 'SDBARS = 30 'PREV = 7 'SDCR = 1 myCMF = CMF(MFPERIOD) If CrossesOver(myCMF, Average(myCMF, MABUY, 0)) And myCMF>MFBUY And myCMF-myCMF[PREV]> SDCR*StdDev(myCMF,SDBARS,1) Then Buy("MA", 1, Close + 0.05*C/100, Stop, Day) End If If CrossesUnder(myCMF, Average(myCMF, MASELL, 0)) And myCMF < MFSELL Then ExitLong("SELLMACROSS", "", 1, 0, Market, Day) End If If BarsSinceEntry - 1 > XTIME Then ExitLong("XTIME", "", 1, 0, Market, Day) End IfEnd SubSub DIVERG_CMF_SYS(MFPERIOD, LRSBARS, STOCHBARS, STAVGBARS, XTIME, MFBUY, MASELL) Dim myCMF As BarArray Dim STOCH As BarArray Dim STOCHAVG As BarArray Dim rSqrd,slopeR,endVal,rSqrdCMF,slopeR_CMF,endValCMF,LRC,LR_CMF 'MFPERIOD = 21 'LRSBARS = 40 'STOCHBARS = 10 'STAVGBARS = 6 'XTIME = 42 'MFBUY = 0 'MASELL = 50 myCMF=CMF(MFPERIOD) STOCHAVG=STOCH_AVG(STOCHBARS,STAVGBARS,STOCH) LRC=LinearRegSRV(C, LRSBARS, 0, rSqrd, slopeR, endVal) LR_CMF=LinearRegSRV(myCMF,LRSBARS,0,rSqrdCMF,slopeR_CMF,endValCMF) If slopeR<0 And slopeR_CMF>0 And CrossesOver(STOCH, STOCHAVG) And myCMF>MFBUY Then Buy("BUY_CMF_DIV", 1, 0, Market, Day) End If If slopeR>0 And slopeR_CMF<0 And CrossesUnder(myCMF, Average(myCMF, MASELL, 0)) Then ExitLong("NEG_CMF_DIV", "", 1, 0, Market, Day) End If If MarketPos(0)=1 And BarsSinceEntry-1>XTIME Then ExitLong("XTIME", "", 1, 0, Market, Day) End IfEnd SubFunction MFI(MFPERIOD) As BarArray Dim TP As BarArray Dim POSMF As BarArray 'Dim NEGMF As BarArray Dim UpSum As BarArray 'Dim DnSum As BarArray If BarNumber>MFPERIOD Then TP = (H+L+C)/3 POSMF=IFF(TP > TP[1],TP * V,0) UpSum=Summation(POSMF,MFPERIOD) 'DnSum=Summation(NEGMF,MFPERIOD) MFI=UpSum*100/SUMMATION(TP*V,MFPERIOD) End IfEnd FunctionSub DIR_MFI_SYS(MFPERIOD, MABUY, MASELL, MFBUY, MFSELL, XTIME, PREV, SDCR) Dim TP As BarArray Dim POSMF As BarArray Dim NEGMF As BarArray Dim UpSum As BarArray Dim DnSum As BarArray Dim myMFI As BarArray 'MFPERIOD = 21 'MABUY = 50 'MASELL = 30 'MFBUY = 50 'MFSELL = 60 'XTIME = 42 'PREV = 7 'SDCR = 1 'If BarNumber>MFPERIOD Then myMFI = MFI(MFPERIOD) 'End If If CrossesOver(myMFI, Average(myMFI, MABUY, 0)) And myMFI > MFBUY And myMFI-myMFI[PREV] > SDCR*StdDev(myMFI,30,1) Then Buy("MFI", 1, Close+.05*C/100, Stop, Day) End If If CrossesUnder(myMFI, Average(myMFI, MASELL, 0)) And myMFI < MFSELL Then ExitLong("SELLMACROSS", "", 1, 0, Market, Day) End If If BarsSinceEntry - 1 > XTIME Then ExitLong("XTIME", "", 1, 0, Market, Day) End IfEnd SubSub DIVERG_MFI_SYS(MFPERIOD, LRSBARS, STOCHBARS, STAVGBARS, MASELL, XTIME) Dim myMFI As BarArray Dim STOCH As BarArray Dim STOCHAVG As BarArray Dim rSqrd,slopeR,endVal,rSqrdMFI,slopeR_MFI,endValMFI,LRC,LR_MFI 'MFPERIOD = 21 'LRSBARS = 40 'STOCHBARS = 10 'STAVGBARS = 6 'MASELL = 50 'XTIME = 42 myMFI=MFI(MFPERIOD) STOCHAVG=STOCH_AVG(STOCHBARS,STAVGBARS,STOCH) LRC=LinearRegSRV(C, LRSBARS, 0, rSqrd, slopeR, endVal) LR_MFI=LinearRegSRV(myMFI,LRSBARS,0,rSqrdMFI,slopeR_MFI,endValMFI) 'If BarNumber>MFPERIOD+LRSBARS Then If slopeR<0 And slopeR_MFI>0 And CrossesOver(STOCH, STOCHAVG) Then Buy("BUY_MFI_DIV", 1, 0, Market, Day) End If If slopeR>0 And slopeR_MFI<0 And CrossesUnder(myMFI, Average(myMFI, MASELL, 0)) Then ExitLong("NEG_MFI_DIV", "", 1, 0, Market, Day) End If 'End If If BarsSinceEntry-1>XTIME Then ExitLong("XTIME", "", 1, 0, Market, Day) End IfEnd SubFunction OBV() As BarArray If Close > Close[1] Then OBV = OBV[1] + Vol Else If Close < Close[1] Then OBV = OBV[1] - Vol Else OBV = OBV[1] End If End IfEnd FunctionSub DIR_OBV_SYS(MABUY, MAFAST, MASELL, XTIME, PREV, SDCR) Dim myOBV As BarArray 'MABUY = 70 'MAFAST = 5 'MASELL = 30 'XTIME = 42 'PREV = 7 'SDCR = 0.5 myOBV = OBV() 'If BARNUMBER>=21+MABUY Then If CrossesOver(myOBV, Average(myOBV, MAFAST, 0)) AND myOBV-myOBV[PREV]> SDCR*StdDev(myOBV,30,1) AND myOBV>Average(myOBV, MABUY, 0) Then Buy("BUY_OBV_DIR", 1, CLOSE+.05*C/100, Stop, Day) End If 'End If If CrossesUnder(myOBV, Average(myOBV, MASELL, 0)) Then ExitLong("MACROSS", "", 1, 0, Market, Day) End If If MarketPos(0)=1 and barssinceentry-1>Xtime Then ExitLong("XTIME", "", 1, 0, Market, Day) End IfEnd SubSub DIVERG_OBV_SYS(LRSBARS, STOCHBARS, STAVGBARS, XTIME, MASELL) Dim myOBV As BarArray Dim STOCH As BarArray Dim STOCHAVG As BarArray Dim rSqrd,slopeR,endVal,rSqrdOBV,slopeR_OBV,endValOBV,LRC,LR_OBV 'LRSBARS = 40 'STOCHBARS = 10 'STAVGBARS = 6 'XTIME = 42 'MASELL = 30 myOBV=OBV() STOCHAVG=STOCH_AVG(STOCHBARS,STAVGBARS,STOCH) LRC=LinearRegSRV(C, LRSBARS, 0, rSqrd, slopeR, endVal) LR_OBV=LinearRegSRV(myOBV,LRSBARS,0,rSqrdOBV,slopeR_OBV,endValOBV) 'If BarNumber>=LRSBARS Then If slopeR<0 And slopeR_OBV>0 And CrossesOver(STOCH, STOCHAVG) Then Buy("BUY_OBV_DIV", 1, 0, Market, Day) End If If slopeR>0 And slopeR_OBV<0 And CrossesUnder(myOBV, Average(myOBV, MASELL, 0)) Then ExitLong("NEG_OBV_DIV", "", 1, 0, Market, Day) End If 'End If If BarsSinceEntry-1>XTIME Then ExitLong("XTIME", "", 1, 0, Market, Day) End IfEnd SubFunction VPT() As BarArray VPT = VPT[1] + V*(C-C[1])/C[1]End FunctionSub DIR_VPT_SYS(MABUY, MAFAST, MASELL, XTIME, SDBARS, PREV, SDCR) Dim myVPT As BarArray 'MABUY = 60 'MAFAST = 5 'MASELL = 40 'XTIME = 42 'SDBARS = 30 'PREV = 7 'SDCR = 1.5 myVPT = VPT() 'If BarNumber>=21+MABUY Then If CrossesOver(myVPT, Average(myVPT, MAFAST, 0)) And myVPT-myVPT[PREV]> SDCR*StdDev(myVPT,SDBARS,1) And myVPT>Average(myVPT, MABUY,0) Then Buy("BUY_VPT_DIR", 1, Close+.05*C/100, Stop, Day) End If If CrossesUnder(myVPT, Average(myVPT, MASELL, 0)) Then ExitLong("VPTX", "", 1, 0, Market, Day) End If 'End If If BarsSinceEntry-1>XTIME Then ExitLong("XTIME", "", 1, 0, Market, Day) End IfEnd SubSub DIVERG_VPT_SYS(LRSBARS, STOCHBARS, STAVGBARS, XTIME, MASELL) Dim myVPT As BarArray Dim STOCH As BarArray Dim STOCHAVG As BarArray Dim rSqrd,slopeR,endVal,rSqrdVPT,slopeR_VPT,endValVPT,LRC,LR_VPT 'LRSBARS = 40 'STOCHBARS = 10 'STAVGBARS = 6 'XTIME = 42 'MASELL = 50 myVPT= VPT() STOCHAVG=STOCH_AVG(STOCHBARS,STAVGBARS,STOCH) LRC=LinearRegSRV(C, LRSBARS, 0, rSqrd, slopeR, endVal) LR_VPT=LinearRegSRV(myVPT,LRSBARS,0,rSqrdVPT,slopeR_VPT,endValVPT) 'If BarNumber>=LRSBARS Then If slopeR<0 And slopeR_VPT>0 And CrossesOver(STOCH, STOCHAVG) Then Buy("BUY_VPT_DIV", 1, 0, Market, Day) End If If slopeR>0 And slopeR_VPT<0 And CrossesUnder(myVPT, Average(myVPT, MASELL, 0)) Then ExitLong("NEG_VPT_DIV", "", 1, 0, Market, Day) End If 'End If If BarsSinceEntry-1>XTIME Then ExitLong("XTIME", "", 1, 0, Market, Day) End IfEnd SubFunction VolumeOsc(FASTLEN,SLOWLEN) As BarArray If BarNumber>=SLOWLEN Then VolumeOsc=(XAverage(V, FASTLEN, 0)/ XAverage(V, SLOWLEN, 0)-1)*100 End IfEnd FunctionSub DIR_VolOsc_SYS(MFBUY, MFSELL, XTIME, FAST_LEN, SLOW_LEN, MAPRICE, MACSELL) Dim VolOsc As BarArray 'MFBUY = 25 'MFSELL = 25 'XTIME = 42 'Fast_Len = 5 'Slow_Len = 21 'MAPRICE = 50 'MACSELL = 10 VolOsc=VolumeOsc(FAST_LEN,SLOW_LEN) If CrossesOver(VolOsc, MFBUY) And C > Average(C, MAPRICE, 0) Then Buy("BUY_VOLOSC_DIR", 1, Close+.05*C/100, Stop, Day) End If If CrossesUnder(C, Average(C, MACSELL, 0)) And VolOsc > MFSELL Then ExitLong("VOLOSC_X", "", 1, 0, Market, Day) End If If BarsSinceEntry-1>XTIME Then ExitLong("XTIME", "", 1, 0, Market, Day) End IfEnd SubSub DIVERG_VolOsc_SYS(LRSBARS, STOCHBARS, STAVGBARS, XTIME, MASELL, FastLen, SlowLen) Dim myVolOsc As BarArray Dim STOCH As BarArray Dim STOCHAVG As BarArray Dim rSqrd,slopeR,endVal,rSqrdVolOsc,slopeR_VolOsc,endValVolOsc,LRC,LR_VolOsc 'LRSBARS = 40 'STOCHBARS = 10 'STAVGBARS = 6 'XTIME = 42 'MASELL = 50 'FastLen = 5 'SlowLen = 21 myVolOsc=VolumeOsc(FastLen,SlowLen) STOCHAVG=STOCH_AVG(STOCHBARS,STAVGBARS,STOCH) LRC=LinearRegSRV(C, LRSBARS, 0, rSqrd, slopeR, endVal) LR_VolOsc=LinearRegSRV(myVolOsc,LRSBARS,0,rSqrdVolOsc,slopeR_VolOsc,endValVolOsc) 'If BarNumber>=LRSBARS Then If slopeR<0 And slopeR_VolOsc>0 And CrossesOver(STOCH, STOCHAVG) Then Buy("BUY_VolOsc_DIV", 1, 0, Market, Day) End If If slopeR>0 And slopeR_VolOsc<0 AND CrossesUnder(C, Average(C, MASELL, 0)) Then ExitLong("NEG_VolOsc_DIV", "", 1, 0, Market, Day) End If 'End If If BarsSinceEntry-1>XTIME Then ExitLong("XTIME", "", 1, 0, Market, Day) End IfEnd Sub
—Richard Denning
INTRADAY APPLICATION OF TD SEQUENTIAL
INTRADAY APPLICATION OF TD SEQUENTIAL
Although Andrew Coles’ article in this issue, “TD Sequential And Ermanometry For Intraday Traders,” discusses two different formulas, we decided to focus exclusively on Tom DeMark’s TD Sequential indicator. In addition to being originally intended for use with daily price bars, TD Sequential can also be used for backtesting. Ermanometry, on the other hand, uses a number of parameters that must be revised manually for each time period, and therefore cannot be backtested easily.
The issue that immediately arises with TD Sequential is that signals don’t come up very frequently. Running against the S&P 500 stocks from 2000 to the present, TD Sequential produced only 369 trades in our tests. That’s less than one trade every 11 years, per stock. Furthermore, using the TD Sequential sell Setup as the exit, holding periods were nearly four years long. Such long holding periods helped create drawdowns exceeding 50%, which many traders would find unacceptable considering the system’s moderate gains.
As a test, we decided to see how effective TD Sequential would be using only the buy Setup, and relying on alternate indicators for the sell signal. Using the automated search in StrataSearch, we searched thousands of supporting trading rules and found some impressive results. Many indicator combinations had holding periods of one month or less, with percent profitability exceeding 70%. Annual returns were often over 40%, with drawdowns as low as 20%. In short, the TD Sequential indicator can produce some impressive results, but only when paired with the proper supporting indicators.
StrataSearch users can easily search for supporting indicators for the TD Sequential by downloading the plugin from the Shared Area of the StrataSearch user forum. After importing the plugin, simply launch the automated search to explore TD Sequential alongside thousands of supporting trading rules.
A sample chart is shown in Figure 7.
Figure 7: STRATASEARCH, TD SEQUENTIAL. In this system, the buy signal is triggered by the TD Sequential buy Setup, but the sell signal is triggered by a price oscillator divergence.
//*********************************************************// TD Sequential - Buy Setup//*********************************************************value = parameter("Value");TDSequentialBuy = if( HadAlert(value < ref(value, -1), 9) = 9 and ref(value, -9) > ref(value, -13), 1, 0);//*********************************************************// TD Sequential - Sell Setup//*********************************************************value = parameter("Value");TDSequentialSell = if( HadAlert(value > ref(value, -1), 9) = 9 and ref(value, -9) < ref(value, -13), 1, 0);
—Pete Rast
Avarin Systems, Inc.
www.StrataSearch.com
BACK TO LIST
TRADECISION: INTRADAY APPLICATION OF TD SEQUENTIAL AND ERMANOMETRY
In “TD Sequential And Ermanometry For Intraday Traders” in this issue, author Andrew Coles describes how to automate the TD Sequential and Ermanometry techniques to apply to intraday charts.
Below is the Tradecision code to recreate the Ermanometry indicator using Tradecision’s Indicator Builder. Following that is the code to recreate the TD Sequential strategy using Tradecision’s Strategy Builder.
To import the strategy into Tradecision, visit the area “Traders’ Tips from Tasc Magazine” at www.tradecision.com/support/tasc_tips/tasc_traders_tips.htm or copy the code below.
ERMANOMETRY indicator:inputStartingYear:"Starting Year", 2010, 1980, 2100;StartingMonth:"starting month", 1, 1, 12;StartingDay:"starting day of month", 1, 1, 31;StartingHour:"hour", 1, 1, 24;StartingMinute:"minute", 0, 0, 60;EF:"seed segment EF (first wave)", 10, 1, 900;DE:"seed segment DE (second wave)", 10, 1, 900;end_inputvarRatio:=0;Inverseratio:=0;StartBar:=0;StartFound:=false;x:=0;CD:=0;BC:=0;AB:=0;FG:=0;GH:=0;HI:=0;IJ:=0;FH:=0;end_varif HistorySize > 0 then begin startFound:=startFound\1\; StartBar:=startBar\1\; end;if (not startFound and Year = StartingYear and Month = StartingMonth and DayOfMonth = StartingDay and Hour = StartingHour and Minute = StartingMinute) thenbegin startBar:=BarNumber(); startFound:=true;end;if (not startFound) then return 0;Ratio:=EF / DE;Inverseratio:=1 / (EF / DE);CD:=DE * Inverseratio;BC:=CD * Inverseratio;AB:=BC * Inverseratio;FG:=EF * Ratio;GH:=FG * Ratio;HI:=GH * Ratio;IJ:=HI * Ratio;FH:=SquareRoot(Power(FG, 2) + Power(GH, 2));x:= barnumber - startbar;{start of calculations}if x = Int(FH) then return 1; {Erman}if x = Int(GH) then return 1; {Erman}if x = Int(HI) then return 1; {Erman}if x = Int(IJ) then return 1; {Erman}if x = Int(DE + EF + CD) then return 1; {Erman}if x = Int(GH + HI + IJ) then return 1; {Erman}if x = Int(CD + DE + EF + FG + GH + HI) then return 1; {Erman}if x = Int(EF + FG + GH) then return 1; {Erman}if x = Int(CD + DE + EF + FG + GH) then return 1; {Erman}if x = Int(CD + DE + EF + FG + GH + HI) then return 1; {Erman}if x = Int(GH + IJ + CD + AB + EF) then return 1; {Erman}if x = Int(FH + FG + GH) then return 1; {Coles}if x = Int(AB + BC + CD + DE) then return 1; {Coles}if x = Int(AB + BC + CD + DE + GH) then return 1; {Coles}if x = Int(FG + GH) then return 1; {Coles}if x = Int(GH + HI) then return 1; {Coles}if x = Int(FG + BC + CD) then return 1; {Coles}if x = Int(FG + BC + CD + DE) then return 1; {Coles}if x = Int(CD + BC) then return 1; {Coles}if x = Int(DE + BC) then return 1; {Coles}if x = Int(SquareRoot(Power(CD, 2) + Power(DE, 2)) + CD + DE) then return 1; {Coles}if x = Int(SquareRoot(Power(EF, 2) + Power(FG, 2)) + EF + FG) then return 1; {Coles}return 0;
Using Tradecision’s Strategy Builder, one needs to create the TD SEQUENTIAL strategy:
TD SEQUENTIAL strategy:Entry Long:varx:= Close;y:=0;count:=0;i:=0;end_vary:=iff(x = O, O, iff(x = H, H, iff(x = L, L, iff(x = C, L, iff(x = V, V, 0)))));if HISTORYSIZE > 14 then beginfor i := 0 to 9 dobegin if y\i\ < y\4 +i\ then count := count + 1;end;return count = 9 and y\9\ > y\13\;end;return false;Entry Short:varx:= Close;y:=0;count:=0;i:=0;end_vary:=iff(x = O, O, iff(x = H, H, iff(x = L, L, iff(x = C, L, iff(x = V, V, 0)))));if HISTORYSIZE > 14 then beginfor i := 0 to 9 dobegin if y\i\ > y\4 +i\ then count := count + 1;end;return count = 9 and y\9\ < y\13\;end;return false;TD SEQUENTIAL strategy:Entry Long:varx:= Close;y:=0;count:=0;i:=0;end_vary:=iff(x = O, O, iff(x = H, H, iff(x = L, L, iff(x = C, L, iff(x = V, V, 0)))));if HISTORYSIZE > 14 then beginfor i := 0 to 9 dobegin if y\i\ < y\4 +i\ then count := count + 1;end;return count = 9 and y\9\ > y\13\;end;return false;Entry Short:varx:= Close;y:=0;count:=0;i:=0;end_vary:=iff(x = O, O, iff(x = H, H, iff(x = L, L, iff(x = C, L, iff(x = V, V, 0)))));if HISTORYSIZE > 14 then beginfor i := 0 to 9 dobegin if y\i\ > y\4 +i\ then count := count + 1;end;return count = 9 and y\9\ < y\13\;end;return false;
—Yana Timofeeva, Alyuda Research
510 931-7808, sales@tradecision.com
www.tradecision.com
BACK TO LIST
NINJATRADER: INTRADAY APPLICATION OF TD SEQUENTIAL AND ERMANOMETRY
The Ermanometry indicator and TD Sequential strategy, as presented by Andrew Coles in his article in this issue, “TD Sequential And Ermanometry For Intraday Traders,” have now been implemented in NinjaTrader as an automated strategy and indicator available for download at www.ninjatrader.com/SC/September2011SC.zip.
Once it has been downloaded, select the menu File → Utilities → Import NinjaScript from within the NinjaTrader Control Center window and select the downloaded file. This file is for NinjaTrader version 7 or greater.
You can review the strategy source code by selecting the menu Tools → Edit NinjaScript → Strategy from within the NinjaTrader Control Center window and selecting “TdSequential.”
You can review the indicator source code by selecting the menu Tools → Edit NinjaScript → Indicator from within the NinjaTrader Control Center window and selecting “Ermanometry.”
NinjaScript uses compiled Dlls that run native, not interpreted, which provides you with the highest performance possible.
A sample chart implementing the strategy is shown in Figure 8.
Figure 8: NINJATRADER, Ermanometry indicator. This screenshot shows the Ermanometry indicator applied to a five-minute chart of the emini S&P (ES 09-11).
—Raymond Deux & Ryan Millard
NinjaTrader, LLC
www.ninjatrader.com
BACK TO LIST
UPDATA: INTRADAY APPLICATION OF TD SEQUENTIAL AND ERMANOMETRY
This tip is based on “TD Sequential And Ermanometry For Intraday Traders” by Andrew Coles in this issue. In the article, Coles describes uses of Tom DeMark’s TD Sequential and William Erman’s study of growth patterns (Ermanometry) in timing long and short entries for intraday strategies.
The Updata code for both indicators has now been added to the Updata Library and may be downloaded by clicking the Custom menu and then either “Indicator” or “System Library.” Those who cannot access the library due to a firewall may paste the code below into the Updata custom editor and save it.
A sample chart is shown in Figure 9.
FIGURE 9: UPDATA, TD SEQUENTIAL. This chart shows the TD Sequential applied to spot rate GBP/USD, with notable reversals successfully picked out.
PARAMETER "O[1],H[2],L[3],C[4],V[5]" #OHLC=4DISPLAYSTYLE LINEPLOTSTYLE LINE RGB(0,0,255)INDICATORTYPE CHART SUPERIMPOSELEFT@LongCount=0@SellCount=0 #BuySetUp=0#SellSetUp=0 @Price=0 FOR #CURDATE=9 TO #LASTDATE If #OHLC=1 @Price=OPEN ElseIf #OHLC=2 @Price=HIGH ElseIf #OHLC=3 @Price=LOW ElseIf #OHLC=4 @Price=CLOSE ElseIf #OHLC=5 @Price=VOL EndIf 'Buy Setup Initial If @Price<Hist(@Price,4) @LongCount=@LongCount+1 Else @LongCount=0 EndIf 'Sell Setup Initial If @Price>Hist(@Price,4) @SellCount=@SellCount+1 Else @SellCount=0 EndIf 'Buy Confirmation If Hist(@LongCount,1)>=9 AND @Price>Hist(@Price,4) #BuySetUp=1 Else #BuySetUp=0 EndIf 'Sell Confirmation If Hist(@SellCount,1)>=9 AND @Price<Hist(@Price,4) #SellSetUp=1 Else #SellSetUp=0 EndIf @Plot=#BuySetUp+#SellSetUp NEXT
—Updata support team
support@updata.co.uk
www.updata.co.uk
BACK TO LIST
TRADESIGNAL: TD COUNTDOWN AND ERMANOMETRY
The TD Countdown and Ermanometry indicators can easily be used with our online charting tool at www.tradesignalonline.com. At our website, check the Infopedia section for our Lexicon. There, you will see the indicator and functions, which you can make available for your personal account. Simply click on it and select “Open script.” The indicator and functions will immediately be available for you to apply to any chart you wish.
The source code is also shown below, or can be downloaded here:
****** Source Code for the Ermanometry Indicator*******Meta: Weblink("http://www.tradesignalonline.com/lexicon/view.aspx?id=17169"), Synopsis("Based on the article 'TD Sequential And Ermanometry For Intraday Traders' by Andrew Coles from the 09/2011 issue of Stocks and Commodities."), ShortCode("ERM"); Inputs: Start_Cond( Bars_Back, Date_Time ), Bars( 500 ), Start_Date( "02.01.2011" ), Start_Time( 1000 ), EF( 100, 1 , 900 ), DE( 50, 1, 900 ); Vars: startCond, ratio, inverseratio, x, ab, cd, gh, fg, ij, hi, fh, bc; If Start_Cond = 0 Then startCond = CurrentBar = LastBar - BarsElse startCond = Date = ResolveDate( Start_Date ) And Time = Start_Time ; If startCond Then DrawSymbol( Close, "Start", SymbolVerticalLine, 1, Black, Black ); ratio = EF/DE;Inverseratio = 1/(EF/DE);x = BarsSince( startCond ); CD = DE * Inverseratio;BC = CD * Inverseratio;AB = BC * Inverseratio;FG = EF * Ratio;GH = FG * Ratio;HI = GH * Ratio;IJ = HI * Ratio; FH = Sqrt(Power(FG,2)+Power(GH,2)); If ( x=Int(FH+FG+GH) Or x=Int(FH) Or x=Int(GH) Or x=Int(HI) or x=Int(IJ) Or x=Int(DE+EF+CD) Or x=Int(GH+HI+IJ) or x=Int(CD+DE+EF+FG+GH+HI) or x=Int(EF+FG+GH) Or x=Int(CD+DE+EF+FG+GH) Or x=Int(CD+DE+EF+FG+GH+HI) Or x=Int(GH+IJ+CD+AB+EF )Or x=Int(FH+FG+GH) Or x=Int(AB+BC+CD+DE) Or x=Int(AB+BC+CD+DE+GH) Or x=Int(FG+GH) Or x=Int(GH+HI) or x=Int(FG+BC+CD) Or x=Int(FG+BC+CD+DE) or x=Int(CD+BC) Or x=Int(DE+BC) or x=Int(Sqrt(Power(CD,2)+Power(DE,2))+CD+DE) Or x=Int(Sqrt(Power(EF,2)+Power(FG,2))+EF+FG) ) Then DrawSymbol( Close, "Spiral", SymbolVerticalLine, 1, Black, Black ); // *** Copyright tradesignal GmbH ***// *** www.tradesignal.com *** ****** Source Code for the Count Down Indicator*******Meta: Weblink("http://www.tradesignalonline.com/lexicon/view.aspx?id=17169"), Synopsis("Based on the article 'TD Sequential And Ermanometry For Intraday Traders' by Andrew Coles from the 09/2011 issue of Stocks and Commodities."), ShortCode("CD"), Subchart( False ); Inputs: Price( Close ); Vars: bullSetup, bearSetup, bullCount, bearCount, initBuy, initSell, bearishFlip, bullishFlip; If CurrentBar = 1 Then Begin bullCOunt = 0; bearCount = 0; End; bearishFlip = Close[1] > Close[5] And Close < Close[4];bullishFlip = Close[1] < Close[5] And Close > Close[4]; If Price < Price[4] Then Begin If ( bullCount = 0 And bearishFlip ) Or bullCount > 0 Then bullCount = bullCount + 1; EndElse bullCount = 0; If bullCount = 9 Then Begin DrawSymbol( Close, "Buy Setup", SymbolVerticalLine, 1, DarkGreen, DarkGreen ); bullCount = 0; End; If Price > Price[4] Then Begin If ( bearCount = 0 And bullishFlip ) Or bearCount > 0 Then bearCount = bearCount + 1; EndElse bearCount = 0; If bearCount = 9 Then Begin DrawSymbol( Close, "Sell Setup", SymbolVerticalLine, 1, Red, Red ); bearCount = 0; End; // *** Copyright tradesignal GmbH ***// *** www.tradesignal.com *** ****** Source Code for the BullishFlip function*******Inputs: paint( TrueFalseSimple ); Vars: bullishPattern; bullishPattern = Close[1] < Close[5] And Close > Close[4]; If bullishPattern And paint Then DrawRectangle( Date[5], Time[5], Highest( High, 5 ), Date, Time, Lowest( Low, 5 ), Red, Transparent, ToolBorder + ToolEngulfing ); BullishFlip = bullishPattern; // *** Copyright tradesignal GmbH ***// *** www.tradesignal.com *** ****** Source Code for the BearishFlip function*******Inputs: paint( TrueFalseSimple ); Vars: bearishPattern; bearishPattern = Close[1] > Close[5] And Close < Close[4]; If bearishPattern And paint Then DrawRectangle( Date[5], Time[5], Highest( High, 5 ), Date, Time, Lowest( Low, 5 ), DarkGreen, Transparent, ToolBorder + ToolEngulfing ); BearishFlip = bearishPattern; // *** Copyright tradesignal GmbH ***// *** www.tradesignal.com ***
FIGURE 10: TRADESIGNAL, COUNTDOWN INDICATOR. This sample Tradesignal Online chart shows the countdown indicator on a daily chart of the German bund future.
—Henning Blumenthal
Tradesignal GmbH
support@tradesignalonline.com
www.TradesignalOnline.com, www.Tradesignal.com
BACK TO LIST
CHARTSY: TD SEQUENTIAL, ERMANOMETRY, LUCAS SERIES, FIBONACCI SERIES
For Windows + Mac + Linux
This Traders’ Tip is based on Andrew Coles’ articles in the August 2011 issue (“About Fibonacci And Lucas: Automated Techniques For Intraday Traders”) and this issue (“TD Sequential And Ermanometry For Intraday Traders”).
The Lucas series overlay and Fibonacci series overlay described in Coles’ August 2011 article and the TD Sequential Setup overlay and Ermanometry overlay described in Coles’ article in this issue are all available as overlay plugins in Chartsy. To install the overlays, go to the Tools → Plugins → Available plugins menu, check the desired indicator, and click Install.
You can find the Java source code for the overlays at the Chartsy website. Sample charts, and the corresponding Chartsy property panels are shown in Figures 11–14.
To download Chartsy, discuss these tools, and help us develop other tools, please visit our forum at www.chartsy.org.

FIGURE 11: CHARTSY, TD SEQUENTIAL chart overlay
FIGURE 12: CHARTSY, ERMANOMETRY chart overlay
FIGURE 13: CHARTSY, FIBONACCI SERIES chart overlay
FIGURE 14: CHARTSY, LUCAS SERIES chart overlay
—Larry Swing
(281) 968-2718, FVD@mrswing.com
Yahoo & Skype ID: larry_swing
www.mrswing.com
BACK TO LIST
TRADE NAVIGATOR: INTRADAY APPLICATION OF TD SEQUENTIAL AND ERMANOMETRY
You can recreate the indicators discussed in “TD Sequential And Ermanometry For Intraday Traders” by Andrew Coles in this issue using Trade Navigator. (See Figure 15 for an example of setting up a function by inputting the formula.)
Here is how to create the custom indicators and add them to any chart in Trade Navigator. We will then show how to use the custom indicators to create a template that can be easily applied to any chart.
Figure 15: TRADE NAVIGATOR, ACTD Buy Setup. Here is how to set up a function in Trade Navigator.
The TradeSense code to recreate the TD Sequential And Ermanometry indicators is as follows:
First, open the Trader’s Toolbox, click on the Functions tab, and click the New button.
ACTD BuySetup
Type in the following code:
&y := IFF (x = 1 , Open , IFF (x = 2 , High , IFF (x = 3 , Low , IFF (x = 4 , Close , IFF (x = 5 , Volume , 0))))) Consecutive (&y < (&y).4) = 9 And (&y).9 > (&y).13
Click the Verify button. When you verify or save the function, you will get an Add Inputs message. Click the Add button and set the Input values:
x = 4
Click on the Save button, type a name for your new function and click OK.
ACTD SellSetup
Type in the following code:
&y := IFF (x = 1 , Open , IFF (x = 2 , High , IFF (x = 3 , Low , IFF (x = 4 , Close , IFF (x = 5 , Volume , 0))))) Consecutive (&y > (&y).4) = 9 And (&y).9 < (&y).13
Click the Verify button. When you verify or save the function, you will get an Add Inputs message. Click the Add button and set the Input values:
x = 4
Click on the Save button, type a name for your new function and click OK.
ACTD Seq S
Type in the following code:
IFF (ACTD BuySetup (4) Or ACTD SellSetup (4) , 1 , 0)
Click on the Save button, type a name for your new function and click OK.
Ermanometry
Type in the following code:
&start := YearMonthDay = startdate &EF := wavelength1 &DE := wavelength2 &ratio := &EF / &DE &inverse := 1 / &ratio &x := Bars Since (&start , 1 , 0) &CD := &DE * &inverse &BC := &CD * &inverse &AB := &BC * &inverse &FG := &EF * &ratio &GH := &FG * &ratio &HI := &GH * &ratio &IJ := &HI * &ratio &FH := SqrRoot (Power (&FG , 2) + Power (&GH , 2)) IFF (&x = Integer Part (&FH + &FG + &GH) , 1 , IFF (&x = Integer Part (&AB + &BC + &CD + &DE) , 1 , IFF (&x = Integer Part (&AB + &BC + &CD + &DE + &GH) , 1 , IFF (&x = Integer Part (&FG + &GH) , 1 , IFF (&x = Integer Part (&GH + &HI) , 1 , IFF (&x = Integer Part (&FG + &BC + &CD) , 1 , IFF (&x = Integer Part (&FG + &BC + &CD + &DE) , 1 , IFF (&x = Integer Part (&CD + &BC) , 1 , IFF (&x = Integer Part (&DE + &BC) , 1 , IFF (&x = Integer Part (SqrRoot (Power (&CD , 2) + Power (&DE , 2)) + &CD + &DE) , 1 , IFF (&x = Integer Part (SqrRoot (Power (&EF , 2) + Power (&FG , 2)) + &EF + &FG) , 1 , IFF (&x = Integer Part (&FH) , 1 , IFF (&x = Integer Part (&GH) , 1 , IFF (&x = Integer Part (&HI) , 1 , IFF (&x = Integer Part (&IJ) , 1 , IFF (&x = Integer Part (&DE + &EF + &CD) , 1 , IFF (&x = Integer Part (&GH + &HI + &IJ) , 1 , IFF (&x = Integer Part (&CD + &DE + &EF + &FG + &GH + &HI) , 1 , IFF (&x = Integer Part (&EF + &FG + &GH) , 1 , IFF (&x = Integer Part (&CD + &DE + &EF + &FG + &GH) , 1 , IFF (&x = Integer Part (&CD + &DE + &EF + &FG + &GH + &HI) , 1 , IFF (&x = Integer Part (&GH + &IJ + &CD + &AB + &EF) , 1 , 0))))))))))))))))))))))
Click the Verify button. When you verify or save the function, you will get an Add Inputs message. Click the Add button and set the Input values:
wavelength1 = 50wavelength2 = 25startdate = 20090526
Click on the Save button, type a name for your new function and click OK.
Creating the chart template
On a daily chart, go to the “Add to chart” window by clicking on the chart and typing “A” on the keyboard.
Click on the Indicators tab, find the ACTD Seq S indicator in the list and either doubleclick on it or highlight the name and click the Add button.
Repeat these steps to add the Ermanometry indicator.
On the chart, click on the Ermanometry label and drag it into the price pane. Click and drag the ACTD Seq S label into the price pane.
Click on the chart and type the letter “E” to bring up the Chart Settings window. Change the indicator colors and or settings to how you want them displayed.
When you have them the way you want to see them, click OK.
Click on the Templates button on the toolbar at the top. Select <Manage chart templates>. Click the New button, type a name for the template and click OK.
You now have a template that you can apply to any chart by going to the Templates button in the toolbar and selecting the template from the list.
Genesis Financial Technologies has also provided a library named “TD Sequential And Ermanometry” that includes a template named “S&C Sept 2011 Andrew Coles” with the custom indicators discussed in Coles’ article. You can download a special file named “SC201109,” downloadable through Trade Navigator, to get this library.
—Michael Herman
Genesis Financial Technologies
www.TradeNavigator.com
BACK TO LIST
VT TRADER: TD SEQUENTIAL SETUP AND ERMANOMETRY INDICATORS
Our Traders’ Tip this month is based on “TD Sequential And Ermanometry For Intraday Traders” by Andrew Coles in this issue. In this second part of the series, Cole discusses Thomas DeMark’s TD Sequential Setup technique (the momentum component of the TD Sequential method used to define price ranges) as well as William Erman’s Ermanometry. Coles describes how these market timing techniques can be mechanized for intraday traders.
We’ll be offering the TD Sequential Setup and Ermanometry indicators for download in our VT client forums at http://forum.vtsystems.com, along with hundreds of other precoded and free indicators and trading systems.
The VT Trader instructions for setting up these indicators are shown below.
TD Sequential Setup
- VT Trader’s Ribbon→Technical Analysis menu→Indicators group→Indicators Builder→[New] button
- In the General tab, type the following text into each corresponding text box:
Name: TASC - 09/2011 - TD Sequential SetupFunction Name Alias: tasc_tdsequentialsetupLabel Mask: TASC - 09/2011 - TD Sequential Setup (%price%)Placement: New FrameData Inspection Alias: TD Sequential Setup
- In the Input Variable(s) tab, create the following variables:
[New] button...Name: priceDisplay Name: PriceType: priceDefault: close
- In the Output Variable(s) tab, create the following variables:
[New] button...Var Name: BuySetup Name: (Buy Setup)Line Color: blueLine Width: slightly thickerLine Type: histogram[New] button...Var Name: SellSetup Name: (Sell Setup)Line Color: redLine Width: slightly thickerLine Type: histogram
- In the Horizontal Line tab, create the following horizontal lines:
[New] button...Value: 0Line Color: blackLine Width: thinLine Type: dashed
- In the Formula tab, copy and paste the following formula:
{Provided By: Capital Market Services, LLC & Visual Trading Systems, LLC}{Copyright: 2011}{Description: TASC, September 2011 - "TD Sequential and Ermanometry for Intraday Traders" by Andrew Coles, PhD}{File: tasc_tdsequentialsetup.vtscr - Version 1.0}BuySetup:= Sum(price<Ref(price,-4),9)=9 AND Ref(price,-9)>Ref(price,-13);SellSetup:= Sum(price>Ref(price,-4),9)=9 AND Ref(price,-9)<Ref(price,-13);
- Click the “Save” icon in the toolbar to finish building the TD Sequential Setup indicator.
To attach the indicator to a chart click the right mouse button within the chart window and then select “Add Indicator” → “TASC - 09/2011 - TD Sequential Setup” from the indicator list.
Ermanometry
- VT Trader’s Ribbon→Technical Analysis menu→Indicators group→Indicators Builder→[New] button
- In the General tab, type the following text into each corresponding text box:
Name: TASC - 09/2011 - ErmanometryFunction Name Alias: tasc_ermanometryLabel Mask: TASC - 09/2011 - Ermanometry(Start M/D/Y H:M: %sm%/%sd%/%sy% %sh%:%se%)Data Inspection Alias: Ermanometry
- In the Input Variable(s) tab, create the following variables:
[New] button...Name: smDisplay Name: Starting MonthType: integer (with bounds)Default: 1Min Bounds: 1Max Bounds: 12[New] button...Name: sdDisplay Name: Starting Day of MonthType: integer (with bounds)Default: 1Min Bounds: 1Max Bounds: 31[New] button...Name: syDisplay Name: Starting YearType: integer (with bounds)Default: 2011Min Bounds: 1980Max Bounds: 2100[New] button...Name: shDisplay Name: HourType: integer (with bounds)Default: 0Min Bounds: 0Max Bounds: 23[New] button...Name: seDisplay Name: MinuteType: integer (with bounds)Default: 0Min Bounds: 0Max Bounds: 59[New] button...Name: EFDisplay Name: Seed Segment EF (first wave)Type: integer (with bounds)Default: 10Min Bounds: 1Max Bounds: 9999[New] button...Name: DEDisplay Name: Seed Segment DE (2nd wave)Type: integer (with bounds)Default: 10Min Bounds: 1Max Bounds: 9999[New] button...Name: ermanDisplay Name: Show Erman Series?Type: enumerationDefault: Yes (* To set up list: click [..] button -> click [New] Button -> type "No" -> click [New] button -> type "Yes" -> click [OK] button)[New] button...Name: colesDisplay Name: Show Coles Series?Type: enumerationDefault: Yes (* To set up list: click [..] button -> click [New] Button -> type "No" -> click [New] button -> type "Yes" -> click [OK] button)
- In the Output Variable(s) tab, create the following variables:
[New] button...Var Name: ErmanSeries Name: (Erman Series)Line Color: light greenLine Width: slightly thickerLine Type: histogram[New] button...Var Name: ColesSeries Name: (Coles Series)Line Color: light blueLine Width: slightly thickerLine Type: histogram
- In the Horizontal Line tab, create the following horizontal lines:
[New] button...Value: 0Line Color: blackLine Width: thinLine Type: dashed
- In the Formula tab, copy and paste the following formula:
{Provided By: Capital Market Services, LLC & Visual Trading Systems, LLC}{Copyright: 2011}{Description: TASC, September 2011 - "TD Sequential and Ermanometry for Intraday Traders" by Andrew Coles, PhD}{File: tasc_ermanometry.vtscr - Version 1.0}start:= sd=DayOfMonth() AND sm=Month() AND sy=Year() AND sh=Hour() AND se=Minute();Ratio:= EF/DE;Inverseratio:= 1/(EF/DE);x:= BarsSince(start);CD:= DE*Inverseratio;BC:= CD*Inverseratio;AB:= BC*Inverseratio;FG:= EF*Ratio;GH:= FG*Ratio;HI:= GH*Ratio;IJ:= HI*Ratio;FH:= Sqrt(Power(FG,2)+Power(GH,2));ErmanSeries:= erman=1 AND ( x=Int(FH) OR x=Int(GH) OR x=Int(HI) OR x=Int(IJ) OR x=Int(DE+EF+CD) OR x=Int(GH+HI+IJ) OR x=Int(CD+DE+EF+FG+GH+HI) OR x=Int(EF+FG+GH) OR x=Int(CD+DE+EF+FG+GH) OR x=Int(CD+DE+EF+FG+GH+HI) OR x=Int(GH+IJ+CD+AB+EF) );ColesSeries:= coles=1 AND ( x=Int(FH+FG+GH) OR x=Int(AB+BC+CD+DE) OR x=Int(AB+BC+CD+DE+GH) OR x=Int(FG+GH) OR x=Int(GH+HI) OR x=Int(FG+BC+CD) OR x=Int(FG+BC+CD+DE) OR x=Int(CD+BC) OR x=Int(DE+BC) OR x=Int(Sqrt(Power(CD,2)+Power(DE,2))+CD+DE) OR x=Int(Sqrt(Power(EF,2)+Power(FG,2))+EF+FG) );
- Click the “Save” icon in the toolbar to finish building the Ermanometry indicator.
To attach the indicator to a chart, click the right mouse button within the chart window and then select “Add Indicator” → “TASC - 09/2011 - Ermanometry” from the indicator list.
Sample charts of the TD Sequential Setup and Ermanometry indicator are shown in Figures 16 and 17.
FIGURE 16: VT TRADER, TD Sequential. Here is the TD Sequential setup indicator attached to a EUR/USD one-hour candle chart.
FIGURE 17: VT TRADER, Ermanometry. Here is the Ermanometry indicator attached to a EUR/USD one-hour candle chart.
To learn more about VT Trader, visit www.vtsystems.com.
Risk disclaimer: Forex trading involves a substantial risk of loss and may not be suitable for all investors.
—Chris Skidmore
Visual Trading Systems, LLC
212 871-1747, info@vtsystems.com
www.vtsystems.com
BACK TO LIST
MICROSOFT EXCEL: INTRADAY APPLICATION OF TD SEQUENTIAL AND ERMANOMETRY
This month, author Andrew Coles continues his exploration of time series-based market studies with Ermanometry-based intervals and TD Sequential Setups in an article titled “TD Sequential And Ermanometry For Intraday Traders” in this issue.
In this Excel example, I have once again used data for Tlt as I did for the August 2011 Traders’ Tip so we can compare the results. This example is coded to use the closing price, but provisions have been made to allow you to base the calculations on open, high, low, or close, similar to the MetaStock code given in Coles’ article.
In Excel terms, the only real difference between intraday, daily, weekly, or longer time frames is how one goes about specifying the bars that define segments DE and EF for the Erman study. The TD Sequential Setups do not require a start date.
In Figure 18, the Erman left, middle, and right plots mark the ends of the ratio defining segments DE and EF chosen for this example. The spreadsheet is coded to start the Ermanometry counts and plots at the Erman right bar.
Figure 18: EXCEL, TD Sequential and Ermanometry. The Erman left, middle, and right plots mark the ends of the ratio defining segments DE and EF chosen for this example. The spreadsheet is coded to start the Ermanometry counts and plots at the Erman right bar.
If you have access to historical intraday data, the notes tab outlines the simple cell format changes you would need to make to use this workbook with intraday data.
This workbook incorporates the chart data windowing ability I introduced in previous Excel Traders’ Tips. To take advantage of this feature you will need to enable Vba macro content when prompted.
Even if you choose not to enable Vba macro content, you may view the macros after you open the spreadsheet by using Alt-F11 to open the Vba integrated development environment.
Here is the link to download the “TDSequentialAndErmanometry.xls” spreadsheet file.
—Ron McAllister
EXCEL and VBA Programmer
rpmac_xltt@sprynet.com
BACK TO LIST
METASTOCK: TD SEQUENTIAL AND ERMANOMETRY FOR INTRADAY TRADERS — COLES ARTICLE CODE
A TD Sequential buy Setup adheres to the following two conditions:
- A bearish price flip whereby price must close higher than the close four bars earlier, followed by a close less than the close four bars earlier
- Nine consecutive closes, each one less than the corresponding close four bars earlier (where the bar on which the bearish price flip occurs qualifies as bar of the buy Setup).
For a sell Setup, these conditions are reversed. These two conditions can be programmed into MetaStock and the result is a mechanized version of the Setup component of the TD Sequential.
Metastock code for intraday application of the TD Setup
x:=Input("Price Field, 1=O,2=H,3=L,4=C,5=V",1,5,4);y:=If(x=1,O,If(x=2,H,If(x=3,L,If(x=4,L,If(x=5,V,0)))));{BuySetup} Sum(y<Ref(y,-4),9)=9 AND {initialization} Ref(y,-9)>Ref(y,-13);{SellSetup} Sum(y>Ref(y,-4),9)=9 AND {initialization} Ref(y,-9)<Ref(y,-13);
Metastock code for intraday application of Ermanometry
sm:=Input("starting month",1,12,1);sd:=Input("starting day of month",1,31,1);sh:=Input("hour", 1,24,1);se:=Input("minute",0,60,0);start:= sd=DayOfMonth() AND sm=Month() AND 2010 AND sh=Hour() AND se=Minute();EF:=Input("seed segment EF (first wave)",1,900,10) {first leg or movement};DE:=Input("seed segment DE (second wave)",1,900,10) {second leg or movement};Ratio:=EF/DE;Inverseratio:= 1/(EF/DE);x:=BarsSince(start); CD:=DE*Inverseratio;BC:=CD*Inverseratio;AB:=BC*Inverseratio;FG:= EF*Ratio;GH:=FG*Ratio;HI:=GH*Ratio;IJ:=HI*Ratio;FH:= Sqrt(Power(FG,2)+Power(GH,2));{start of calculations}If(x=Int(FH),1,0); {Erman}If(x=Int(GH),1,0); {Erman}If(x=Int(HI),1,0); {Erman}If(x=Int(IJ),1,0); {Erman}If(x=Int(DE+EF+CD),1,0); {Erman}If(x=Int(GH+HI+IJ),1,0); {Erman}If(x=Int(CD+DE+EF+FG+GH+HI),1,0); {Erman}If(x=Int(EF+FG+GH),1,0); {Erman}If(x=Int(CD+DE+EF+FG+GH),1,0); {Erman}If(x=Int(CD+DE+EF+FG+GH+HI),1,0); {Erman}If(x=Int(GH+IJ+CD+AB+EF),1,0); {Erman}FH:= Sqrt(Power(FG,2)+Power(GH,2));If(x=Int(FH+FG+GH),1,0); {Coles}If(x=Int(AB+BC+CD+DE),1,0); {Coles}If(x=Int(AB+BC+CD+DE+GH),1,0); {Coles}If(x=Int(FG+GH),1,0); {Coles}If(x=Int(GH+HI),1,0); {Coles}If(x=Int(FG+BC+CD),1,0); {Coles}If(x=Int(FG+BC+CD+DE),1,0); {Coles}If(x=Int(CD+BC),1,0); {Coles}If(x=Int(DE+BC),1,0); {Coles}If(x=Int(Sqrt(Power(CD,2)+Power(DE,2))+CD+DE),1,0); {Coles}If(x=Int(Sqrt(Power(EF,2)+Power(FG,2))+EF+FG),1,0); {Coles}
—Andrew Coles
www.midasmarketanalysis.com
BACK TO LIST
BLOOMBERG: INTRADAY APPLICATION OF TD SEQUENTIAL AND ERMANOMETRY
In his article in this issue, “TD Sequential And Ermanometry For Intraday Traders,” author Andrew Coles demonstrates additional techniques following his article last month, this time focused on intraday trading using sequences of spikes on the chart to represent the development of a linear rectangular spiral, as well as the TD Sequential developed by Tom DeMark.
The TD Sequential indicator is available as part of the DeMark suite of indicators offered as a third-party subscription service accessible through DEMA<GO>.
The spikes on the 60-minute Citigroup chart shown in Figure 19 formed by the Ermanometry study, as described in Coles’s article, are based on the two significant moves in the beginning of June 2010. The downward slope consists of 90 bars, and the move back up has a count of 40 bars. Using these inputs, the spikes are created and, as is shown, line up with a number of meaningful times in the market. The first three green circles all line up with points where the market was not following the overall uptrend that ran from mid-June until reversing in early/mid July. The furthest spike on the chart lines up (within three bars, as mentioned in Coles’s article) with what appears to be the end of the downmove.
FIGURE 19: BLOOMBERG, TD SEQENTIAL AND ERMANOMETRY. This 30-minute chart of Citigroup shows a down move from June 1 through June 8, 2011, consisting of 90 bars. The move up from the low on June 8 hit a swing high on June 13 with a count of 40 bars. Using these numbers with Ermanometry, as described in this month’s article by Andrew Coles, produces spikes on the chart often corresponding with prominent points of trend pausing and reversal.
As with the Fibonacci and Lucas sequences discussed in last month’s Bloomberg Traders’ Tip, this indicator was written to paint the bar that is clicked on as the beginning point for the count. Using the CS.NET framework within the STDY<GO> function on the Bloomberg Terminal, C# or Visual Basic code can be written to display the spikes resulting from Ermanometry sequences, as described in Coles’s article in this issue.
The C# code for this indicator is shown below. All Bloomberg code contributions to Traders’ Tips can also be found in the sample files provided with regular SDK updates, and the studies will be included in the Bloomberg global study list.
using System;using System.Collections.Generic;using System.Text;using System.Drawing;using Bloomberg.Study.API;using Bloomberg.Study.CoreAPI;using Bloomberg.Study.Util;using Bloomberg.Study.TA;using Bloomberg.Math;namespace Ermanometry{ public partial class Ermanometry { // DateTime to hold the starting point for the sequence DateTime startPoint; public StudyIntegerProperty DE = new StudyIntegerProperty(10, 40, 900); public StudyIntegerProperty EF = new StudyIntegerProperty(10, 48, 900); private void Initialize() { // Create Lines to Output at Ermonetric Counts Output.Add("Ermanometry", new TimeSeries()); StudyLine ErmanometryLine = new StudyLine("Ermanometry", Color.Red); ErmanometryLine.Style = LineStyle.Solid; ErmanometryLine.Width = 1; ParentPanel.Visuals.Add("ErmanometricCount", ErmanometryLine); // Create Paint Bar to mark start point of Ermonetric Count Output.Add("PaintBar", new TimeSeries()); StudySignal paintBar = new StudySignal("PaintBar"); paintBar.Marker = new PaintBar(Color.Cyan); ParentPanel.Visuals.Add("PaintBar", paintBar); // Register callback function for handling chart click to set a new start point Notifications.Add("Ermanometry Start", new StudyIndexNotification(ermStartCallback)); } public override void Calculate() { // Find the min and max value of the chart data for plotting the needle projections double minValue = Input.Low.Minimum; double maxValue = Input.High.Maximum; int count = Input.Close.Count; TimeSeries paintBarData = new TimeSeries(count); TimeSeries ermanometricData = new TimeSeries(count, minValue); // This section will tie the color of the Paint Bar (clicked bar) to the color of the // Ermanometry Lines StudyLine line = ParentPanel.Visuals["ErmanometricCount"] as StudyLine; StudySignal signal = ParentPanel.Visuals["PaintBar"] as StudySignal; PaintBar paintBar = signal.Marker as PaintBar; paintBar.Color = line.Color; line.ShowValues(false); // This stops the needle projections from showing a value in the // chart legend // Intialize the start point to the beginning of the chart if (startPoint == null) { startPoint = Input.DateTimes[0]; } // Find the starting point of the sequence based on the selected DateTime int startIndex = 0; while (startIndex < Input.Close.Count && Input.DateTimes[startIndex] < startPoint) { startIndex++; } // Mark the starting point with a paintBar paintBarData[startIndex] = 1; double Ratio = (double)EF.Value / (double)DE.Value; double Inverseratio = 1 / Ratio; int CD = (int)Math.Round(DE.Value * Inverseratio); int BC = (int)Math.Round(CD * Inverseratio); int AB = (int)Math.Round(BC * Inverseratio); int FG = (int)Math.Round(EF.Value * Ratio); int GH = (int)Math.Round(FG * Ratio); int HI = (int)Math.Round(GH * Ratio); int IJ = (int)Math.Round(HI * Ratio); double FH = Math.Sqrt(Math.Pow(FG, 2) + Math.Pow(GH, 2)); for (int ii = 0; ii < count; ii++) { double x = ii - startIndex; if (x == (int)FH) ermanometricData[ii] = maxValue; //Erman if (x == (int)GH) ermanometricData[ii] = maxValue; //Erman if (x == (int)HI) ermanometricData[ii] = maxValue; //Erman if (x == (int)IJ) ermanometricData[ii] = maxValue; //Erman if (x == (int)DE.Value + EF.Value + CD) ermanometricData[ii] = maxValue; //Erman if (x == (int)GH + HI + IJ) ermanometricData[ii] = maxValue; //Erman if (x == (int)CD + DE.Value + EF.Value + FG + GH + HI) ermanometricData[ii] = maxValue; //Erman if (x == (int)EF.Value + FG + GH) ermanometricData[ii] = maxValue; //Erman if (x == (int)CD + DE.Value + EF.Value + FG + GH) ermanometricData[ii] = maxValue; //Erman if (x == (int)CD + DE.Value + EF.Value + FG + GH + HI) ermanometricData[ii] = maxValue; //Erman if (x == (int)AB + BC + GH-1) ermanometricData[ii] = maxValue; //Erman if (x == (int)GH + IJ + CD + AB + EF.Value) ermanometricData[ii] = maxValue; //Erman FH = Math.Sqrt(Math.Pow(FG, 2) + Math.Pow(GH, 2)); if (x == (int)FH + FG + GH) ermanometricData[ii] = maxValue; //Coles if (x == (int)AB + BC + CD + DE.Value) ermanometricData[ii] = maxValue; //Coles if (x == (int)AB + BC + CD + DE.Value + GH) ermanometricData[ii] = maxValue; //Coles if (x == (int)FG + GH) ermanometricData[ii] = maxValue; //Coles if (x == (int)GH + HI) ermanometricData[ii] = maxValue; //Coles if (x == (int)FG + BC + CD) ermanometricData[ii] = maxValue; //Coles if (x == (int)FG + BC + CD + DE.Value) ermanometricData[ii] = maxValue; //Coles if (x == (int)CD + BC) ermanometricData[ii] = maxValue; //Coles if (x == (int)DE.Value + BC) ermanometricData[ii] = maxValue; //Coles if (x == (int)(Math.Sqrt(Math.Pow(CD, 2) + Math.Pow(DE.Value, 2)) + CD + DE.Value)) ermanometricData[ii] = maxValue; //Coles if (x == (int)(Math.Sqrt(Math.Pow(EF.Value, 2) + Math.Pow(FG, 2)) + EF.Value + FG)) ermanometricData[ii] = maxValue; //Coles } Output.Update("Ermanometry", ermanometricData); Output.Update("PaintBar", paintBarData); } // This is inserted to allow user to click on starting bar instead of manually inputting date and time public void ermStartCallback(int index) { // Reset the startPoint to the DateTime of the selected bar startPoint = Input.DateTimes[index]; // Force the study to recalculate based on the new start point Calculate(); } }}
—Bill Sindel
以上文援引自: http://tw.myblog.yahoo.com/jw!4_ltTWaFGRlZDPIlaXb6ln4-/article?mid=29608&prev=-1&next=29607