
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
Beautiful!
I wonder if it can even handle "CloseAll"?
CloseAllType();
This is turning out to be a high-level education in programming. Unbelievable that such generosity still exists.
So if no parameter like OP_BUY or OP_SELL is passed, the function closes all orders?
If OP_BUY is passed it closes all longs and if OP_SELL is passed it closes all shorts?
There is no risk that it closes the wrong order if the spread is less than the slippage?
There is no risk that it closes the wrong order if the spread is less than the slippage?
Yes, if no param is passed, it should close all buy and sell orders. Otherwise the given ordertype.
You don't have a check for the spread though.
Please note: i didn't test the adjustments I made in your function. But at first glance it seems to be right
btw you allready checked if orderselect was valid so this check
can be skipped.By having separate functions for longs and shorts I ensure that the correct orders are selected.
btw you allready checked if orderselect was valid so this check
can be skipped.Early in the discussion, Gordon wrote "And u should also check OrderSelect()'s return value."
8) Yes and gordon was right about that.
OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == false
here you select your order on it's position in the array of open trades, and you check if it was successful. If not, you go to the next position. (the continue)
with the order already selected, you select it once more
OrderSelect(ordticket, SELECT_BY_TICKET, MODE_TRADES) == true
but there is no need to do so, because it is already selected, and you checked if it was. So the chance that the order selection isn't valid anymore, is almost zero. There are only a few instructions between your first select and the execution of OrderClose.Very educational. Thank you both, Gordon and Russell, for your fantastic contribution.
Warmest regards, Helmut