Intraday AFL backtesting for Amibroker

Hello Seniors,
I wanted some help from your end.

my code say for example is as below
Buy=C > EMA(C,30);
SELL = C < EMA(C,30);

i want to perform backtesting to check certain results the criteria is as mentioned below:
1. I require no overnight postion so every poistion should be squared at 3:30 @ close
2. During the day if the close of the current bar exceeds by 2 percent than my buying price i would sell 50% quantity only if the high for the current bar is higher than my profit target which is 2 percent from the buy price.
3. suppose if today i have buy signal @ 10am then according to my requirement I have squared up my position @ 3.30pm. means the trend is in buy, now the next day morning after the 9:30am bar is complete i want the trend to continue which is Buy and Buy @ the close of the bar if there is a fresh signal generated which is sell in case of buy reference we are talking then we should consider the sell signal .
4. Signals if in buy keep on continuing for more than one day then the same should be bought @ 9.30am bar and sold @ 15:30 pm bar and continue till the short signal is not encountered along with it should also check if the CMP has exceeded by 2% then 50% poistion should be booked comparision would be with the 9:30am buying price in case of continuing trend..

Please help seniors any query pertaining to my problem is welcomed.

Zerodha – Open Paperless Account

Open online account with Zerodha. Free delivery trading and Max Rs 20 for Intraday, F&O, Currency and Commodity Trading. Intraday High leverage with MIS, CO and BO.

Are you a day trader?