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
Well you have to "tag" the order upon its creation somehow, in a unique way. Later on you retrieve the tag. I do not think that there is a simpler way.
Also I think that you have not explained your problem well: how do you create orders - manually? Is there always to be four orders? And maximally four orders? And so on..
Yeah that is of course a problem because you cannot tag manually created orders with magic numbers (however comment is possible - you can use the comment as a tag).
Maybe try to distinguish the orders by their time of creation (not sure if this is possible).
Forgive me for doubting what you're saying, but I have a hunch that there is a way. What I do doubt is that we've found a limitation of MT4... When you do a for loop by position, it'll index 0 through to nth number....
Each open position has a fixed take profit target that is different. 4th has the further Reward ratio and so-forth...
Is there a way I could do it using the TP?
I am not quite sure what you are looking for - may be this helps?
To close an order you have to know the ticket number!
You either have saved it: ticket = OrderSend(..) or you have to get it by OrderSelect() and e.g. OrderMagicNumber()..
Forgive me for doubting what you're saying, but I have a hunch that there is a way. What I do doubt is that we've found a limitation of MT4... When you do a for loop by position, it'll index 0 through to nth number....
Each open position has a fixed take profit target that is different. 4th has the further Reward ratio and so-forth...
Is there a way I could do it using the TP?
Sure. Anything that can identify an order will do the trick.
So for example, lets say I select (extern) "Order3" ... Well, this is supposed to be BuyTicketOrder3, or ticket number #3 (for the first ever 4 trades placed). Now, this whole thing above, closes the trade where it should and the right trade. Then the next 4 trades open from another setup... no more closing. I printed it out and OrderSelect endlessly changes through the OrderTickets...
Just looking for some guidance as to gaurantee that what I select "Order3" is going to correspond with the right ticket...?
Just looking for some guidance as to gaurantee that what I select "Order3" is going to correspond with the right ticket...?
Not sure but ticket numbers might be unique for the run, while position numbers are not:
Your code (and or the program-logic) is wrong :
SelectOrder == OrderTicket() // this only accidentally true for the first 4 orders in the tester! ... //this is completely wrong!! OrderClose( SelectOrder, OrderLots(), Bid, 5, CLR_NONE );
OrderTicket is an Integer: -2 147 483 648 .. is 2 147 483 647!!
SelectOrder an enum between 0..4
Where have you saved the ticket-number of OrderSend()?
The ticket is a 'reference' of you broker! I think you should use the Magic number (this is 'your reference') for what I think you want to achieve.
Ahhhhh I seeeeee! Well, can you see what I was trying to do though?
I was under the impression that SelectOrder would "store" the corresponding variable "BuyTicketOrderx" with "Orderx" but it just holds 0 through 4.
I am wanting a way that when I select externally the order ticket number, in that code above, it will use that ticket number within the function and close just that ticket number? Hope that makes sense?
MagicNumber would work but it's a ball-ache for now change a lot of my code when I am convinced I can do it this way^?