hint: my subscribers can post here . .
. .
assume you want to calculate profit in pips for closed positions . . some of them are BUY and others are SELL . .
Instead of using two functions (one for BUY and other for SELL) what is the best/smart alternative?
I am eagerly waiting your answer/solution which would be better than my suggestion . .
look at it!! is it very smart? only one line that is valid for both BUY or SELL type . .
let us check: assume order type: BUY = 0
pips = (OrderType()-(OrderType()^1)) * (OrderOpenPrice()-OrderClosePrice())
You have to study this "^" symbol . . to understand what we are talking about . . in MQL4 it is not "THE POWER OF"
or just simply check the result which will be -1 for BUY and +1 for SELL
^ is the bitwise exclusive operation XOR of binary representations of x and y. The value of the expression contains a 1 in all digits where x and y have different binary values, and it contains 0 in all other digits.
Therefore:
it makes 0 (which is BUY) 1
and
makes 1 (which is SELL) 0
. .
assume you want to calculate profit in pips for closed positions . . some of them are BUY and others are SELL . .
Instead of using two functions (one for BUY and other for SELL) what is the best/smart alternative?
I am eagerly waiting your answer/solution which would be better than my suggestion . .
Inserted Code
pips = ( OrderType() - ( OrderType() ^ 1 ) ) * ( OrderOpenPrice() - OrderClosePrice() )
look at it!! is it very smart? only one line that is valid for both BUY or SELL type . .
let us check: assume order type: BUY = 0
pips = (OrderType()-(OrderType()^1)) * (OrderOpenPrice()-OrderClosePrice())
You have to study this "^" symbol . . to understand what we are talking about . . in MQL4 it is not "THE POWER OF"
or just simply check the result which will be -1 for BUY and +1 for SELL
^ is the bitwise exclusive operation XOR of binary representations of x and y. The value of the expression contains a 1 in all digits where x and y have different binary values, and it contains 0 in all other digits.
Therefore:
it makes 0 (which is BUY) 1
and
makes 1 (which is SELL) 0
Be yourself