Amibroker Accumulation/Distribution Divergence Scan Code?

mrfixituk

Junior member
43 0
I am a new user to Amibroker and I'm trying to recreate a scan I used
on market in out.


ad = AccDist();
Filter = ad > HHV(ad,13)*0.9 AND Close == HHV( Close, 13);
AddColumn(Close, "Close");
AddColumn( ad, "AccDist");
AddColumn( HHV(ad,13), "accDist high");


The code above for example is meant to find accumulation/distribution
bullish divergence vs price in the last 13 days.

These symbols are not showing with the above scan and should because
there is bullish divergence. What am I doing wrong with the code?

CRND.L
JEO.L
ACMG.L

Thanks Very much!
 

fxtr

Member
50 3
With your code you expect the close to be the same as the highest close of the past 13 periods AND AccDist > 90% of the Highest AccDist of the last 13 periods. Both to be true at the same time. Now do yourself a favor and plot both conditions on a chart.

plot this in first chart pane
Code:
_SECTION_BEGIN("Price");
SetChartOptions( 0, chartShowArrows | chartShowDates | chartWrapTitle );
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +"\n {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 

PriceCond = Close == HHV( Close, 13 );
PlotShapes( PriceCond*shapeSmallUpTriangle, colorGreen, 0, L, -15 );
PlotShapes( PriceCond*shapeHollowSmallUpTriangle, colorLightGrey, 0, L, -15 );
PlotShapes( PriceCond*shapeHollowSmallCircle, colorGreen, 0, Close, 0 );

dist = 1.20 * ATR(10);
pToggle = ParamToggle("PlotText","Disable|Enable", 1);
firstbar = Status("firstvisiblebar" );
lastbar = Min( BarCount, Status("lastvisiblebar") );

for(i = firstbar; i < lastbar; i++) 
{
    if ( PriceCond[i] ) if(pToggle) PlotText( "HighestClose\[email protected]" + Close[ i ], i, L[ i ] - dist[i], colorGreen );  
}
_SECTION_END();


Plot this in a second chart pane below
Code:
ad = AccDist();
Plot( ad, _DEFAULT_NAME(), ParamColor("Color", colorCycle ), ParamStyle("Style") );

CondAcctdist = ad > HHV( ad, 13 ) * 0.9;
PlotShapes( CondAcctdist*shapeSmallUpTriangle, colorGreen, 0, ad, -15 );
PlotShapes( CondAcctdist*shapeHollowSmallUpTriangle, colorLightGrey, 0, ad, -15 );
PlotShapes( CondAcctdist*shapeHollowSmallCircle, colorGreen, 0, ad, 0 );
 

fxtr

Member
50 3
What "now what"? You can't apply the codes or what?

In case you have applied them on symbols

CRND.L
JEO.L
ACMG.L

What do you see? You can follow?
 

mrfixituk

Junior member
43 0
What "now what"? You can't apply the codes or what?

In case you have applied them on symbols

CRND.L
JEO.L
ACMG.L

What do you see? You can follow?

Yes I see them applied to the symbols, but the problem is that the original code doesn't actually find any divergence when doing a scan of 3000 symbols no matter what parameters I use so is wrong.


ad = AccDist();
Filter = ad < HHV(ad,100)*0.9 AND Close == HHV( Close, 100);
AddColumn(Close, "Close");
AddColumn( ad, "AccDist");
AddColumn( HHV(ad,100), "accDist high");


I changed the for example the 100 to 13 for 13 days/bars and also tried changing 0.9 right down to 0.1

Still stuck.
 

mrfixituk

Junior member
43 0
I came across this method for stockcharts.com but again am not sure how this would be written for amibroker.

Price higher than the highest close during the previous five days
and Chaikin Money Flow (CMF) currently lower than
the lowest reading during the same period

[type = stock] and [close > yesterday's max(5,close)] and
[CMF(20) < yesterday's min(5,CMF(20))]
 

fxtr

Member
50 3
Yes I see them applied to the symbols, but the problem is that the original code doesn't actually find any divergence when doing a scan of 3000 symbols no matter what parameters I use so is wrong.


ad = AccDist();
Filter = ad < HHV(ad,100)*0.9 AND Close == HHV( Close, 100);
AddColumn(Close, "Close");
AddColumn( ad, "AccDist");
AddColumn( HHV(ad,100), "accDist high");


I changed the for example the 100 to 13 for 13 days/bars and also tried changing 0.9 right down to 0.1

Still stuck.

The problem is you don't provide any info what you are actually doing and what you wanna see. Are you using EOD? What are your settings in the auto analysis etc.? What results do you wanna see. Current day?


Anyway if applying my two codes then it looks this way for symbol ACMG.L
adist.png


So most recent signal is at March 4th where both conditions were true.

And auto analysis shows same result if using your code
acctdist2.png
 

mrfixituk

Junior member
43 0
I am using eod but on the trial version so makes it harder to use. If I can get the results I want I will buy the full version. I take it the auto analysis function using explore will only search and find symbols that currently showing divergence and not the whole 3000 symbols and when there has been divergence.
 

fxtr

Member
50 3
I take it the auto analysis function using explore will only search and find symbols that currently showing divergence and not the whole 3000 symbols and when there has been divergence.

If you set to ALL symbols and ALL quotes then it will list ALL results (past and most recent !true! conditions) for ALL symbols (no matter if data base consists of 3000, 5000 10000 or just 10 symbols) so your assumption is wrong. If you set to ALL symbols and 1 recent bar then it will list most recent true signal occurrences only. But if there is no 'true' condition for ALL symbols at most recent bar then of course it's no surprise that explorer could be empty then. It just depends on your code and what you input. In addition you can set to most recent days and you can set from-to-dates in Auto Analysis. To be honest I don't understand your difficulties it's pretty easy actually (of course IMO).
 

fxtr

Member
50 3
Here is a different version of your original code. Use this one and I think you will understand better.

Code:
ad = AccDist();
cond = ad > HHV( ad,13 ) * 0.9 AND Close == HHV( Close, 13 );
mostrecentdate = ValueWhen( Cond, DateTime() );

Filter = Status( "lastbarinrange" );

AddColumn( Close, "Close", 1.2 );
AddColumn( mostrecentdate, "Most recent date/time of true signal", formatDateTime );
AddColumn( ad, "AccDist", 1.2 );
AddColumn( HHV(ad,13), "accDist high", 1.2 );
 
 
AdBlock Detected

We get it, advertisements are annoying!

But it's thanks to our sponsors that access to Trade2Win remains free for all. By viewing our ads you help us pay our bills, so please support the site and disable your AdBlocker.

I've Disabled AdBlock