Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 832

 
borilunad:
This is because the Expert Advisor does not "drop" a fractional part before calculation, while the calculator "drops" everything exceeding its "solvability" by the total number of digits.

It does not matter how many digits after decimal point (by the way 16, more than enough for most problems outside of nuclear physics or quantum mechanics), it does not matter their meaning, after trimming whole part will be the same. And then the differences begin.

Yes, by the way, in some test runs initial lot values are correct - both in the calculator and in the Expert Advisor 0.04. But sometimes the Expert Advisor gives 0.05, although during the test it shows 0.04. Although initial funds are always 1000.

PS: the question is removed, I have set MarginRequired in lot calculation, check calculation has the same result as EA.

 
eddy:
Can you create buttons on the chart? I want a closing cross to be dangling beside the price line
Isn't it easier to write a script and put it on the chart at the right time? The script works long enough and then disappears.
 
evillive:

By the way, no matter how many digits after the decimal point (by the way 16, more than enough for most problems outside of nuclear physics or quantum mechanics), no matter their value, after trimming integer part will be the same. And then the differences begin.

Yes, by the way, in some test runs initial lot values are correct - both in the calculator and in the Expert Advisor 0.04. But sometimes the Expert Advisor gives 0.05, although during the test it shows 0.04. Although initial funds are always 1000.

PS: the question is removed, I have set MarginRequired in lot calculation, check calculation has the same result as EA.

It makes sense, because in the calculator the calculation is done step by step, so there are more "kickbacks" than in the Expert Advisor by the formula!
 
the script is not suitable for the task of closing an order as quickly as possible at the right price.
 
borilunad:
It makes sense, because the calculator calculates step by step, so there are more "tilts" than the EA uses a formula!
And the Expert Advisor does not calculate step by step? Right?
 
eddy:
the script is not suitable for the task of closing an order at the right price as quickly as possible.
This is a controversial statement. For the speed all the claims are rather to the DC.
 
not controversial. the price can change while you call the script.
 
evillive:
And the councillor is not counting step by step, then? Are you sure?
What do you mean by "not stepwise"? It calculates step by step, but "discards" unnecessary data only at the end of the calculation chain, normalizing it according to the given Digits()! Therefore, it has much less loss in accuracy than a calculator!
 
eddy:
The price may change before the script is called.

If a few pips are critical, it's time to rethink the strategy and switch from pipsing to normal trading.

Pips are effective only when automated, and it is very desirable to have a ping to the server of less than 1 ms and execution on demand.

 
borilunad:
What do you mean "not stepwise"? It calculates stepwise, but "discards" unnecessary things only at the end of the calculation chain, normalizing it according to given Digits()! Therefore, it has much less loss in accuracy than the calculator!

Boris, I'm surprised at you. It's not the normalization by Digits, it's the MathFloor and exactly when the calculator does (the calculator allows the whole equation to be entered, although it solves it step by step).

Expert Advisor: lots=MathFloor(AccountFreeMargin()*rsk*0.01/margin/lotstep)*lotstep=MathFloor(1000*1*0.01/275.88/0.01)*0.01=0.03 - as you see, there is no "normalization"

Calculator: Trunc(1000*0.01/275.88/0.01)*0.01=0.03 - just like that

The question is closed, the Expert Advisor calculates correctly, I checked it and pasted a wrong value of margin and got a wrong result.