EasyLanguage programming questions...

Discussion in 'Technical Analysis' started by DGBrothers, Sep 23, 2002.

  1. Hi,

    I've got a quick question for anyone interested...

    I'm trying to determine several things in EasyLanguage (EL) code:

    1.) holidays and weekends (in advance, not after the fact, so I can exit all trades programmatically before the end of the trading day preceding a weekend or holiday). I've tried using the EL BusinessDays function, but that only shows weekends, not holidays.

    2.)options expiration days (again, in advance, not after the fact).

    3.) economic report days (again, in advance, not after the fact, so any open positions can either be covered with options (if the trend strength is intact), or exited (it the trend strength is waning)).

    4.) triple witching days

    Will I need to put all these dates into separate arrays (one for weekends/holidays, one for options expiration days, one for economic report days, one for triple witching days), and read each array from code, and act upon it programmatically?

    Or is there an easier way that I'm missing?

    Is there a way to put all these dates into an external file (say, a text .TXT file or Excel .XLS file), read it from the EL code, and act upon it programmatically?

    I'm designing this specifically for the S&P (both E-Mini and full-size contracts), so I'd only need to program options expiration days for that. I'm using TradeStation 2000i.

    Thanks in advance for any help anybody can provide.

  2. Bob111


    dude, you need a reminder or something.)))))) try to use yahoo calendar.))))) it will remind you next expiration day or weekend.TS-is a tool, on wich you may test you trading ideas or systems, BASED ON HISTORICAL PRICE. that why all functions shows you those days from past.
    i dont know, what for you need to know, when is next saturday, TS not going to sell for you @ friday close anyway. you can do all this stuff in VB for example. if you have IB acc. it is possible to create app, which will execute orders without you.
  3. Actually, this will be for back-testing purposes.

    Part of our new trading methodology requires us to avoid entering any trades in the first 30 minutes of a trading session after a date gap (after a weekend or holiday), avoid entering any trades in the last 15 minutes of any trading session, cover all existing positions with options on FOMC report days and double witching days, and not trade on triple witching days. It also requires that we hold no open positions over date gaps. This is easy enough for weekends, but not so for market holidays.

    In order to effectively backtest our methodology and have accurate results, I need to be able to programmatically determine when to either exit or stay out of trades, and when to cover existing open contracts with options.

    Perhaps I should have clarified my intended purpose at the start...

  4. If you are talking about TS2000i, then keep on reading.

    One thing is to goto Global Server and add the holidays on Holiday setting for the exchange. It's for back-testing purposes so it should be no problem. I think they stopped the Exchange update at 2000 or 2001. I just add them constantly before the holiday so I don't have the exact date they stopped updating.

    I think it's time they make a new GSUniverse update but as you may or may not know, they stopped their main support with TS2000i when TS6 came out. It's just shameful.
  5. Thank, WDGann, but that's still not what I'm looking for.

    I've already updated the GlobalServer holiday list up until 2005.

    What I'm looking for is a way to use EasyLanguage code to determine when those holidays will occurs, so I can exit out of any positions before they occur. Our new trading strategy requires that we hold no open positions over date gaps (weekends and holidays).

    This is for backtesting purposes...as you know, if you have code that specifies an entry, it'll keep you in that trade until the code tells the trade to exit, regardless of weekends, holidays, etc.

    So, I'm looking for a "weekends and holidays" exit, so I can exit on the day prior to that weekend or holiday. That way, when I'm backtesting, the results will be in accordance with the actual trading strategy.

    Weekends are easy, I've already got the code done for that, that took all of 5 minutes. Holidays are tougher. Look like I'll have to use an array. What I wanted to do was to use an external text file that was more easily updated, have the EasyLanguage code read that file, and react accordingly on the day prior to the dates in the text file to close out all open positions.
  6. Bob111


    -----------1.) holidays and weekends (in advance, not after the fact, so I can exit all trades programmatically before the end of the trading day preceding a weekend or holiday). I've tried using the EL BusinessDays function, but that only shows weekends, not holidays

    this is from your first post..........
    you did not mentioned what for you need this, like you did in second post. from this-i as i understand it---so I can exit all trades programmatically before the end of the trading day preceding a weekend or holiday). -----
    so, you get, what you ask))))))))

    Go to Omega help-type word "functions"->go to library
    you will get list of all functions, i did not remember exact names, but Omega do have functions for all your questions.
    hope it help.
    Thank you!
  7. marksimms


    Unless you are willing to take-on a MAJOR C++ DLL programming project, best to consider arrays for now.
    In fact, designed properly, a single array could serve your purpose for indicating any date for multiple situations (i.e. expiration day, triple witching, FOMC meeting day, etc).

    Input to Tradestation from an external file has always been a "bad idea" due to the requirement of an external DLL to perform the I/O....and the fact that "deadlock" could occur on the file during a realtime session.

    One thing that is possible, is to actually create a VB or Java program that would GENERATE the EL source code that could be inserted into the signal code via Power Editor. Potentially, the Power Editor may be DDE-enabled, so if you know how to program using DDE commands, you MIGHT be able to actually build the entire source code including the array values with a VB program.

    Keep in mind that TS2000i is basically a "dead" program....with little or no support from the vendor. This makes extending it or enhancing it a really, really time-consuming trial-and-error affair.
    If you've got the time, fine. If not, then you better be prepared to shell-out some major portion of your trading profits to people who are familiar with it's internals, especially the DLL interface.
  8. Thanks to everyone for their help on this one...

    What I ended up doing was creating two different functions, one for holidays, one for FOMC report days.

    In those functions, I created arrays. The one for holidays was easy (unless the following code is hosed, in that case it was extremely difficult), :D the code follows:
    Holidays Function:
    Variables: DateNextBarJul(0), DateNextBar(0);
    Arrays: Holiday[11](0);

    Holiday[1] = 11; {Jan01}
    Holiday[2] = 121; {Jan21}
    Holiday[3] = 218; {Feb18}
    Holiday[4] = 329; {Mar29}
    Holiday[5] = 527; {May27}
    Holiday[6] = 74; {July4}
    Holiday[7] = 92; {Sept2}
    Holiday[8] = 1128; {Nov28}
    Holiday[9] = 1129; {Nov29}
    Holiday[10] = 1224; {Dec24}
    Holiday[11] = 1225; {Dec25}


    For Value1 = 1 To 11 Begin
    If NumToStr(Holiday[Value1],0)=NumToStr(Month(DateNextBar),0)+NumToStr(DayOfMonth(DateNextBar),0) Then Holidays=True Else Holidays=False;
    I did it this way so that no year is included in the array, since the market holidays are the same each year. Basically, I took today's date, converted it to a Julian date, added one day to it, then converted it back to the EasyLanguage format date. Then I concatenated the strings which consist of the number corresponding to the Month, and the number corresponding to the DayOfMonth for tomorrow's date, and compared them to a string conversion of the array elements.

    If the two equate, then Holidays=True. In my Signal, I then put into the code that if @Holidays=True, I cover open positions with options.

    On those days which are market half-days due to holidays, I simply decided to forego trading. Those days are rarely worth it anyway.

    For the FOMC report days, I had to create an array that will simply have to be updated as time goes by, but that'll be not much of a problem. The code follows:
    FOMC_Report_Day Function:
    Arrays: Report_Day[160](0);

    Report_Day[1] = 960130;
    Report_Day[2] = 960131;
    Report_Day[3] = 960326;
    Report_Day[4] = 960521;
    Report_Day[5] = 960702;
    Report_Day[6] = 960703;
    Report_Day[7] = 960820;
    Report_Day[8] = 960924;
    Report_Day[9] = 961113;
    Report_Day[10] = 961217;
    Report_Day[11] = 970205;
    Report_Day[12] = 970325;
    Report_Day[13] = 970520;
    Report_Day[14] = 970702;
    Report_Day[15] = 970819;
    Report_Day[16] = 970930;
    Report_Day[17] = 971112;
    Report_Day[18] = 971216;
    Report_Day[19] = 980203;
    Report_Day[20] = 980204;
    Report_Day[21] = 980331;
    Report_Day[22] = 980519;
    Report_Day[23] = 980630;
    Report_Day[24] = 980701;
    Report_Day[25] = 980818;
    Report_Day[26] = 980929;
    Report_Day[27] = 981117;
    Report_Day[28] = 981222;
    Report_Day[29] = 990202;
    Report_Day[30] = 990203;
    Report_Day[31] = 990330;
    Report_Day[32] = 990518;
    Report_Day[33] = 990629;
    Report_Day[34] = 990630;
    Report_Day[35] = 990824;
    Report_Day[36] = 991005;
    Report_Day[37] = 991116;
    Report_Day[38] = 991221;
    Report_Day[39] = 1000201;
    Report_Day[40] = 1000202;
    Report_Day[41] = 1000321;
    Report_Day[42] = 1000516;
    Report_Day[43] = 1000627;
    Report_Day[44] = 1000628;
    Report_Day[45] = 1000822;
    Report_Day[46] = 1001003;
    Report_Day[47] = 1001115;
    Report_Day[48] = 1001219;
    Report_Day[49] = 1010130;
    Report_Day[50] = 1010131;
    Report_Day[51] = 1010320;
    Report_Day[52] = 1010515;
    Report_Day[53] = 1010626;
    Report_Day[54] = 1010627;
    Report_Day[55] = 1010821;
    Report_Day[56] = 1011002;
    Report_Day[57] = 1011106;
    Report_Day[58] = 1011211;
    Report_Day[59] = 1020129;
    Report_Day[60] = 1020130;
    Report_Day[61] = 1020319;
    Report_Day[62] = 1020507;
    Report_Day[63] = 1020625;
    Report_Day[64] = 1020626;
    Report_Day[65] = 1020813;
    Report_Day[66] = 1020924;
    Report_Day[67] = 1021106;
    Report_Day[68] = 1021210;
    Report_Day[69] = 1030128;
    Report_Day[70] = 1030129;
    Report_Day[71] = 1030318;
    Report_Day[72] = 1030506;
    Report_Day[73] = 1030624;
    Report_Day[74] = 1030625;
    Report_Day[75] = 1030812;
    Report_Day[76] = 1030916;
    Report_Day[77] = 1031028;
    Report_Day[78] = 1031209;

    For Value1 = 1 To 78 Begin
    If Report_Day[Value1] = Date Then FOMC_Report_Day = True Else FOMC_Report_Day = False;
    I pulled the past and future FOMC meeting and report dates from the FOMC website, and entered them into an array. Notice that when I declared the array, I made it much larger than I needed right now. This is basically so I don't have to mess with resizing the array as I add future FOMC dates. (It should be good for another 5 years or so, much longer than I'll need).
    The only thing I'll have to do is add the line:
    to the end of the array list, and change the:
    For Value1=1 To xx Begin
    line to the number of array elements.

    In my Signal code, I then specified that if FOMC_Report_Day=True, then the normal entry signals would not be taken, and instead buy and sell stops would be put above and below the market, just outside the volatility range. When we get stopped in on either the long or short side, we'll know it's actual market movement, and not noise. This would have worked extremely well today, an FOMC report day.

    For the double and triple witching days, I did the following:
    WorkDay = DayOfWeek((Year(Date) * 10000) + (100 * Month(Date)) + 1);

    If WorkDay = 0 Then
    FirstFriday = 6;
    If WorkDay = 1 Then
    FirstFriday = 5;
    If WorkDay = 2 Then
    FirstFriday = 4;
    If WorkDay = 3 Then
    FirstFriday = 3;
    If WorkDay = 4 Then
    FirstFriday = 2;
    If WorkDay = 5 Then
    FirstFriday = 1;
    If WorkDay = 6 Then
    FirstFriday = 7;

    ThirdFriday = FirstFriday + 14;

    If DateToJulian(Date)+1 = DateToJulian((Year(Date) * 10000) + (100 * Month(Date))+WorkDay+ThirdFriday) Then...

    and I tell it to cover any existing contracts with options on the day before the double or triple witching day.

    If anybody sees any glitches in the above code, please let me know...

  9. marksimms


    You forgot to mention exactly WHEN you call these functions.....
    are you working with Intraday bars or daily bars or tick intervals ?

    Unless your signals use daily bars, it would be a bit of overhead to call these on each new bar for intraday bars.
  10. I have all indicators/signals/etc. set to update on each tick.

    We've got fairly fast machines, so there's no performance penalty in constantly calling complex code (the entire trading strategy consists of 26 pages (approximately 4000 lines) of EasyLanguage code).

    #10     Sep 25, 2002