News event monitor EA that closes/disables trading

Rene's trading Expert Advisors
Post Reply
deadman
Posts: 8
Joined: Fri Feb 05, 2016 5:07 pm

News event monitor EA that closes/disables trading

Post by deadman »

Just awesome. Thank you!
User avatar
renexxxx
Trader
Posts: 860
Joined: Sat Dec 31, 2011 3:48 am

News event monitor EA that closes/disables trading

Post by renexxxx »

I received a PM from deadman with the following request:
deadman wrote: Would it be possible to add a filter functionality to the EA to filter for specific high impact news. The reason why I'm asking is because different high impact news have a different impact in the reality.
This is easy enough and I have added a few lines to the code in Post 1, so that it is now possible to specify a NewsFilter to target specific news items. Note that the string comparison is case sensitive so if you specify "fomc" and the news item text from FF is "FOMC Member Evans Speaks", it won't match.

I haven't tested the additional line of code, so let me know if it doesn't work.
mntiwana
Trader
Posts: 17
Joined: Fri Aug 16, 2013 11:57 am

News event monitor EA that closes/disables trading

Post by mntiwana »

renexxxx » Wed Jan 11, 2017 5:21 am wrote:I received a PM from deadman with the following request:

This is easy enough and I have added a few lines to the code in Post 1, so that it is now possible to specify a NewsFilter to target specific news items. Note that the string comparison is case sensitive so if you specify "fomc" and the news item text from FF is "FOMC Member Evans Speaks", it won't match.

I haven't tested the additional line of code, so let me know if it doesn't work.
Thanks for your addition.
regards
deadman
Posts: 8
Joined: Fri Feb 05, 2016 5:07 pm

News event monitor EA that closes/disables trading

Post by deadman »

Thank you Rene for the great work!!! Really appreciated.
User avatar
traveliron
Trader
Posts: 24
Joined: Wed Nov 16, 2011 1:01 pm

News event monitor EA that closes/disables trading

Post by traveliron »

Hi Rene

When this EA came out I thought it would be an ideal solution to many of the issues with the volatility and spreads around news events. Prior to this I had to make sure I was around to manually cancel the trades and that was not always possible. The later addition of news level filters made it seemingly perfect.

I'm currently experimenting with grid EAs on four separate platforms and I have deployed your CloseOnNews EA on each. I'm getting the same issue on all of them. I'm certain it is loaded correctly and I have all the /include files in the right place.

I want it to close all open trades/pendings for the period of the news event and then to re-enable the EA to begin trading afterwards. To effect this I have set:
CloseOpenTrades - True
ClosePendingTrades - True
DisableTradingOnNews - True
RenableTradingAfterNews - True

The problem is that a number of trades are open after Autotrading is disabled and, of course, then it cannot close them. I'm not certain if your EA has closed the trades and the trading EA has re-opened trades before the Autotrading is disabled or if it has failed to close all the pre-existing trades before it disables Autotrading. I think it is probably the former because the open trades appear to have been ordered within a minute or so after the CloseOnNews becomes active.

Looking at the Experts tab, OrderCloseReliable is looping, trying to close the trades but being unable to because "trade is not allowed in the expert properties".

As you might expect, if I set DisableTradingOnNews to - False the trading EA keeps opening trades and your EA immediately closes them.

I'm pretty sure the problem here is that the trading EA manages to open a trade or three in the time gap between CloseOnNews EA closing the trades and disabling Autotrading.

Actually, having sat down and thought of how to describe the problem I may have thought of a solution for my own situation. There is a TimeoutBetweenTrades on the trading EA. I'm not sure if that's between executing separate orders or after a closure. Anyway I'll widen that out a bit and report back if it makes a difference. It may be a while as it is now Friday and I'm actually short of news events.

I'd like to thank you Rene for the outstanding work you do on this forum. You really have created some absolute masterpieces.

