Calendar Effects In Long-Term Treasuries (Amibroker And Tradestation Code)

The original article can be found here.

The end of month effect in long-term Treasuries

The code in plain English:

  • Buy at the close of the seventh last trading day of the month.
  • Sell at the close of the last trading day of the month.

This is the Amibroker code:

Buy= Ref(Month(),7)!=Ref(Month(),6);

buyPrice=Close;

Sell= Month()!=Ref(Month(),1);

sellPrice=Close;

The start of the month effect in long-term Treasuries

The strategy in plain English:

  • Buy at the close of the last trading day of the month.
  • Sell at the close of the seventh trading day of the month.

This is the code in Amibroker:

Buy= Month()!=Ref(Month(),1);

buyPrice=Close;

Sell= Ref(Month(),-7)!=Ref(Month(),-6);

sellPrice=Close;

“Rest of the month effect” in long-term Treasuries

This is the strategy in plain English:

  • Buy at the close of the seventh trading day of the month.
  • Sell at the close of the last trading day of the month.

This is the Amibroker code:

Buy= Ref(Month(),-7)!=Ref(Month(),-6) ;

buyPrice=Close;

Sell= Month()!=Ref(Month(),1);

sellPrice=Close;

Tradestation code:

{
Calendar effects in long-term tresuries (Strategy 82A)
Buy at the close of the sixth last trading day of the month.
Sell at the close of the last trading day of the month.
}

if TdaysTillMonthEnd = 6 then Buy this bar on close;
if TdaysTillMonthEnd = 0 then Sell this bar on close;

----------------------------------------------------

{
Calendar effects in long-term tresuries (Strategy 82B)
Buy at the close of the last trading day of the month.
Sell at the close of the seventh trading day of the month.
}

if TdaysTillMonthEnd = 0 then Buy this bar on close;
if Month(Date[7]) <> Month(Date[6]) then Sell this bar on close;

------------------------------------------------------

{
Calendar effects in long-term tresuries (Strategy 82C)
Buy at the close of the seventh trading day of the month.
Sell at the close of the last trading day of the month.
}

if Month(Date[7]) <> Month(Date[6]) then Buy this bar on close;
if TdaysTillMonthEnd = 0 then Sell this bar on close;

Disclaimer: We are not financial advisors. Please do your own due diligence and investment research or consult a financial professional. All articles are our opinions – they are not suggestions to buy or sell any securities.