select open order farthest away
-
I want ot select an open sell order from a bunch of open orders with the following characteristic, irrespective of size I want to select the order that is the fartest away from current price.
Any easy way to do that?
-
This should do it, but you'll have to switch the flag on/off when you want this to be closing a trade. This is the logic it's using:
checks a flag to see if starting the loop trees is allowed - takes the open price of the latest trade and works out it's distance in points from the current ask price - sets the flag to false to stop a new tick from starting the loops again - loops through every running trade, gets it's distance from the ask price and if it's larger than last saved it saves it into a variable - starts the last loop and compares all trade distance until it finds the biggest, closes the trade and sets the flag to true (this starts the loops again so will close the next farthest away trade, so ensure flags are switched on/off as necessary).
Test and let me know if it's doing as required, where it closes you can replace with whatever you want to do with the selected trade: https://fxdreema.com/shared/HR92Ux2Nd
-
Impressive structure.
-
@jstap Thanks! Impressive
I will test this week and lot you know -
It seesm to be doing what is described I need to test further with greater pools of open trades. but it is great THANKS!
-
@holygrailfx You are welcome