This reminds me of adding to volume on loss, here is an example for this. This example works on every tick, so it adds new trade on the first tick where the distance is detected, but if you want to do something only on the first tick of each candle, just place "Once per bar" on the top - or above block 3 in this example.