Please help AFL coding for Exploring/backtesting EOD data with my strategy

#1
I have daily EOD data of NSE in my Amibroker. I want to scan /explore stocks which meet my criteria. Please help me with the code.

Criteria:
Today's high should be 2-Month High and also today's range (high-low) should be largest out of previous 5 trading days.

I want to scan/backtest/explore stocks depending on the above strategy. Please help me.
*Note: I want this to happen on a Daily Chart. I tried with TimeFrameSet(inMonthly) command but i doesnt seem to get it work. Please help.
 

Ajax

Well-Known Member
#3
Buy = Cross(H,Ref(HHV(H,50),-1));
x1 = Ref(HHV(H,5),-1);
x2 = Ref(LLV(L,5),-1);
x3 = abs(x1-x2);
x4 = (H-L) > x3 ;
Filter = Buy;

AddColumn(C,"Close",1.1,colorBlack,colorAqua);
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 

Ajax

Well-Known Member
#4
correction

x = Cross(H,Ref(HHV(H,50),-1));
x1 = Ref(HHV(H,5),-1);
x2 = Ref(LLV(L,5),-1);
x3 = abs(x1-x2);
x4 = (H-L) > x3 ;
Buy = x AND x4 ;
Filter = Buy;

AddColumn(C,"Close",1.1,colorBlack,colorAqua);
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Figure out
 
#5
correction

x = Cross(H,Ref(HHV(H,50),-1));
x1 = Ref(HHV(H,5),-1);
x2 = Ref(LLV(L,5),-1);
x3 = abs(x1-x2);
x4 = (H-L) > x3 ;
Buy = x AND x4 ;
Filter = Buy;

AddColumn(C,"Close",1.1,colorBlack,colorAqua);
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Figure out
Yup looks good

Sent from my SM-G900H using Tapatalk
 
#7
correction

x = Cross(H,Ref(HHV(H,50),-1));
x1 = Ref(HHV(H,5),-1);
x2 = Ref(LLV(L,5),-1);
x3 = abs(x1-x2);
x4 = (H-L) > x3 ;
Buy = x AND x4 ;
Filter = Buy;

AddColumn(C,"Close",1.1,colorBlack,colorAqua);
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Figure out
Dear Ajax,

Thank you so much for helping me out. I would like to point out on edoubt which is still bothering me, plz help:

x1 = Ref(HHV(H,5),-1); // This statement will tell us Highest High of some candle "A".

x2 = Ref(LLV(L,5),-1); // This statement will tell us Lowest Low of some candle either "A" OR it could be candle "B" also. I mean it will not give the lowest of the same candle "A".

Please comment on it.
 
#8
try this.
Code:
//requested by Trader_Sanky. 30/12/2017
//created by https://twitter.com/ert_analiz

period=Param("period",50,5,200,1);
dayhigh=hhv(h,period);
range=h-l;
analiz= h>=ref(dayhigh,-1) and range>Ref(hhv(range,5),-1);

Plot( c, "Price Chart", IIf( O < C, colorGreen, colorRed ), styleCandle );
Plot(Ref(dayhigh,-1),"hhv50",colorBlue);
PlotShapes(analiz*shapeCircle,colorGreen);

filter=analiz;

addcolumn(analiz,"analiz",1.2);