Controlling BuyPrice and ShortPrice

I am trying to control the Buy/short Price. I tried to use the idea expressed below,i.e. taking a long with a buy stop at yesterday’s high, if and when the price rises at least back to yesterday’s high. What would happen is that the position is taken not at the buy stop, but at the day’s high? As the trade is taken with a one bar delay, I adjusted to this as you can see below. As the conditions are generated before the day of the trade, is there a problem?
Thanks,
Richard

tradeDelaybuy = 1;tradedelaysell=1;
tradeDelayshort=1;tradeDelaycover=1;
SetTradeDelays(tradedelaybuy ,tradedelaysell ,tradedelayshort ,tradeDelaycover );

……………………..

Buy= buycond1;// AND buyprice>L AND BuyPrice<H;
BuystopPrice=Ref(H,-1);
Buy=Buy AND buystopPrice;
BuyPrice=buystopprice;
Short= shortcond1;// AND ShortPrice>L AND ShortPrice<H;;// AND shortprice>L AND ShortPrice<H;
shortstopprice=Ref(L,-1);
Short=Short AND shortstopPrice ;
ShortPrice=shortstopprice;