Closed with a loss even I coded profit > 0.0

 

I have a trade that closed with a loss even I coded to have profit to be > 0.0

The time that happen is just a few seconds after US release their Non-Farm Employment Change

I suspect it was caused by the big spread. So what can I do to further prevent this? Doesn't order profit > 0.0 work? 

 
doshur:

I have a trade that closed with a loss even I coded to have profit to be > 0.0

The time that happen is just a few seconds after US release their Non-Farm Employment Change

I suspect it was caused by the big spread. So what can I do to further prevent this? Doesn't order profit > 0.0 work? 

What about?
realProfit=PositionGetDouble(POSITION_PROFIT)-PositionGetDouble(POSITION_SWAP);
 
figurelli:
What about?

Why swap? I thought current profit is without swaps?

Any idea what could be the reason that my trade closes?

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Position Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Position Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Position Properties - Documentation on MQL5
 
doshur:

Why swap? I thought current profit is without swaps?

Any idea what could be the reason that my trade closes?

Can you publish the code you use to define a trade current profit?
 

figurelli:
Can you publish the code you use to define a trade current profit? 

PositionGetDouble(POSITION_PROFIT) > 0.0
 

I have another condition that is together with this profit > 0.0

if(MA[0] < MA[1] && MA[1] > MA[2] && PositionGetDouble(POSITION_PROFIT) > 0.0)
then close trade

 so as you can see I use MA turning down and if profit is > 0.0 then close trade

however it closes with a loss. I can only think of it is due to the rapid price movement and the huge spread caused by the Non Farm news release

 
doshur:

I have a trade that closed with a loss even I coded to have profit to be > 0.0

The time that happen is just a few seconds after US release their Non-Farm Employment Change

I suspect it was caused by the big spread. So what can I do to further prevent this? Doesn't order profit > 0.0 work? 

The equation is suppose to be OrderProfit + OrderCommission + OrderSwap;

If Slippage is Guaranteed on your orders then use 0{zero} for Slippage.

If Slippage is not Guaranteed, then use Pending Orders.

 
Ubzen:

The equation is suppose to be OrderProfit + OrderCommission + OrderSwap;

If Slippage is Guaranteed on your orders then use 0{zero} for Slippage.

If Slippage is not Guaranteed, then use Pending Orders.

Hi,

There is no OrderComission, I want the current profit without swaps.

For Ctrade class, the deviation is == slippage?

SetDeviationInPoints

 

Additional info my loss is 10.7 pips...


 
doshur: For Ctrade class, the deviation is == slippage?

Yeah I believe so. However, not all brokers (example ECN) allow slippage/deviation. In case of ECN, you get the Best Price after you submit the order. Which Execution_Type allows slippage and which doesn't is something you'll need to check for before submitting the order. I cannot remember which you need .. nor have I tested them extensively.

Possible deal execution modes for a certain symbol are defined in enumeration ENUM_SYMBOL_TRADE_EXECUTION.

ENUM_SYMBOL_TRADE_EXECUTION

Identifier
 Description
 
SYMBOL_TRADE_EXECUTION_REQUEST
 Execution by request
 
SYMBOL_TRADE_EXECUTION_INSTANT
 Instant execution
 
SYMBOL_TRADE_EXECUTION_MARKET
 Market execution
 
SYMBOL_TRADE_EXECUTION_EXCHANGE
 Exchange execution
 
 
doshur:

I have another condition that is together with this profit > 0.0

 so as you can see I use MA turning down and if profit is > 0.0 then close trade

however it closes with a loss. I can only think of it is due to the rapid price movement and the huge spread caused by the Non Farm news release

If your MA periods are high values or long postitions a Swap could do this, but if you are sure that Swap is zero it is another reason.

I agree, rapid price movement with low MA periods can be also the reason if you have a fast slippage.

Have you checked terminal history open/close/swap prices of the trade to double check the rapid price movement?



 

 
figurelli:

If your MA periods are high values or long postitions a Swap could do this, but if you are sure that Swap is zero it is another reason.

I agree, rapid price movement with low MA periods can be also the reason if you have a fast slippage.

Have you checked terminal history open/close/swap prices of the trade to double check the rapid price movement?



 

It happened yesterday at US timing 9.30 when it release Non Farm. I can be 99% sure there is rapid price movements.
Reason: