HELP Error Code AFL // Buy 5 session before end of month and Sell 3 sessión next month

Dear friends,

I have a problem with this code.

Thanks for your help.

//Daily SISTEM // Buy 5º session before end of month // Sell 3º sessión next month

PosQty = 1;
SetOption("MaxOpenPositions", PosQty);

isEndOfMonth = TimeFrameExpand(1,inMonthly,expandPoint);
isEntryDay = Ref(isEndOfMonth,5);

Buy = isEntryDay

//ApplyStop( stopTypeNBar, stopModeBars, 3 );

BuyPrice = Close;
SellPrice = Close;