Yes it is more correct to have Swap and Commission included as well. But the order close price must not be Ask always(Ask for sell closes only), it is more appropriate to have it as OrderClosePrice().
Yes It is true (this is the way I use it too), I think it is better to include Symbol check also, as the EA might work on different currency pairs as well..
for ( int pos = 0 ; pos < OrdersTotal(); pos++)
{
if ( !OrderSelect (pos, SELECT_BY_POS,MODE_TRADES) ) continue;
if ( OrderMagicNumber() != magicNumber ) continue;
if ( OrderSymbol() != Symbol() ) continue;
if ( OrderProfit()+ OrderSwap()+ OrderCommission() > -25 ) continue;
if ( OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), slipage, 0 ) ) continue;
}
I don't understand why it is written in the way it is.
It's simple.
Hello,
A trade must be closed if its losses reache -25$
The probable codes are :
is it correct ?Thanks
Yes it is more correct to have Swap and Commission included as well.
But the order close price must not be Ask always(Ask for sell closes only), it is more appropriate to have it as OrderClosePrice().
Yes It is true (this is the way I use it too), I think it is better to include Symbol check also, as the EA might work on different currency pairs as well..
I don't understand why it is written in the way it is.
It's simple.
Because there are 2 ways to get out of the trade : one if takeprofit()<=-25$ ,the second if price target stoploss .
But anyway I have to change the code because the moving SL dont respect the minmum loss condition (-25$)
thanks for this remark
i thanks all for your ideas
I remarked my moving stoploss dont respect the maximum losses condition = -25$
So i must rewrite the pg to correct this by sizing the lot ,maybe it's more simple: