How to code a take profit at an institutional level

Hi all,

attempting a new EA, currently need to find a way to code take profit to be sent in the ordersend.

Take profit should be set at institutional levels 00 || 20 || 50 || 80 as long as that distance is more >= StopLoss (larger or equal to 1R).

So i figure i need to

  1. measure distance from the bid || ask (depending on trade direction) to the nearest level

  2. comparing that distance to the SL

  3. take profit at the required level

The comparison side and setting take profit in to ordersend I should be fine with, just cant think of a way to measure distance from bid || ask to the nearest level.

Any suggestions would be great.

or how to create the levels around current price would be a great start.

could then save those levels as a double and use that to compare. Then the value of those doubles could be put straight in to the TP of ordersend

sorry guys typing ideas as i get them

Maybe I can just grab the first 3 digits of the bid || ask and apply levels to the end…
(would have to account for 2/3 4/5 digit pairs)