Bad Expeirence today! How to solve this issue by coding?

 
My EA placed order at the price of 135.00 on EURJPY. as per conditions EA must close 50% of lot when price reaches 20+pips profit, when EA tried close the order spread difference become 2.5 pips to 50+ pips. so EA closed the order with loss of -33pips(Ask Buy Difference in spread).

How to avoid such a market. broker says its due to news impact spread inclresed.

i like to filter with code when close the order ea must check/filter the spread or etc...

please advice me to add some filter for my EA to avoid such a expereince!


 

Your broker is just in the middle between you and some banks (being the 'market') and they stop providing prices for the news time.

Just try to avoid news times - there are tools that can do that. You just have to google.

 
gooly:

Your broker is just in the middle between you and some banks (being the 'market') and they stop providing prices for the news time.

Just try to avoid news times - there are tools that can do that. You just have to google.

Thanks for your reply gooly.

yes. i understood it. is this will happen such huge difference.

in fact partial order must be closed @ 134.77 , but order closed @ 135.33, its huge difference around 58 pips.

how to avoid this type orders closed. as you said news time we can avoid trades. but this trade opened  6 hrs before news time.

i need a solution by coding to avoid these probloms.

i have no such a issue with when other broker has fixed spread. currently i changed my account with ECN broker and variable spread.

i really appreciate your support/ideas!

 

So the trade opened 6 hrs before, irrelevant.

You wanted to close when the trade was 20 pips in profits. You didn't compare the OrderClosePrice() to the OrderOpenPrice() to see if it was.

 
sheriffonline:

Thanks for your reply gooly.

yes. i understood it. is this will happen such huge difference.

in fact partial order must be closed @ 134.77 , but order closed @ 135.33, its huge difference around 58 pips.

how to avoid this type orders closed. as you said news time we can avoid trades. but this trade opened  6 hrs before news time.

...
Add a news filter as Gooly said. If you knew there was a news around 14:00, don't try to trade (open or close) X minutes before and/or after.
 
WHRoeder:

So the trade opened 6 hrs before, irrelevant.

You wanted to close when the trade was 20 pips in profits. You didn't compare the OrderClosePrice() to the OrderOpenPrice() to see if it was.

There You are WHRoeder!. i agree with your clue.

yes. i must recheck the order while closing it.

Once again thank you all.

Reason: