stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

News event monitor EA that closes/disables trading
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=5039
Page 2 of 11
Author:  deadman [ Sun Jan 08, 2017 11:02 pm ]
Post subject:  News event monitor EA that closes/disables trading

Just awesome. Thank you!
Author:  renexxxx [ Wed Jan 11, 2017 12:21 am ]
Post subject:  News event monitor EA that closes/disables trading

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.
Author:  mntiwana [ Wed Jan 11, 2017 6:12 am ]
Post subject:  News event monitor EA that closes/disables trading

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
Author:  deadman [ Wed Jan 11, 2017 12:10 pm ]
Post subject:  News event monitor EA that closes/disables trading

Thank you Rene for the great work!!! Really appreciated.
Author:  traveliron [ Fri Mar 03, 2017 3:55 pm ]
Post subject:  News event monitor EA that closes/disables trading

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
Author:  renexxxx [ Fri Mar 03, 2017 11:11 pm ]
Post subject:  News event monitor EA that closes/disables trading

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.
Author:  traveliron [ Sat Mar 04, 2017 11:53 am ]
Post subject:  News event monitor EA that closes/disables trading

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
Author:  renexxxx [ Sat Mar 04, 2017 8:59 pm ]
Post subject:  News event monitor EA that closes/disables trading

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.
Author:  traveliron [ Sun Mar 05, 2017 10:27 pm ]
Post subject:  News event monitor EA that closes/disables trading

Rene

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

Chris
Author:  SteveHopwood [ Sun Mar 19, 2017 1:03 pm ]
Post subject:  News event monitor EA that closes/disables trading

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:
All times are UTC Page 2 of 11