charlotte nc
Experience: Advanced
Platform: My Own System
Broker: Optimus
Trading: Emini (ES, YM, NQ, ect.)
Posts: 408 since Jan 2015
Thanks Given: 90
Thanks Received: 1,148
|
This can be achieved by just creating a date time variable for each key event that you want to monitor then comparing the current day/ hour/ minute/ to the time signature of the event in your variable. For example:
if((ToTime(Time[0]) + ToTime(0,15,0) == VariableEvent)
{
// This is 15 minutes prior to the announcement time. Don't trade
}
if((ToTime(Time[0]) > VariableEvent +ToTime(0,15,0) )
{
// This is 15 after the announcement. Trade Again.
}
To get exact times to match, you just do something like: If Current Time + 15 minutes = VariableEvent then don't trade and then following announcements: If Current Time > 15 minutes + VariableEvent then trade again.
There are a number of date classes in C# you can use, but here is a simple way to implement this.
In your declarations sections add using System.Globalization;
Then create a short simple custom class with your variables like this:
class datetime
{
DateTime FedAnnouncment1 = new DateTime(2017,08,19,20,08,30);
DateTime FedAnnouncment2 = new DateTime(2018,04,15,15,03,43);
//etc.
}
Then you can call the FedAnnouncment variables from your code in any event handler you like and compare it to the current time (Like in the example above), check to see if you are within a 10-15 minutes window either before or after and simply just sit these windows out.
It's fairly easy to do.
Happy coding!
Ian
|