Maybe you can modify your algo to trade only at candle start.