dude, the profit in pips is not the difference between the OrderOpenPrice and OrderClosePrice (that's for closed orders; or the current price for opened ones)?
int start() { int D_Factor = 1; double Profit_Pips; //---- if(Digits == 3||Digits == 5)D_Factor = 10; for(int i=0;i<OrdersTotal();i++){ if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){ if(OrderType() == OP_BUY) Profit_Pips = (MarketInfo(OrderSymbol(), MODE_BID) - OrderOpenPrice())/Point/D_Factor; if(OrderType() == OP_SELL) Profit_Pips = (OrderOpenPrice() - MarketInfo(OrderSymbol(),MODE_ASK))/Point/D_Factor; Print("Order No : " + OrderTicket() + " Profit = " + DoubleToStr(Profit_Pips,1)); } else{ Print("Access to trades failed with error (",GetLastError(),")"); break; } } //---- return(0); }For an open order, use the difference between current price(Bid/Ask) and the OrderOpenPrice.
kennyhubbard:
For an open order, use the difference between current price(Bid/Ask) and the OrderOpenPrice.
For an open order, use the difference between current price(Bid/Ask) and the OrderOpenPrice.
Kenny, I am assuming this is a Script not an EA. (If it's an EA it will run for ever and fill the logs.)
I notice that you used Point rather than
MarketInfo( OrderSymbol(), MODE_POINT );
which is a bug.
If there are any orders which are not OP_BUY or OP_SELL then you either print an uninitialised variable or the previous value, both of which are unpleasant.
int incomePips = (int) ((OrderProfit() - OrderSwap() - OrderCommission()) / OrderLots());
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
how to get profit in pips?
OrderProfit() just for amount deposit, how do we get the profit in Pips?
i tried to use MathRound(OrderProfit()-OrderSwap())/(OrderLots()*MarketInfo(OrderSymbol(),MODE_TICKVALUE)), but not so accurate!!!!!
PLease help, thanks.