Hi
I am using Amibroker 6.00.2. I am new to AFL.
I am trying to write code for "Opening Range Breakout" strategy.
I could see the "Sell and Cover trades" within "Scan" of analysis, but when I run backtest, Backtest report (which is blank) not able to fetch and diplay trades.
Please could you help to solve this problem? Or will also be helpful if anyone could share backtestable sample AFL for "Opening Range Breakout" strategy.
Thank You in advance!
Please find code of my AFL below:
//Not yet added stop loss related code
market_start_time=091500;
brake_out_time=093000;
market_end_time=151500;
//target_point=Optimize("target_point",20,5,500,1);
target_point=50;
EndDay = (Day()!= Ref(Day(), 1));
buy_occurred = False;
short_occurred = False;
Highest_since_start = HighestSince(market_start_time,H,1);
Lowest_since_start =LowestSince(market_start_time,L,1);
ORBH = ValueWhen(brake_out_time,Highest_since_start,1);
ORBL = ValueWhen(brake_out_time,Lowest_since_start,1);
if(buy_occurred == False){
Buy=IIf(Cross(C,ORBH) AND (TimeNum()>brake_out_time) ,True,Null);
buy_occurred = True;
}
if(short_occurred == False){
Short =IIf((Cross(ORBL,C) AND (TimeNum()>brake_out_time)) ,True,Null);
short_occurred = True;
}
BuyPrice=ValueWhen(Buy,C,1);
ShortPrice=ValueWhen(Short,C,1);
SellPrice1=BuyPrice+target_point;
Sell_Cond=Cross(H,SellPrice1);
Sell=IIf(((buy_occurred==True) AND ((Sell_Cond==True) OR (EndDay==True))),True ,Null);
//Sell=IIf(((buy_occurred==True) AND ((Sell_Cond==True) OR (market_end_time <= TimeNum()))),True ,Null);
SellPrice=ValueWhen(Sell,H,1);
CoverPrice1=ShortPrice-target_point;
Cover_cond= IIf(L<=CoverPrice1,True,False);
Cover=IIf((short_occurred==True) AND (Cover_Cond==True OR EndDay==True),True,Null) ;
//Cover=IIf((short_occurred==True) AND (Cover_Cond==True OR market_end_time <= TimeNum()),True,Null) ;
CoverPrice=ValueWhen(Cover,C,1);