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.


  Current location        Thread information  
OmniTrader Professional Forum
OmniLanguage Discussion
Entry on specific day within a month-range
Last Activity 1/29/2018 8:23 AM
1 replies, 2043 viewings

Jump to page : 1
Now viewing page 1 [25 messages per page]
 
back reply
Printer friendly version

^ Top
Jim Dean

Sage
20001000100
Posts: 3111

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 - 476 downloads)
Attached file : aJDysCalendarEntry ExpFri graphic.png (43KB - 484 downloads)
Attached file : aJDysCalendarEntry code.png (30KB - 465 downloads)
Attached file : aJDysCalendarEntry.rtf (3KB - 349 downloads)

^ Top
Gary Rickle

Member
25
Posts: 40

Joined: 3/7/2006
Location: Cape Canaveral, Fl

User Profile
 
Subject : RE: Entry on specific day within a month-range
Posted : 6/26/2010 7:38 AM
Post #16521 - In reply to #16516

Jim,
I keep thinking that there is no way you can continue to "out do" yourself, but you have proved me wrong again.

Neat work, especially the Jan expiration. "Particularly cool" is just an understatement.

Looking at the time stamp on your post confirms to me that you must write some of these things while you sleep or maybe it would be more accurate to say you never sleep.

Thanks again for all your time, attention and help on so many different problems (opportunities)! As usual you have gone above and beyond what most would be able or would consider doing.

G
Jump to page : 1
Now viewing page 1 [25 messages per page]
back reply

Legend    Action      Notification  
Administrator
Forum Moderator
Registered User
Unregistered User
E-Mail this thread to a friend
Toggle e-mail notification


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