Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

TD REI for Amibroker (AFL)
kaiji
almost 15 years ago
Amibroker (AFL)

Rating:
5 / 5 (Votes 1)
Tags:

TD range expansion index (REI). Indicator was posted by another user. I have modified it to follow TD’s rules. See my comments in the code for further info..

By milostea – rcarjunk1206 [at] charter.ent

Screenshots

Indicator / Formula

Copy & Paste Friendly
_SECTION_BEGIN("TDREI-w-TDPOQ");
/* 
* TD's Range Expansion Index (TD REI)
* with Price Oscillator Qualifier (TD POQ)
*
* Notes: Code was modified to follow TD's rules.
* Improvements: plenty of bug fixes.
*
* Buy when the "varPrimaryBuySetupSignal" is 1
* Sell when the "varPrimarySellSetupSignal" is 1
*
*/

varPeriod = Param("Periods", 5, 1, 8, 1); //default is 5.
varSignal = Param("Signal", 40, 35, 45, 1);// default is 40.

varOversoldSignal = (0-1)*varSignal;
varOverboughtSignal = varSignal;
// End set variables

HighMom = H - Ref( H, -2 );
LowMom = L - Ref( L, -2 );

Cond1 = ( H >= Ref( L,-5) OR H >= Ref( L, -6 ) ) OR ( Ref( H, -2 ) >= Ref( C,-7 ) OR Ref( H, -2 ) >= Ref( C, -8 ) ); 
Cond2 = ( L <= Ref( H, -5 ) OR L <= Ref( H, -6) ) OR ( Ref( L, -2 ) <= Ref( C,-7 ) OR Ref( L, -2 ) <= Ref( C, -8 ) );

Cond = ( Cond1 AND Cond2 );

Num = IIf( Cond, HighMom + LowMom, 0 );
Den = abs( HighMom ) + abs( LowMom );

TDREI = 100 * Sum( Num, varPeriod )/Sum( Den, varPeriod ) ;

// Identify oversold conditions
nOversold = 0;
nOverbought = 0;
nOversold = Sum( TDREI <= varOversoldSignal, 6 ) == 6 OR
			Sum( TDREI <= varOversoldSignal, 5 ) == 5 OR
			Sum( TDREI <= varOversoldSignal, 4 ) == 4 OR
			Sum( TDREI <= varOversoldSignal, 3 ) == 3 OR
			Sum( TDREI <= varOversoldSignal, 2 ) == 2 OR
			TDREI <= varOversoldSignal
			;

// Identify overbought conditions
nOverbought = Sum( TDREI >= varOverBoughtSignal, 6) == 6 OR
				Sum( TDREI >= varOverBoughtSignal, 5) == 5 OR
				Sum( TDREI >= varOverBoughtSignal, 4) == 4 OR
				Sum( TDREI >= varOverBoughtSignal, 3) == 3 OR
				Sum( TDREI >= varOverBoughtSignal, 2) == 2 OR
				TDREI >= varOverBoughtSignal
				;

// Tom DeMark Price Oscillator Qualifier (TD POQ)
// Primary and Secondary Buy Setups apply to EOD of today
// Buy = H > (H,-1)

varPrimaryCheck = 0;
varPrimaryBuySetup = 0;
varSecondaryBuySetup = 0;
varPrimaryBuySetup = (
						Ref(C,-1) > Ref (C,-2) AND O <= Ref(H,-1)
						AND O<= Ref(H,-2) AND O<=Ref(H,-1)
						AND O<=L
						AND (H > Ref(H,-1) OR H > Ref(H,-2))
						);
varPrimarySellSetup = (
						Ref(C,-1) > Ref(C,-2)
						AND O >= Ref(L,-1)
						AND O >= Ref(L,-2)
						AND O >= H
						AND (L < Ref(L,-1) OR L < Ref(L,-2))
						);

varPrimaryBuySetupSignal = IIf(varPrimaryBuySetup AND Ref( nOversold,-1),1,0);
varPrimarySellSetupSignal = IIf(varPrimarySellSetup AND Ref(nOverbought,-1),1,0);

// Start: Plot all lines
Graph0=TDREI;
Graph0Style=styleThick;
Graph0Color=colorRed;
Graph1=varOverboughtSignal;
Graph1Style=styleLine;
Graph1Color=colorBlue;
Graph2=varOversoldSignal;
Graph2Style=styleLine;
Graph2Color=colorBlue;

IIf(varPrimaryBuySetupSignal>0,
	PlotShapes(shapeUpArrow*varPrimaryBuySetupSignal,colorGreen),0);
IIf(varPrimarySellSetupSignal>0,
	PlotShapes(shapeDownArrow*varPrimarySellSetupSignal,colorRed),0);

// End: plot all lines

Title =Name() + " -TDREI: " + "("+ WriteVal ( Graph0,format=1.2)+")";
_SECTION_END();

0 comments

Leave Comment

Please login here to leave a comment.

Back