Need afl codefor this

close reached a new 52 week high within the last 10 days

and close more than 5 percent below close 52 week high
and close less than 10 percent below close 52 week high

Here when price reaches 52 week high and price consolidates there for about minimum 2 week and after that price reaches new 52 week high which is 5 to 10 % of old 52 week high price and pulls back to old 52 week high.then buy signal ,and same condition with 52 week low for sell signal.

For the above given condition check the below Amibroker AFL

// Calculates new 52 week High's vs new 52 week lows.
// The new symbol "~NewHiNewLoIndex" will be found in the Workspace > Symbol > All > at the end.
// Input a Date 5 years back to the current Date in the Range section of the Analysis Window AND click the From button.
// In the Apply To section, click the Use Filter button AND click the Define > Include > Group > Stock 
// to scan stocks ONLY. Right click on chart window, then > Parameters > Show MiddlLe Lines - NO > Levels > +-100.
// Compare against the SP-500, look for convergences, divergences. Read Elder's book "Trading For A Living" pp.194-200.

H1 = High > Ref(HHV(High,260),-1);
L1 = Low < Ref(LLV(Low,260),-1);
HiLoDifference = H1 - L1;

Buy = 0; 
Filter = 0;

AddToComposite( HiLoDifference , "~NewHiNewLoIndex", "X", atcFlagDefaults = 7);

GraphXSpace = 10;
Plot(Foreign("~NewHiNewLoIndex","C",1),"52 Week New High - New Low Index",colorYellow,styleHistogram);