# Comparative Quantiles Analysis



## mrWoodo (20 March 2007)

Came across this indicator. Quite neat - It's a bit of a slog reading through it all, but basically he's combining a Money Flow indicator and statistical ranking to determing potential trend changes.

Would be a handy indicator for swing trading - Have knocked it up in AmiBroker language, will upload the formula tonight if anyone wants it. No reason I guess why this approach couldn't be used with your indicator of choice.

I doubt I'm breaking any sort of copywright with this, but have looked through it and see that it's easily accessible in more than a few places on the web. Respect where it's due, Clive Corcoran is the author, and his book is here.


----------



## wayneL (20 March 2007)

mrWoodo said:
			
		

> Came across this indicator. Quite neat - It's a bit of a slog reading through it all, but basically he's combining a Money Flow indicator and statistical ranking to determing potential trend changes.
> 
> Would be a handy indicator for swing trading - Have knocked it up in AmiBroker language, will upload the formula tonight if anyone wants it. No reason I guess why this approach couldn't be used with your indicator of choice.
> 
> I doubt I'm breaking any sort of copywright with this, but have looked through it and see that it's easily accessible in more than a few places on the web. Respect where it's due, Clive Corcoran is the author, and his book is here.



Looks interesting MrWoodo. I'd certainly be interested in looking at it. (will read in more depth later)

Cheers


----------



## mrWoodo (20 March 2007)

Hi Wayne,

Hmmm  - mixed results - Either I've stuffed something in the formula (new at Amibroker) or I'm missing some of the subleties in the parameters...... It's a start I guess.

The buy signals in the attached screenshot seem ok but the sells aren't so good - Corcoran's example (in the first link I posted) looks a lot better so I'll keep at it.

Anyway, here's the code :

_SECTION_BEGIN("All");

f = (C > 0.5) AND ((V*C) > 400000); //optional filter

AccumWindow = Param("Accumulation Window (days)", 20, 1, 50); 
LowerBias = Param("Lower Bias", -0.5, -1, 0, 0.05); 
UpperBias = Param("Upper Bias", 0.5, 0, 1, 0.05); 
LowerQuantile = Param("Lower Quantile", 10, 0, 50); 
UpperQuantile = Param("Upper Quantile", 90, 50, 100); 
SellWindow= Param("Sell Window (days)", 10, 1, 50); 
BuyWindow= Param("Buy Window (days)", 10, 1, 50);

ClosingDifference = Close - Ref(Close, -1); 
ClosingPositionBias = ( ClosingDifference / ATR(1) ); 
SignValue = IIf ( ClosingPositionBias < LowerBias , -1, IIf ( ClosingPositionBias > UpperBias, 1, 0 ) );

TrueRangeAccumulator = IIf ( ATR(1) > Percentile ( ATR(1), AccumWindow, UpperQuantile ), Close * Volume * signValue * ATR(1), 0 ); 
AccumulatorLine = Sum(TrueRangeAccumulator , AccumWindow );

SellAccumulator = IIf ( Close > Percentile ( Close, AccumWindow, UpperQuantile ), Close * Volume * signValue * ATR(1), 0 ); 
SellLine = Sum(SellAccumulator , AccumWindow );
Sell = Cross ( 0, AccumulatorLine ) AND ( BarsSince ( SellLine <= 0 ) > SellWindow); //need to improve this
Sell = ExRemSpan(Sell, 8);

BuyAccumulator = IIf ( Close < Percentile ( Close, AccumWindow, LowerQuantile ), Close * Volume * signValue * ATR(1), 0 ); 
BuyLine = Sum(BuyAccumulator , AccumWindow );
Buy = Cross ( AccumulatorLine , 0 ) AND ( BarsSince ( Buyline > 0 ) > BuyWindow); //need to improve this
Buy = ExRemSpan(Buy, 8) AND f;
PositionSize = -100 / GetOption("MaxOpenPositions");
PositionScore = 100 - RSI(14);
Filter = Buy;
AddColumn( Volume, "Volume");

arrows = ParamToggle("Plot Trade Arrows", "HIDE|SHOW", 1);
if (arrows)
{
	PlotShapes( Buy*shapeSmallUpTriangle+ Sell*shapeSmallDownTriangle, IIf(Buy, colorLime, colorRed), 0 );
}

_SECTION_END();

_SECTION_BEGIN("Indicators");
Plot( AccumulatorLine , "AccumulatorLine ", ColorRGB(255,0,0), styleNoTitle | styleNoLabel);
Plot( SellLine , "SellLine ", ColorRGB(100,0,0), styleNoTitle | styleNoLabel | styleArea );
Plot( BuyLine, "BuyLine", ColorRGB(0,0,100), styleNoTitle | styleNoLabel | styleArea );
_SECTION_END();


----------



## wayneL (20 March 2007)

Muchas gracias.  

But, if your new at Amibroker then I am very depressed LOL

[will report back later]


----------



## mrWoodo (25 March 2007)

Cheers Wayne - I'm a programmer, so unfair advantage  

I misread a bit of Corcorans text, and have changed the Buy signal to :

Buy = Cross ( AccumulatorLine, 0 ) AND ( BuyLine < 0) AND ( BarsSince ( Ref(AccumulatorLine, -1) > 0 ) > BuyWindow); 
Buy = ExRemSpan(Buy, 8) AND f;

It's a bit more selective, refer attached, same stock


----------



## wayneL (25 March 2007)

Cheers mr Woodo that makes me feel better  

It looks interesting and have been lazily running this over some stocks. Will have a look real time as well.

Cheers


----------

