OmniTrader Professional Forum OmniTrader Professional Forum
forums calendars search
today this week
 
register logon control panel Forum Rules
You are currently browsing as a guest.
You should logon to access more features
A Self-Moderated Community - ALL MEMBERS, PLEASE READ!
Vote for Members who contribute the most to your trading, and help us moderate content within the Forums.


This message cannot be deleted. It is the first message of the thread.
Administrators or moderators may choose to delete the entire thread


 
Jim Dean

Sage
2000100010010010010025
Posts: 3433

Joined: 3/13/2006
Location: L'ville, GA

User Profile
 
Subject : Entry on specific day within a month-range
Posted : 6/26/2010 12:33 AM
Post #16516

Duxx presented an interesting problem for solution: he wanted to fire an Entry signal on a particular day of the month, for a certain range of months of the year. Sounds relatively simple, if you have the necessary functions to determine things like the Month and Day of a given Bar.

However, there are a few tricks involved ... first, you have to deal with month-ranges that "cross over" to the next year ... for instance, starting in October and ending in January.

Also, you need to deal with the fact that only approx 21 days of the avg 30-day month are "trading days" ... and inevitably whatever calendar-day-of-month you pick as your focus, there will be some months where that date lands on a Sat or Sun. In this case, Duxx wanted the trade to be taken on the following Monday.

The code below solves this problem ... and provides for another very interesting feature. If the EntryDoM date input is ZERO, then the routine automatically identifies the THIRD TRADING-DAY FRIDAY of a given month ... ie, Options-Expiration Friday.

Personally, I believe that month-cyclic behavior tends to reference itself to Expiration Fridays, more than the first of the month. This code provides a framework for applying that logic in a variety of ways.

I've chosen a timeperiod on the chart-example to illustrate how it picks the precise date on months when it can, and how it jumps to the next Monday when necessary. Also, how it bridges over the end of the year.




The second set of charts illustrate how it finds the Expiration Friday. The January case is particularly cool ... it picked the FOURTH Friday of the month, since the FIRST Friday was a holiday (New Years Day).




The RTF file contains the actual code.



[Edited by Jim Dean on 3/28/2015 7:25 AM]

Attached file : aJDysCalendarEntry graphic.png (81KB - 1104 downloads)
Attached file : aJDysCalendarEntry ExpFri graphic.png (43KB - 1141 downloads)
Attached file : aJDysCalendarEntry code.png (30KB - 1076 downloads)
Attached file : aJDysCalendarEntry.rtf (3KB - 876 downloads)

Deleting message 16516 : Entry on specific day within a month-range


Nirvana Systems
For any problems or issues please contact our Webmaster at webmaster@nirvsys.com.