Cheers - Chris
User avatar
renexxxx
Trader
Posts: 860
Joined: Sat Dec 31, 2011 3:48 am

News event monitor EA that closes/disables trading

Post by renexxxx »

traveliron » Sat Mar 04, 2017 1:55 am wrote: I'm pretty sure the problem here is that the trading EA manages to open a trade or three in the time gap between CloseOnNews EA closing the trades and disabling Autotrading.
I agree with this assessment. If your trading EA's main loop is in the OnTick() event handler, it will attempt to open a new trade for a symbol that was just closed, when a new tick arrives for that symbol. The only way for CloseOnNewsEA and your trading EA to "work together" is by establishing a communication channel between the two, either by
  • For CloseOnNewsEA setting a global variable (eg. StopTrading : true), that your trading EA is checking at the start of its OnTick() loop
  • or
  • For CloseOnNewsEA broadcasting a custom event (a STOP_TRADING event), whilst your trading EA is listening for these events and acting accordingly.
(Although I don't like global variables, the first option is probably better, as with the second option, if you restart your trading EA, it wouldn't have a clue in what "state" it is in ...)

In both options, code changes are required to your trading EA (and to CloseOnNews EA -- but that is under my control).

As you mentioned, CloseOnNewsEA can not disable AutoTrading before starting to close existing open and pending trades -- as then these trading operations are no longer allowed and will therefore fail.

Let me know if you want to take this further.
User avatar
traveliron
Trader
Posts: 24
Joined: Wed Nov 16, 2011 1:01 pm

News event monitor EA that closes/disables trading

Post by traveliron »

Brilliant Rene

I'll see if something can be done with the trading EA I'm using. I've sent you a PM.

This would be amazing to get resolved.

Many thanks - Chris
User avatar
renexxxx
Trader
Posts: 860
Joined: Sat Dec 31, 2011 3:48 am

News event monitor EA that closes/disables trading

Post by renexxxx »

traveliron » Sat Mar 04, 2017 9:53 pm wrote: This would be amazing to get resolved.
Hi Chris,

I have uploaded a new version (v1.2) of CloseOnNewsEA to Post 1 of this thread. This new version allows for the setting of a global variable, that can be checked by your trading EA. If this global variable is set, your trading EA should be coded to discontinue initiating new trades. This way, we can keep Auto Trading enabled during the whole process.

Cheers.
User avatar
traveliron
Trader
Posts: 24
Joined: Wed Nov 16, 2011 1:01 pm

News event monitor EA that closes/disables trading

Post by traveliron »

Rene

"Thank you" always seems insufficient for all you do. I'll report back.

Chris
User avatar
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

News event monitor EA that closes/disables trading

Post by SteveHopwood »

I finally got around today to something I have been going to do for ages - hack Rene's news code for my own EA's. What I found was......................





What I found was......................





What I found was......................





What I found was......................




What I found was......................




Wait for it......................



It's coming. Rene knows what is coming..........................




Drum roll to increase the tension..............................





I don't have to do a thing. :clap: :clap: :clap: :clap: :clap: :clap: :clap: :party: :party: :party: :party: :party: :!!: :!!: :!!: :!!: :!!: :!!:

Brilliant stuff Rene. Breathtaking, yet again. I am going to highlight this in my wrup tonight.

All my EA's over about the last three years or so include sets a 'do nothing for the time being' variable that is set when the ea reads a file that mptm and my closure scripts create when they are closing trades. Rene's bot here uses the same variable and gives it the same name, so I need add nothing at all to my existing body of work.

Fantastic. Totally fantastic. :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :party: :party: :party: :party: :party: :party: :party: :party: :party: :party: :party: :!!: :!!: :!!: :!!: :!!: :!!: :!!: :!!: :!!: :!!: :!!: :!!: :!!: :!!:

Thanks Rene. You are a megastar of the Forex world.

:xm:
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
Post Reply

Return to “Auto-trading EA's and EA monitors”