News event monitor EA that closes/disables trading
-
trader689
- Trader
- Posts: 674
- Joined: Thu Nov 17, 2011 12:53 am
News event monitor EA that closes/disables trading
Brilliant news, thanks Rene and Steve!

-
Radar
- Trader
- Posts: 437
- Joined: Fri Mar 23, 2012 5:39 pm
- Location: Round the bend ;)
Broker GMT Offset
Hey Rene,
I currently have an account with a broker that changes its GMT offset in order to stay aligned with NY close when it flips into and out of Daylight Savings Time...
I use the following code in my EA's and modded indicators that need to stay aligned with either GMT or Broker time...
It's crude coding, but it does the job
Just thought you might like something like this in any of your projects that need to stay in sync with GMT or Broker Time 
Take care,
&
Have fun!
Radar =8^)
I currently have an account with a broker that changes its GMT offset in order to stay aligned with NY close when it flips into and out of Daylight Savings Time...
I use the following code in my EA's and modded indicators that need to stay aligned with either GMT or Broker time...
Code: Select all
// Show Times
string LocalTime, LocalTimeGMT_Offset, GMT, BrokerTime, BrokerOffset;
long h, m, s;
if(Show_Local_Time)
{
LocalTime = TimeToStr(TimeLocal(), TIME_DATE|TIME_SECONDS);
DrawStuff("Local_Time", "Local Time : " + LocalTime, MainFontSize, MainFont, 60, 1, LocalColour);
}
if(Show_Local_GMT_Offset)
{
// Get Local GMT Offset (in seconds)
long LocalTimeGMT_OffsetSeconds = MathAbs(TimeGMTOffset());
// Convert to hours & minutes
s=LocalTimeGMT_OffsetSeconds%60;
m=((LocalTimeGMT_OffsetSeconds-s)/60)%60;
h=((LocalTimeGMT_OffsetSeconds-s-m*60)/3600)%24;
if (h!=0)
{
LocalTimeGMT_Offset = (string(h) + " h " + string(m) + " m ");
}
else
{
LocalTimeGMT_Offset = (string(m)+" m ");
}
if (TimeGMTOffset() < 0) // If you're GMT+, returns negative seconds, GMT- returns positive seconds.
{
LocalTimeGMT_Offset = ("+" + LocalTimeGMT_Offset);
}
else
{
LocalTimeGMT_Offset = ("-" + LocalTimeGMT_Offset);
}
DrawStuff("Local_GMT_Offset", "Local GMT Offset is " + LocalTimeGMT_Offset, MainFontSize, MainFont, 60, 3, LocalColour);
} // End if(Show_Local_GMT_Offset)
if(Show_GMT)
{
GMT = TimeToStr(TimeGMT(), TIME_DATE|TIME_SECONDS);
DrawStuff("GMT_Time", "GMT : " + GMT, MainFontSize, MainFont, 80, 1, GMTColour);
}
if (Show_Broker_Time)
{
BrokerTime = TimeToStr(TimeCurrent(), TIME_DATE|TIME_SECONDS); // Broker Time
DrawStuff("Broker_Time", "Broker Time : " + BrokerTime, MainFontSize, MainFont, 100, 1, BrokerColour);
}
if(Show_Broker_GMT_Offset)
{
// I don't know if there are brokers that are GMT-, but, just in case...
if (TimeGMT() > TimeCurrent())
{
long Broker_GMT_Offset = TimeGMT() - TimeCurrent();
s=Broker_GMT_Offset%60;
m=((Broker_GMT_Offset-s)/60)%60;
h=((Broker_GMT_Offset-s-m*60)/3600)%24;
if (h!=0)
{
BrokerOffset = ("-" + string(h) + " h " + string(m) + " m ");
} // End if (h!=0)
else
{
BrokerOffset = ("-" + string(m)+" m ");
} // End else
} // End if (TimeGMT() > TimeCurrent()) (GMT-)
else // GMT+
{
long Broker_GMT_Offset = TimeCurrent() - TimeGMT();
s=Broker_GMT_Offset%60;
m=((Broker_GMT_Offset-s)/60)%60;
h=((Broker_GMT_Offset-s-m*60)/3600)%24;
if (h!=0)
{
BrokerOffset = ("+" + string(h) + " h " + string(m) + " m ");
} // End if (h!=0)
else
{
BrokerOffset = ("+" + string(m)+" m ");
} // End else
} // End else // GMT+
DrawStuff("Broker_GMT_Offset", "Broker GMT Offset is " + BrokerOffset, MainFontSize, MainFont, 100, 3, BrokerColour);
} // End if(Show_Broker_GMT_Offset)
// End Show Times
Take care,
&
Have fun!
Radar =8^)
Check out my new, (well, old now), manual trade & automatic scale-in manager,
StackManV2
StackManV2
- renexxxx
- Trader
- Posts: 860
- Joined: Sat Dec 31, 2011 3:48 am
News event monitor EA that closes/disables trading
Hi Radar,
Apologies for the late reply, but I've been away.
My code requires the Broker's Time GMT Offset, not the Local Time GMT Offset (as the FF News items are expressed in GMT=0, and the EA needs to compare the TimeCurrent() with the news item's time, to work out if there is upcoming or lingering news).
It is easy to find the GMT Offset of the Local Time (since Build 6xx there is even a function for -- TimeGMTOffset() ). However, we need the GMT Offset of the Broker's Time. By using code similar to yours, you can calculate the difference between the Local Time and the Broker Time, and then try to work out the Broker's Time GMT Offset. However, there are several problems with this:
Hope this clarifies my position.
Apologies for the late reply, but I've been away.
My code requires the Broker's Time GMT Offset, not the Local Time GMT Offset (as the FF News items are expressed in GMT=0, and the EA needs to compare the TimeCurrent() with the news item's time, to work out if there is upcoming or lingering news).
It is easy to find the GMT Offset of the Local Time (since Build 6xx there is even a function for -- TimeGMTOffset() ). However, we need the GMT Offset of the Broker's Time. By using code similar to yours, you can calculate the difference between the Local Time and the Broker Time, and then try to work out the Broker's Time GMT Offset. However, there are several problems with this:
- This does not work when the Broker's Time is stopped (like in the weekends and on public/bank holidays)
- Your code does not work when the Local Time's GMT Offset is not a whole number of hours (eg. Australian Central Timezone = UTC + 9:30)
- This is also susceptible to problems, if/when the user manipulates the local PC clock.
Hope this clarifies my position.
-
Radar
- Trader
- Posts: 437
- Joined: Fri Mar 23, 2012 5:39 pm
- Location: Round the bend ;)
News event monitor EA that closes/disables trading
Hey Rene',
I've been using similar code for years, and when MQ introduced TimeGMT(), I converted to that, and it does work with partial hours (Eucla, Chatham Islands, and Kathmandu are 45 minutes off the hour, and, as you've noted, I live 9.5 hours ahead of GMT, and the indicators and EA's that I've modded with the above code all show correct GMT and Broker's Offset). I do have to ensure that my computer time doesn't drift, though, so I grabbed an NTP client for windows from here.
Still, I see your point about users having to use a bit of grey matter now and then
After all, it's their money that they're putting on the line.
Take care,
&
Have fun!
Radar =8^)
I've been using similar code for years, and when MQ introduced TimeGMT(), I converted to that, and it does work with partial hours (Eucla, Chatham Islands, and Kathmandu are 45 minutes off the hour, and, as you've noted, I live 9.5 hours ahead of GMT, and the indicators and EA's that I've modded with the above code all show correct GMT and Broker's Offset). I do have to ensure that my computer time doesn't drift, though, so I grabbed an NTP client for windows from here.
Still, I see your point about users having to use a bit of grey matter now and then
Take care,
&
Have fun!
Radar =8^)
Check out my new, (well, old now), manual trade & automatic scale-in manager,
StackManV2
StackManV2
-
jhs
- Trader
- Posts: 17
- Joined: Wed Feb 05, 2014 4:49 pm
News event monitor EA that closes/disables trading
HI Rene and All,
first I would like to thank everyone for the wonderful work you are doing and sharing. Congrats!
Should I ask you a favor, please? I do not know whether it is lawful or not, forgive me in advance if it is inapppropriate.
I'm testing News Event Monitor EA with great pleasure, it is a fantastic and very important tools for my research.
Could you please consider if possible to implement these additions in the next release please, of course if you think they are worth it?
State that I am not a programmer, so I apologize if what I dare to propose is particularly hard to implement or too costly and challenging.
The tools that I think might also interest or benefit other traders are:
- when the EA disable trading for upcoming news release, the ability to print on the chart vertical lines in according with the parameters specified in the EA: for example if the news is at 10:00 and I set the program to suspend activities 30 mins before and after, 2 vertical lines, one at 09:30 the other at 10:30.
-provide for the ability to activate all the other EAs and then trading on Sundays at specified hour:mins and then, if requested, to suspend all activities on Friday evening, always at hour:mins, with the option to close all trades before it, in order to leave no positions open for the weekend.
Thanks in advance for the attention that you want to devote to this my post.
I hope everything is clear, I'm using a translation program, so if there is something in doubt, please let me know, I will try to reformulate the topic
Thank you again
Regards
first I would like to thank everyone for the wonderful work you are doing and sharing. Congrats!
Should I ask you a favor, please? I do not know whether it is lawful or not, forgive me in advance if it is inapppropriate.
I'm testing News Event Monitor EA with great pleasure, it is a fantastic and very important tools for my research.
Could you please consider if possible to implement these additions in the next release please, of course if you think they are worth it?
State that I am not a programmer, so I apologize if what I dare to propose is particularly hard to implement or too costly and challenging.
The tools that I think might also interest or benefit other traders are:
- when the EA disable trading for upcoming news release, the ability to print on the chart vertical lines in according with the parameters specified in the EA: for example if the news is at 10:00 and I set the program to suspend activities 30 mins before and after, 2 vertical lines, one at 09:30 the other at 10:30.
-provide for the ability to activate all the other EAs and then trading on Sundays at specified hour:mins and then, if requested, to suspend all activities on Friday evening, always at hour:mins, with the option to close all trades before it, in order to leave no positions open for the weekend.
Thanks in advance for the attention that you want to devote to this my post.
I hope everything is clear, I'm using a translation program, so if there is something in doubt, please let me know, I will try to reformulate the topic
Thank you again
Regards
- renexxxx
- Trader
- Posts: 860
- Joined: Sat Dec 31, 2011 3:48 am
News event monitor EA that closes/disables trading
You may want to have a look at this post and particularly at the FFCalLines indicator.jhs » Mon Apr 03, 2017 11:39 pm wrote: - when the EA disable trading for upcoming news release, the ability to print on the chart vertical lines in according with the parameters specified in the EA: for example if the news is at 10:00 and I set the program to suspend activities 30 mins before and after, 2 vertical lines, one at 09:30 the other at 10:30.
Although possible, I'm not sure if this falls under the duties of the "News Event monitor EA". If anything, we would need to rename this topic to "EA that closes/disables trading", as the extra functionality has nothing to do with the news. The obvious extension of this would be the option to set any manual sequence of OFF and ON timing events. This is outside of the current scope.jhs » Mon Apr 03, 2017 11:39 pm wrote: -provide for the ability to activate all the other EAs and then trading on Sundays at specified hour:mins and then, if requested, to suspend all activities on Friday evening, always at hour:mins, with the option to close all trades before it, in order to leave no positions open for the weekend.
-
jhs
- Trader
- Posts: 17
- Joined: Wed Feb 05, 2014 4:49 pm
News event monitor EA that closes/disables trading
Hi Rene,
thanks a lot for your kind anwer and support.
About point 1 I did not know this variation of FFCal, I'll work on it, TY.
And regarding the EA modification I agree with you, it is outside the main scope of the program.
I've already made a brief test with SimpleAllPairsBasketManager, it has this function already coded in it.
I was on standby for the moment as a result of the amount of functions it has in it, I would not introduce elements that can complicate the control of the backtest.
Anyway thank you for all, I will focus my attention on this and similar instruments published here.
Have a Good Day
Regards
thanks a lot for your kind anwer and support.
About point 1 I did not know this variation of FFCal, I'll work on it, TY.
And regarding the EA modification I agree with you, it is outside the main scope of the program.
I've already made a brief test with SimpleAllPairsBasketManager, it has this function already coded in it.
I was on standby for the moment as a result of the amount of functions it has in it, I would not introduce elements that can complicate the control of the backtest.
Anyway thank you for all, I will focus my attention on this and similar instruments published here.
Have a Good Day
Regards
-
jhs
- Trader
- Posts: 17
- Joined: Wed Feb 05, 2014 4:49 pm
News event monitor EA that closes/disables trading
Hi Rene,
sorry I'm here again...
About the 2nd point, I was just thinking that, however, a function that disables all the EA's before the close on Friday evening and reopen on Sunday / Monday morning at a specified time, it would still be a function related to the news management, let me explain better, in the case of sudden macroeconomic events , and most important, unexpected (and so not mentioned in advance in FFCal), this could prevent major losses due to the opening gaps. What is your opinion about it please?
Thanks again a lot for your attention.
Regards
sorry I'm here again...
About the 2nd point, I was just thinking that, however, a function that disables all the EA's before the close on Friday evening and reopen on Sunday / Monday morning at a specified time, it would still be a function related to the news management, let me explain better, in the case of sudden macroeconomic events , and most important, unexpected (and so not mentioned in advance in FFCal), this could prevent major losses due to the opening gaps. What is your opinion about it please?
Thanks again a lot for your attention.
Regards
- renexxxx
- Trader
- Posts: 860
- Joined: Sat Dec 31, 2011 3:48 am
News event monitor EA that closes/disables trading
My opinion, really, is to use your own discretion for (manually) closing trades at the end of the week and restarting your EAs at the beginning of the new week. Imagine for instance, that you have a big draw down at the end the week: do you still want to have all your trades automatically closed by a machine? I think not.jhs » Thu Apr 06, 2017 11:28 pm wrote:What is your opinion about it please?
- 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
You are asking Rene to code for too many weaknesses in the EA's you are running. Any sensibly-coded EA has time-control functionality built in. He is not going to try to accommodate every whimsy you come up with.jhs » Thu Apr 06, 2017 1:28 pm wrote:Hi Rene,
sorry I'm here again...
About the 2nd point, I was just thinking that, however, a function that disables all the EA's before the close on Friday evening and reopen on Sunday / Monday morning at a specified time, it would still be a function related to the news management, let me explain better, in the case of sudden macroeconomic events , and most important, unexpected (and so not mentioned in advance in FFCal), this could prevent major losses due to the opening gaps. What is your opinion about it please?
Thanks again a lot for your attention.
Regards
Your EA does not shut down at times under your control when the markets are about to close, and do not allow you to control their trading start time when the markets reopen? Junk the EA and instead start using some of the fantastic stuff on offer here. We would not even bother to have bad dreams about presenting an EA without these features.
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.
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.