- First problem is not closing multiple times. Move to BE before closing so you know you already did it.
-
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Blue);
What do you think that line does? ERR_NO_RESULTYou Server Change the SL to X It is at X! Change the SL to X It is at X! Change the SL to X You are insane Insanity: doing the same thing over and over again and expecting different results.Compute the new value, then check that you are moving the existing value at least a tick. PIP, Point, or Tick are all different in general.
Unknown
What is a TICK? - MQL4 programming forum -
OrderClose(OrderTicket(),OrderLots()*(percentage/100),Ask,3,clrYellow);
You can't just use OrderLots()/2 because that is not a multiple of LotStep, and you can't close or have remaining less than MinLot. See my code. - You also must check if you have already done it, to avoid repeated closing.
- First problem is not closing multiple times. Move to BE before closing so you know you already did it.
- What do you think that line does? ERR_NO_RESULT
You Server Change the SL to X It is at X! Change the SL to X It is at X! Change the SL to X You are insane
What is a TICK? - MQL4 programming forum - You can't just use OrderLots()/2 because that is not a multiple of LotStep, and you can't close or have remaining less than MinLot. See my code.
- You also must check if you have already done it, to avoid repeated closing.
your answer is so confusing are you sure you read my code i moves sl to be before closing , im not doing OrderLots/2 im using OrderLots*percentage*100, i got your idea of cheacking wether i already modified or closed partially the order but how i go a long with that is ther a built function to cheackthat??
if(Bid-OrderOpenPrice()>(OrderOpenPrice()-OrderStopLoss()))
Think about what this condition outputs once the SL has been moved to BE.
void be_cl(int percentage) // Print("closing ",OrderLots()*(percentage/100));
percentage and 100 are both ints and so the result of the division will be an int, as it will be less than 1, it will be 0.
Change your code to
Print("closing ",OrderLots()*(percentage/100.0));
And take note of what William posted.
You can't just use OrderLots()/2 because
that is not a multiple of LotStep,
and you can't close or have remaining less than MinLot.
See my code.
the 2 is not important as it applies to any multiplication or division of OrderLots().
Think about what this condition outputs once the SL has been moved to BE.
percentage and 100 are both ints and so the result of the division will be an int, as it will be less than 1, it will be 0.
Change your code to
Ok so let me see if get your point, when multiplying with percent*100 it converts to int , so i need to make to change it to 100.0 so it be double , right?
Yes

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hi guys , im writing function to move stop loss to break even and close percentage of the order im geting errors in the ordermodify and orderclose opreator when i print the resuilts in journal i get the orderlot()=0.0 before i even issue the orderclose commandm any help will be apriciated thanks
the journel output