You select a position, then access the order.
The order that does the closing of a long position is a sell order.
The closing of a short position is a buy order.
As far as I know, you need to select the order as well, not only the position.
Since I do not use the standard lib, I don't know if positionInfo does that for you.
if(positioninfo.PositionType() == POSITION_TYPE_BUY)
the solution works, thanks guys
if(OrderGetInteger(ORDER_TYPE) == ORDER_TYPE_BUY){ difference = orderPriceClose - orderPriceOpen;Does your code actually compile? Where do you set your variables?
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
results:
as you can see, the sign of the operation result is wrong. pipsGained should be -9.
this happens only for
what's wrong?
Thanks