close a certain number of lots of any previously opened position , the order which is modified or partially closed is not important though

 

if i have any ea that opens multiple buy positions and sell positions and i would like to close 0.01 lots of any of the buy positions for example then what is the least complicated way of doing that ? 


for example , the ea i coded opens 4 different buy positions with different lot sizes at different times as the pre-established conditions for opening each buy position are met , but then when another pre-established condition is met i would like to decrease my exposure by 0.01 lots which could be achieved by closing 0.01 lots of any of those previously opened buy positions 


i don't care which order is modified or partially closed , it could be the most recently opened buy position or the least recent , but what is the least complicated way of doing that ? 


thank you to any of you who can provide me with any useful information to solve this problem i've been having 


i would be most interested in any response 

 
Just close 0.01 lots of any of the open positions.
 
Keith Watford:
Just close 0.01 lots of any of the open positions.

what would be some code i could use to do that ? 


i heard there are also different ways of initiating orders and the way i did it was , for example : 


int a = OrderSend(Symbol(), OP_BUY, Lot, Ask, 30, Bid - StopLoss * Point, Ask + TakeProfit * Point, NULL, MagicNumber, 0, clrGreen); 


so if all the buy orders opened at different times with different lot amounts have the same int " a " then what would be some code i could use at any time to close a certain number of lots of any previously opened buy position(s) ? 


maybe this is a question which would have a very obvious answer to some people but i am uncertain what code would be the least complicated to achieve the proposed result 

 
aaron1111:

what would be some code i could use to do that ? 


The OrderClose() function.

Reason: