Math for partial closing and re opening.

 

Hi,

I am developing an ATS that contain a module for partial closing and reopening.. I need some help for the math/formulas that will control this feature.. In summary, the feature will partially close a trade size on a number of grid levels and if price retern back to the previous grid price, EA will re-open another size.

For example.. At price 1.5000, EA has a buy trade size 10 lots. TP was 1.6000. However, i need the feature to control this trade to partially close it " for example on 10 levels with 100 pips inbetween"..

The limitations will be: 1- I need to achieve a certain percentage of profits on a certain price grid.

2- if the price oscillate in a narrow range for longer period of time so EA will reopen new sizes and collect small profits to achieve the TP. Even with the price didnot go to 1.6000.

I could send the example on an excel sheet so you could help me to do the math.

Sorry for my language

McGene