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 put in a pending order "OP_BUYSTOP" but I was under the impression that this would change when triggered to an "OP_BUY"?
I thought the order type would be "OP_BUY" if it had been triggered?
Afterall, I am only interested ONCE the order has been triggered?
Why are those braces confusing? Do you mean in terms of where the left parenthesis is? If so, it seems that is an individual thing, as I have been corrected on this multiple times?
The braces are not needed, so the fact they are there can cause confusion for other trying to read your code (me).
If you only have a BUYSTOP then your code will not do anything because it is not an OP_BUY . . .
Hmmm, still does not want to close @ "Close_Half_Order" ? Not getting any error message either?
so this make sense while the Order is still pending . . .
Does your Order have the correct Magic Number ?
I removed the line "if(OrderType()==OP_BUY)" - This is the new print outs within the journal after the test? Invalid Ticket... (sorry for asking 101 questions about this!)
RaptorUK:
You don't close a pending Order, what did your error reporting tell you ?
You can't close a pending order, they get deleted.
But I am not trying to close a pending order? I am trying to close half of the lots on an "OP_BUY" which is not pending...? I'm obviously missing something here...
I put in a pending order "OP_BUYSTOP" but I was under the impression that this would change when triggered to an "OP_BUY"?
If I remove "OpenOrdersThisPair(Symbol()) == 1" from the code, the messages are exactly the same within the journal... I'm baffled...?
Time to add some more Print() statements, check everything you haven't already checked . . . you are only baffled because you don't know why, find out why and you will no longer be baffled.
When you have found out why and you have all these Print() statements that you no longer want printing to the Journal/Experts tab have a look at this which will allow a nice way of turning them on and off: https://www.mql5.com/en/forum/135168/page2
Ah, by the way, you can't do this . . .
. . . unless FirstTarget_Buy happens to == Bid To remove the possibility that it isn't just use Bid. A Buy is closed with a Sell, a Sell is executed at Bid.
How am I supposed to close the position out at "FirstTarget_Buy"?
Ok, so if I put "Bid" there, the lots are now being closed out, but not at the correct price, and it seems to close out several halves during any one position. (more toward the top 2/3rds of the 100% target price area... not all the same price that they're closing at...)
How am I supposed to close the position out at "FirstTarget_Buy"?
You can't OrderClose() at any price other than Bid and Ask (Buy and Sell) . . . it's that simple, you cannot.
What you can do:
open two trades for half the position each and give each a different TP
or
monitor Bid/Ask price and when it has reached or passed "FirstTarget_Buy" close half the trade at Bid/Ask