sebastianK
Re: TradeStation
Dmi And
Moving Average
Quote:
Rombout Kerstens’ “Combining Dmi And Moving Average For A Eur/Usd Trading System,” describes a technique for long entry and exit that uses both J. Welles Wilder’s Dmi (directional movement indicator) and a moving average.
PHP Code:
Indicator: DMI_MA RS
inputs:
MALength( 30 ),
DMILength( 14 ) ;
variables:
vDMIMinus( 0 ),
vDMIPlus( 0 ),
MA( 0 ),
DMILong( false ),
DMIShort( false ),
MALong( false ),
MAShort( false ),
MADiffPct( 0 ),
DMIDiff( 0 ) ;
vDMIMinus = DMIMinus( DMILength ) ;
vDMIPlus = DMIPlus( DMILength ) ;
MA = Average( Close, MALength ) ;
if CurrentBar > 1 then
begin
if vDMIPlus crosses over vDMIMinus then
begin
DMILong = true ;
DMIShort = false ;
end
else if vDMIPlus crosses under vDMIMinus then
begin
DMILong = false ;
DMIShort = true ;
end ;
if Close crosses over MA then
begin
MALong = true ;
MAShort = false ;
end
else if close crosses under MA then
begin
MALong = false ;
MAShort = true ;
end ;
if MA <> 0 then
MADiffPct = ( Close - MA ) / MA ;
DMIDiff = vDMIPlus - vDMIMinus ;
Plot1( MADiffPct, “MADiff%” ) ;
Plot2( DMIDiff, “DMIDiff” ) ;
if MALong then
begin
SetPlotBGColor( 1, Green ) ;
SetPlotColor( 1, Black ) ;
end
else
begin
SetPlotBGColor( 1, Red ) ;
SetPlotColor( 1, White ) ;
end ;
if DMILong then
begin
SetPlotBGColor( 2, Green ) ;
SetPlotColor( 2, Black ) ;
end
else
begin
SetPlotBGColor( 2, Red ) ;
SetPlotColor( 2, White ) ;
end ;
if DMILong and MALong then
begin
Plot3( “LongSig”, “Signal” ) ;
SetPlotBGColor( 3, Green ) ;
SetPlotColor( 3, Black ) ;
end ;
if DMIShort and MAShort then
begin
Plot3( “ExitSig” , “Signal” ) ;
SetPlotBGColor( 3, Red ) ;
SetPlotColor( 3, White ) ;
end ;
end ;