Hello
So, MathMod() eh? What's this crazy function all about?
what is this line supposed to be doing?
double MathMod( double value, double value2);
if you remove that it will compile... it is easier to help if you post the actual code you used.
if you want the whole lots without remainder just use MathFloor on the output of your expression.
Sorry Paul, that was just inserted here to give the reader some context as to the syntax of the MathMod() function. It compiles with no issues.
MathMod returns a double not a boolean.
But you are over complicating it, if you simply want the lowest whole value try this:
void OnStart() { int partialCloseLotsNum = 3; /*This is expressed as the numerator fraction*/ int partialCloseLotsDen = 4; /*This is expressed as the denominator fraction i.e. 2 = 1/2, 4 = 1/4*/ int LotSize = 13; double wholeLots = MathFloor(LotSize * partialCloseLotsNum / partialCloseLotsDen); Print("Whole Lots: " + DoubleToString(wholeLots,2)); }
MathMod returns a double not a boolean.
But you are over complicating it, if you simply want the lowest whole value try this:
Ah Yes, it's exactly what I've just done before seeing your last answer. When you clarified that, it all made sense. Then you insert
wholeLots
into the "OrderClose" syntax under under "double lots," .
Thanks again.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello
So, MathMod() eh? What's this crazy function all about?
I''ve coded up a partial position close once certain parameters are met, have have set the amount of lots with which the position is to be closed by as a fraction (i.e. 1/2 = half of the lotsize etc). This works swimmingly, but I wanted to employ a check function to ensure that it only closes whole lot sizes. If I had 13 lots and I wanted to close of the lots, I can't close 9.75 lots because it does not divide wholly
Now, the MathMod() function, as you will know, returns the remainder of the division of two values. So you will always want the remainder to always be 0, so you will always be closing out whole lots.
I have the following code:
However, the result I am getting is:
2021.09.27 12:42:08.081 [EA NAME] EURAUD,H4: Close Lots Pass 0.00
3/4 of 13 IS 9.75, so it should give a remainder is 1 remainder 4 - which completely contradicts that the result is printing.
Am I misreading the way in which MathMod() works or am I missing something blatantly obvious?
Thanks