Generating REALISTIC buy and sell signals in Amibroker backtesting

I am new to coding, and am trying out a simple strategy just for practice purposes. I am trying to generate a realistic BuyPrice for my AFL.
After a buy signal is triggered, I want the BuyPrice to be set to the high of the next 1 minute bar.

I know that I can use something like the following:
Things go on smoothly when I am backtesting my strategy with 1minute time frame. But I want to run my strategy on an Hourly timeframe. In such a case, with the above code, my BuyPrice is triggered at high of the next hourly candle after buy signal. But I want BuyPrice to be the high of next 1 minute bar and not the next 1 hour bar. Could this be done on a hourly chart?

Any help will be greatly appreciated.
Last edited:
Found the solution. This was posted by Happy_Singh on another thread.
yes small changes, refer to Amibroker help file for multi timeframe usage spefically use of expand- first/last options
also use ExRem to remove excess buy/sell signals

TimeFrameSet( inHourly ); // switch to generate buy sell signals in hourly TF 

MYbuy=My condition;   //generate buy signal in hourly TF
MYsell=My condition;   //generate sell signal in hourly TF

TimeFrameRestore(); // this restores to original to 1 minute TF

Buy = TimeFrameExpand(MYBuy, inHourly);  / converts signals back from hourly to current TF (i.e. 1 Minute)
Sell = TimeFrameExpand(MYBuy, inHourly);

Happy :)

Intraday Higher Leverage

Save up to 90% in brokerage and get higher leverage for intraday trades.

Are you a day trader?