It depends if the close price is stored or calculated on the fly. My guess is it's stored and updated whenever any of the other values are changed on the trade (or it is being closed)
Put this EA on a chart, then open a Buy for the Symbol the EA is on then look at the Experts tab, if you are correct OCP won't be updated, if I am correct OCP should be the same a Bid as a Buy is closed at Bid price.
Put this EA on a chart, then open a Buy for the Symbol the EA is on then look at the Experts tab, if you are correct OCP won't be updated, if I am correct OCP should be the same a Bid as a Buy is closed at Bid price.
I stand corrected, it does indeed appear to be updating correctly. It was a few months back when I saw this issue and I wondered if it was in the tester where I had noticed it. However, I've just ran the the test EA in the tester and it is working as expected (it always shows an up to date close price using OrderClosePrice()).
double Direction(int op_xxx){ return( 1. - 2. * (op_xxx%2) ); }
double DeltaValuePerLot(string pair=""){
//{Value in account currency of a Point of Symbol.// In tester I had a sale: open=1.35883 close=1.35736 (0.0147)// gain$=97.32/6.62 lots/147 points=$0.10/point or $1.00/pip.// IBFX demo/mini EURUSD TICKVALUE=0.1 MAXLOT=50 LOTSIZE=10,000// IBFX demo/standard EURUSD TICKVALUE=1.0 MAXLOT=50 LOTSIZE=100,000// $1.00/point or $10.0/pip.//// https://www.mql5.com/en/forum/127584 CB: MODE_TICKSIZE will usually return the same// value as MODE_POINT (or Point for the current symbol), however, an example// of where to use MODE_TICKSIZE would be as part of a ratio with// MODE_TICKVALUE when performing money management calculations which need to// take account of the pair and the account currency. The reason I use this// ratio is that although TV and TS may constantly be returned as something// like 7.00 and 0.0001 respectively, I've seen this (intermittently) change// to 14.00 and 0.0002 respectively (just example tick values to illustrate).// https://www.mql5.com/en/forum/135345 zzuegg reports for non-currency DE30:// MarketInfo(chart.symbol,MODE_TICKSIZE) returns 0.5// MarketInfo(chart.symbol,MODE_DIGITS) return 1// Point = 0.1// Prices to open must be a multiple of ticksize//}if(pair == "") pair = Symbol();
return( MarketInfo(pair, MODE_TICKVALUE)
/ MarketInfo(pair, MODE_TICKSIZE) ); // Not Point.
}
int TypeModifier, Profit.Point ;
OrderSelect( . . . . .); // this will need to be done in any case
TypeModifier = ((OrderType() * 2) - 1) * -1; // gives 1 for a Buy, -1 for a Sell
Profit.Point = ( OrderClosePrice() - OrderOpenPrice() ) * TypeModifier; // gives +ve for a gain, -ve for a loss
It depends if the close price is stored or calculated on the fly. My guess is it's stored and updated whenever any of the other values are changed on the trade (or it is being closed)
Put this EA on a chart, then open a Buy for the Symbol the EA is on then look at the Experts tab, if you are correct OCP won't be updated, if I am correct OCP should be the same a Bid as a Buy is closed at Bid price.
No it is not. OrderCloseTime() is always zero.
It is Bid or Ask depending on order type. It is out of date exactly like Bid and Ask. Call RefreshRates(). Ref
Put this EA on a chart, then open a Buy for the Symbol the EA is on then look at the Experts tab, if you are correct OCP won't be updated, if I am correct OCP should be the same a Bid as a Buy is closed at Bid price.
I stand corrected, it does indeed appear to be updating correctly. It was a few months back when I saw this issue and I wondered if it was in the tester where I had noticed it. However, I've just ran the the test EA in the tester and it is working as expected (it always shows an up to date close price using OrderClosePrice()).
Regards, Paul.
double profitInAccountCurrency = OrderProfit() +OrderSwap() +OrderCommission();OrderClosePrice() works as intended and always gives the ClosePrice.
Thanks for all the comments and discussion, really helped me a lot!
Open trades' OrderClosePrice() is 0.
Unfortunately I 've not seen any good answer. Here is mine:
Don't forget to call
function before a call of
Unfortunately I 've not seen any good answer.
I guess you didn't read all of the thread . . .
So . . .