Download MetaTrader 5

Pepperstone's MT4 Demo account: OrderClose(), OrderClose() do not work properly

To add comments, please log in or register
Daniele
6
Daniele  
By the Pepperstone's MT4 I see unusual behavior related to primitive function of MT4 that I summarize by an example

Eg. lot size = 2.3

- OrderLots(): it returns only the integer part of real lot size. -> In this case OrderLots() returns 2

- If I use OrderClose(OrderTicket(), OrderLots(), 0.0, 3.0) so it lets my opened a part of trade related of current ticket left me still 2.3-2.0 = 0.3 lots opened.

- then, if I call the OrderClose() combined to the new Ticket (opportunely selected by OrderSelect(...)), it returns 0.0 even if this Ticket present 0.3 lots.

Someone suggests me any proposal solution?

Thank you in advance

Regards,

Daniele

whroeder1
15592
whroeder1  
danidani82: If I use OrderClose(OrderTicket(), OrderLots(), 0.0, 3.0)
  1. You need to RTFM
    OrderClose(OrderTicket(),          OrderLots(), 0.0, 3.0)
    OrderClose( OrderClose(int ticket, double lots, double price, int slippage, color Color=CLR_NONE)
    Bad price, function will always fail.
  2. What are Function return values ? How do I use them ? - MQL4 forum
  3. I doubt it. POST your code.

    Play video
    Please edit your post.
    For large amounts of code, attach it.

Keith Watford
Moderator
10568
Keith Watford  
danidani82:
By the Pepperstone's MT4 I see unusual behavior related to primitive function of MT4 that I summarize by an example

Eg. lot size = 2.3

- OrderLots(): it returns only the integer part of real lot size. -> In this case OrderLots() returns 2

- If I use OrderClose(OrderTicket(), OrderLots(), 0.0, 3.0) so it lets my opened a part of trade related of current ticket left me still 2.3-2.0 = 0.3 lots opened.

- then, if I call the OrderClose() combined to the new Ticket (opportunely selected by OrderSelect(...)), it returns 0.0 even if this Ticket present 0.3 lots.

Someone suggests me any proposal solution?

Thank you in advance

Regards,

Daniele


I don't see how this code would close any part of a trade as price will not be 0.0

More likely that you are assigning the value of OrderLots to an integer variable and using that

To add comments, please log in or register