1) ordergap*Point are points but what is PipValue - probably they don't match.
2) ordergap*Point*PipValue are e.g. $ - and value is it $ as well?
otherwise you 'compare apple with oranges'.
We don't know the value for PipValue.
We don't know what logic you are using or what you expect to achieve.
We don't know what value you get and what value you are expecting.
You need to give more details.
Your code is the same as
double value=0; int ordegap=3; int newsgap=3 value=(ordergap+newsgap)*Point*PipValue;
simplified
I can't see any problem with casting as Point is a double
value=value+ordergap*Point*PipValue+newsgap*Point*PipValue;
This looks like a simple solution. The first thing you should do is, check whether the Math rules are set properly. Point calculation usually comes before adding and subtracting calculation. This is the first thing that I would look up. I would also put some parenthesis "(" and ")" around the Math, to make sure that your expected calculations are correct.
E.g.
What do you calc here:
value + ordergap * Point * PipValue + newsgap * Point * PipValue
What is being added and what multiplicated ?
value + ( ordergap * Point ) * PipValue + ( newsgap * Point ) * PipValue
might return a different value than:
value + ordergap * ( Point * PipValue ) + newsgap * ( Point * PipValue )
Make sure you read yourself about operator priorities. That should solve the problem.
value + ( ordergap * Point ) * PipValue + ( newsgap * Point ) * PipValue
might return a different value than:
value + ordergap * ( Point * PipValue ) + newsgap * ( Point * PipValue )
False. Multiplication has higher priority then addition A * B * C + D * E * F = (A * B) * C + (D * E) * F = A * (B * C) + D *( E * F) = (A * B * C) + (D * E * F)
False. Multiplication has higher priority then addition A * B * C + D * E * F = (A * B) * C + (D * E) * F = A * (B * C) + D *( E * F) = (A * B * C) + (D * E * F)
Wrong. "might return a different value than" is false. it make no difference in the order of multiplies. (1 * 2 ) * 3 = 2 * 3 = 6 = 1 * 6 = 1 * (2 * 3)
You are right with what you explain. But that's not what I wanted to express in my initial reply. Though I might have chosen a better example.
As I tried to explain in my second reply, it depends on how the initial poster has made his calculus. It could be that the initial poster wasn't aware of the calculation rules or oversight that when doing his own calculus on dry run (e.g. on a piece of paper) and then afterwards tried bringing this in a formula.
As example:
He might have calculated
30 + 3 = 33
Summed up these values and later on multiplied it with a different value.
33 * 3 = 99
Then he might have taken these values into a formula and wondered why the result differs to those he initially calculated on paper:
30 + 3 * 3 = 39
Now he is sitting at home and can't figure out why the value 39 is not the expected sum of 99 that he initially tried to calculate... To whatever reasons...
Therefore I came up with the reference to operand priorities and the hint by using parenthesis in his calculations to give the stuff some priorities).
That might look as in our example like this:
(30 + 3) * 3 = 99
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use