You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I'm sorry but this is both incorrect and ignorant. First, there is an implied misunderstanding of what CloseBy is and how it works. CloseBy is not a trade operation, it is an accounting operation. The CloseBy operation has absolutely no bearing on position's profit because its obly job is to instruct the trade serve to reconcile offsetting deals to be used as one order closing another. It does not matter what order you close them in, and time has absolutely no effect either. The most important thing you have missed with your code (You need to do one cycle) is because you scanning tickets first you will miss and skip deals still in the pool. You will miss them because when you use a larger one to close a smaller one that deal is modified and issued as a new position. That is not good. In order to account for the mutating order pool you need to either restart the entire loop (ugly and error prone) or use recursion so the function can call itself and restart the iteration over your freshly mutated position pool. David's code didn't work because he didn't use my code. He removed the most important abstractions and turned it into something else.
In summary:
Nicholish, you are precisely correct on your explanation!
Thanks for the recursion function, just found it here while look for another thing, but i got interested on it, and it works perfectly!