is I am selling and when bid reach my first take profit (variable = profit),
then i want to close 80% of the position..
If the variable "profit" is a price level (not a profit in points, pips or currency) then the first condition could be so. If the variable "magic" is a ticket number (not a magic number) the second condition could be so too. In the function OrderClose use OrderClosePrice() instead of Bid as Keith said. Realize that we see a piece of your code and we can't have an overall picture.
Thanks for your comment.
I really appreciate. it is true that I do not know what I am doing with this magic number.
playing with it for nothing I think.
thanks for pointing out that to me.
Have a good week-end
I do not understand the problem with the magic number.
i use it only to make sure that my EA manage the trade i want only..
1. Why do you suggest that was a problem?
2. If i do not want a magic number what should I write instead?
int sell = OrderSend(Symbol(), OP_SELL, lot2, Bid, 4, Bid + stop2, Bid - profit, "Ordre Vente Executee", magic, 0, clrRed);
int ticket = OrderSend(_Symbol, OP_SELL, lot2, Bid, 4, stoploss, takeprofit, "Ordre Vente Executee", magicNumber, 0, clrRed);
and then you can select the order by ticket:
If you want to filter your orders by magic number you can use something like this:
if(OrderSelect(pos,SELECT_BY_POS) && OrderMagicNumber()==magicNumber)
// do something
I understand clearly what you are saying.
So, I change and everything work, but the variable "magicNumber" appear in red through all the codes.
Do you know what this mean?
This is standard color text formatting in MQL editor. If you declare a variable as extern or input then it will be red in the code. As you can see numbers are green, built-in functions are violet...