Partial close (50%) for odd number lot size
-
How do I partially close an odd number lot size? In testing it only works for even numbers. I'm trying to figure out if there's a way to adjust the variable but I'm having trouble. Here's what I have so far. https://fxdreema.com/shared/c4bu20U9
-
As far as I know, you cannot unless your broker allows it.
-
@kmfoster79 You will need to normalize the lot size for de the partial close.
-
@eklonsousa Do you mean in the EA or when I place the order, only use even number lots?
-
@kmfoster79 You need to use the function "Normalize" for the lot to be closed.
Ex: You have the variables as LotSize, Lot1_Close.
Then you will calculate the size of the Lot1_Close based on a % of the LotSize.
Let's say that Lot1_Close will close 50% of the LotSize, that in that example is 0.05.
So 50% of 0.05 would be 0.025, but it's not possible. You need to use it that code to get the correct lot that would be 0.03."Lot1_Close = NormalizeDouble(Lot1_Close,2)"
-
@eklonsousa You mean doing it with a custom code block, Right?
-
@l-andorrà Yes, that's right.
I'm doing this with one of my EAs. Like this:
https://fxdreema.com/shared/BhC5kekB
This is only the Partial close side.
-
Very interesting. Thank you.
-
I think the issue is that when the lot size is not valid and needs to be rounded to the nearest valid value, the EA rounds it to the nearest... maybe from the up side. I think it all happens in one of my functions called AlignLots in which I have this row of code:
lots = MathRound(lots/LotStep)*LotStep;LotStep is the minimum lot step, normally 0.01 or 0.1. MathRound is described like this:
The function returns a value rounded off to the nearest integer of the specified numeric value.
-
In this case it will only calculate the initial lote size, right?
I mean, it will calculate the lote size based on something as stop loss size.
The issue is when you try to partial close an odd lote size.
-
@eklonsousa Hello! And where do you get the lot step value? Maybe on Markes Properties? Thank you!