Jim Dean![]() Sage ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3433 Joined: 3/13/2006 Location: L'ville, GA ![]() | 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] ![]() ![]() ![]() ![]() |