PureBytes Links
Trading Reference Links
|
> I would like it to exit all open positions on the close of the day
> prior to the FOMC day, and also not to enter any new positions on the
> day of the FOMC. Any help much appreciated.
Define a function like this, which lists all the FOMC meeting
dates in your period of interest:
{ function FOMCday }
inputs: TradeDate(numericsimple);
if Date = 1040128 or Date = 1040316 or Date = 1040504 or ...
then FOMCday = true
else FOMCday = false;
See http://www.federalreserve.gov/FOMC/#calendars for a list of
meeting dates.
Now you can reference FOMCday(Date) to determine if today is an
FOMC meeting date.
Not entering positions on FOMC dates is easy:
if FOMCday(Date) = false then begin
{ your entry logic }
end;
Closing positions the day before is trickier. It would be
simpler to close them on the morning of FOMC meetings, which is
generally quite safe:
if Date > Date[1] and FOMCday(Date) then begin
{ exit all positions }
end;
If you really must exit on the day before, you have to use an
Easy Language trick (which has impacts on your code) or you can
cheat.
The trick is to look at the next bar:
if FOMCday(Date of next bar) then begin
{ exit all positions }
end;
Problem is, looking at the next bar has lots of ramifications
that you might want to avoid, as has been explained here many
times. (Can't use multiple data streams, can't use certain order
types, LastBarOnChart is *never* true, etc.)
Instead you can cheat. It looks to me like FOMC days are ALWAYS
in the middle of the month. Furthermore they're generally on
Tuesdays or Wednesdays. That means it's safe to just add a day
to today's Date to get tomorrow's date, on all days when tomorrow
is an FOMC day. So you could say:
if FOMCday(Date + 1) then begin ...
You'd want to check that all FOMC days in your test period really
do conform to the "not on the 1st of the month and not on Monday"
rule if you want to do it this way.
Gary
|