If you have been reading EasyLanguage Mastery for a while you’re probably familiar with how I develop trading systems. The very first step is to come up with a simple idea to act as the seed or core of your trading system. I call this your Key Idea. This key idea is a simple observation of market behavior. This observation does not need to be complex at all. In fact, they are often very simple.
For example, here is a key idea: most opening gaps on the S&P market close if the gaps are less than 4 points. This key idea is very simple, and testable. It is from such observation that I’ll often start to build a trading system from.
In this article I want to show you a tool I use to help test key ideas on an intraday chart. Building trading systems on intraday charts (day-trading systems) are some of the more difficult systems to develop when compared to daily charts. First, you must deal with more market noise but even more dangerous are slippage and commissions. Why? Your potential profit per trade is small on a day trading system thus, both commissions and slippage take a bigger bite out of your profits (as a percentage of your P&L). This produce drag on the performance of your system much like a strong headwind slows your advance. In short, it’s more difficult!
The Key Idea
For this example let’s create a simple trend following strategy for the Euro currency futures (EC) market on a 5-minute chart. We’ll use the extreme readings on the RSI indicator as our signal. Because we are using RSI as a trend indicator that means we are looking to enter the market when RSI gives us an extreme reading. That is, go-long at the oversold region and go-short at the lower region.
- Buy when nine period RSI value above 80
- Sell Short when nine period RSI value below 20
This might be a little different than how most people would use RSI. Most of the time, it seems anyway, you would fade the extremes. However, when it comes to the markets unconventional can be beneficial. As for the extreme values, those are un-optimized numbers. I just picked them off the top of my head in hopes of looking for a strong swing in either direction. Also, I picked a value of nine for the RSI look-back period because I wanted it to be more sensitive than the default 14 that is often used. (The value of nine really has no significance. It was not optimized and I could have very well picked 7 or 10. I just simply picked it.)
Below is the EasyLanguage code for the key idea.
MyRSI = RSI( Close, RSILookBack );
If ( MyRSI < ShortZone ) Then
begin
GoShort = true;
GoLong = false;
End
Else If ( MyRSI > BuyZone ) Then
Begin
GoShort = false;
GoLong = true;
End;
If ( MP = 0 ) Then
Begin
If ( GoShort and BullTrend ) Then Sellshort ("RSI Short") next bar market
Else If ( GoLong and BearTrend ) Then Buy("RSI Buy") next bar at market;
End;
If you code this basic concept up and test it from 08:30 to 15:00 (central) on the EC market what do you think you’ll get? That’s right, a losing concept with an ugly equity curve.
Clearly, we don’t want to trade our system at any time during the U.S. day session. We want to focus when EC is most likely to show strong trending characteristics. If the price of EC is strong enough to push the RSI value above 80 we want the price to continue climbing. So, what market session is best suited for this RSI trend system? Or are all market sessions hopeless for this simple trading concept? Let’s find out.
The Session Test
When designing a day trading system one of the first steps I want to perform is to test which market session will likely produce the best results. We are all aware that different sessions exist for any given market. For example, when dealing with the S&P E-mini we have a pre-market session - the morning session, lunch time session, and an afternoon session. Sometimes you can see distinct characteristics within each session.
So, when I’m developing a trading system for day trading I don’t want to blindly trade during every session. I want to be more targeted in my approach. There will be most likely a particular session or two where my key idea will do better than the other sessions. In order to test our key idea vs. different sessions I need to create an EasyLanguage function that can isolate these sessions and execute the key idea individually over those sessions only.
This is where my “Session Testing” code comes into play. Session Testing is an EasyLanguage function that I wrote to help me in this task of testing various intraday sessions. Using TradeStation’s optimizer I can test my idea across different combinations of sessions and discover how the key idea holds up across each session. Here are the basic sessions:
- “Pre-Market” Between 05:30 and 08:30
- “Open” Between 08:30 and 9:00
- "Morning" Between 9:00 and 11:30
- “Lunch” Between 11:30 and 13:15
- “Afternoon” Between 13:15 and 14:30
- “Close” Between 14:30 and 15:15
- “Post-Market” Between 15:00 and 18:00
- “Night” Between 18:00 and 05:30
From this list of basic sessions I created several more “sessions” based upon combinations of the above.
- “Pre-Market” + “Open”
- “Pre-Market” + “Open” + “Morning”
- “Open” + “Morning”
- “Open” + “Morning” + “Lunch”
- “Lunch” + “Afternoon”
- “Lunch” + “Afternoon” + “Close”
- “Daily Session”
- “Night” + “Pre-Market”
- “Morning” + “Afternoon”
The 17 different sessions I came up with may not please everyone. Perhaps you have a contrasting idea on how to break up the different sessions and with the code provided you can simply change them to your liking. For example, if you are interested in the European markets and trade those times, you can create your own sessions based around the European markets.
Session Test Function
The session testing function is really simple. You place it within your strategy and pass into the function the session number you wish to test. Below is an example of testing session 1 – what I’m calling pre-market.
TradeFlag = SessionTest( 1 );
The variable TradeFlag will be set to a Boolean value based upon if the current time is pre-market (true) or not (false). Now we can use TradeFlag as a switch to enable/disable our trading as demonstrated below.
If ( TradeFlag ) Then
Begin
// Trade Logic goes Here
End;
What’s going on inside of the function? It’s rather simple as it’s nothing more than a bunch of if-then statements testing the current time. Below is a code, snip-it to give you an idea of what it looks like.
If ( SessionToTest = 1 ) And ( Time >= PREMARKET ) And ( Time < THE_OPEN ) Then TradeFlag = true
Else If ( SessionToTest = 2 ) And ( Time >= THE_OPEN ) And ( Time < MORNING ) Then TradeFlag = true
If ( SessionToTest = 3 ) And ( Time >= MORNING ) And ( Time < LUNCH ) Then TradeFlag = true
Else If ( SessionToTest = 4 ) And ( Time >= LUNCH ) And ( Time < AFTERNOON ) Then TradeFlag = true
Here is our code with the session test function applied.
If ( TradeFlag ) Then
Begin
MyRSI = RSI( Close, RSILookBack );
If ( MyRSI < ShortZone ) Then
begin
GoShort = true;
GoLong = false;
End
Else If ( MyRSI > BuyZone ) Then
Begin
GoShort = false;
GoLong = true;
End;
If ( MP = 0 ) Then
Begin
If ( GoShort and BullTrend ) Then Sellshort ("RSI Short") next bar market
Else If ( GoLong and BearTrend ) Then Buy("RSI Buy") next bar at market;
End;
End;
Testing All Sessions
Next let’s see what happens when I run TradeStation’s optimizer over each of the sessions. In doing so TradeStation will systematically execute my key idea strategy over each market session and record the trading results. This can be done by simply creating an input value to act as the session number to test. Then you simply optimize over the values 1-17.
After all the sessions have been analyzed I can generate a bar graph representing the P&L for each session. Below is the Net Profit graph which depicts the total net profit from our testing. By the way, we were testing this strategy from January 1, 2003 to December 31, 2011. This time-span covers both bull and bear markets. It’s important to test your key idea over a wide range of market conditions. Slippage and commissions are not factors into these results.
In this case we can see session input value number 12 produces the best net profit. This input value is actually a combination of Open, Morning, and Lunch sessions. It’s during these times EC market apparently demonstrates strong trending characteristics that we might be able to take advantage of with our key idea.
Let’s now isolate the session input value to 12 and execute our key idea on this specific time. For this test I will deduct $18.50 per round trip for slippage and commissions. Below is the equity graph of our key idea along with some performance numbers.
There is no optimization here. The code simply trades based off un-optimized RSI signals and the results look promising. Below is the Trade Summary Report.
Please note I have no stops or targets within my test strategy. Instead the strategy simply enters a trade if the proper condition is met and the trade is exited only at the close of the session. That’s it. Remember, I’m not testing a trading strategy. I’m testing a key idea vs. different market sessions. My goal is to locate the best possible market sessions for my key idea. In this case, which session holds the strongest trending characteristic? Once a session(s) has been identified only then will I continue to develop a complete strategy (containing stops, targets, and other rules) tailored to the top session(s).
Conclusion
There you have it. This type of RSI trend following concept should be developed for the Open, Morning, and Lunch sessions. This makes sense. The big volume and big trends often appear during the U.S. day session. This is also corroborated from a previous Best Times To Day Trade, where I explored the hourly range of the Euro Currency market. In that study we can see that the hours between 08:00 and 11:00 (Central) have the highest price movement of the EC market.
I would like to point out again, this is not a trading system. What we did in this article was to validate our key idea. The code presented in this article does not have stops, a regime filter, volatility filters, profit targets, or any number of other checks and balances we might see in a true trading system. In fact, take a look at the average profit per trade. It’s $15 after slippage and commissions which is too low in my opinion. I would like to see this closer to $50 per trade or higher.
Thanks Jeff,
An automated /6e intraday trend system makes good sense to me.
I hope you continue the thread… perhaps testing some Aurora methods as well?
Steve
Good stuff really enjoyed it. I have a question though. Once you run this and find the session/sessions where the system does best. Do you then go back to the baseline system to keep developing? Or just continue to use this session time for building. I know in your ebook you return to baseline after adding filters etc.
Thanks Derek. The concept presented is the “key concept”. I tested the key concept upon various sessions to see which was most effective. After applying the key concept to a best-fit session, that would be our baseline system. From this point onward I would continue to develop the system against the baseline, which is the key concept applied to our targeted session. I would not investigate other sessions. Let me know if this is not clear.
Jeff I am trying to run a simple Study on ES to test the buy time in the morning and then close at the end of the day to see if there is any sort of an edge. I modified your function and set the code up as a strategy. Cant seem to get this to work what so ever. The optimization engine goes through the time increments improperly and tests times like 990 which is not a real time. Any thoughts on this? I also don’t get any trades generated.
Inputs:
THE_OPEN (0930),
THE_CLOSE (1600);
// define ALL your variables for storage.
Var: jMinofDate(0),TimeVal(0),MinOfDate(0);
jMinOfDate = Intportion(MinOfDate) ;
TimeVal = fracportion(computerdatetime) ;
MinOfDate = TimeVal*1440 ;
// The open
If ( jMinofDate >= THE_OPEN ) And ( jMinofDate < THE_CLOSE ) Then
Buy next bar market;
If you would like to test different entry and exit times I would take advantage of TradeStation’s built-in support for Time. I’ll assume you are working with minute charts.
Inputs:
OpenTime(930),
CloseTime(1600);
if ( Time = OpenTime ) then buy next bar at market;
If ( Time = CloseTime ) then sell next bar at market;
I just typed this from memory and have not compiled it. However this should get close to what you want. In the example code, you can test various entry and exit times.
Thanks for sharing this process. I really enjoy your blog!
In your EasyLanguage code you refer to BearTrend and BullTrend. I assume that these are booleans set elsewhere in the code…? Or maybe built-in EasyLanguage functions? How are they calculated?
Sorry about the confusion. It appears the download code does not have those Boolean values. I was most likely testing these Boolean values and they made it into the article but not into the download code. Those are just booleans. I’ll often use those as a longer-term filter. Often Bulltrend is true when price is above its 200-day moving average.
Hi Jeff
Thanks for the article, well done as usual. Couple of questions. How about a list of detailed settings for non-Tradestion users? Hard to replicate your results if we don’t have this. Also, how is this article different from your previous series on EC intraday trading? (I Admit to being lazy. 🙂 )
Thanks Kevin. Let me know what setting you need and I can post them. If you’re not using TradeStation you probably will never matching them 100%. Just get close enough. Can you point me to the other EC intraday trading article? Not sure which one you’re talking about. Thanks!
Don’t worry about the settings, I’ll figure it out. MC users are at a bit of a disadvantage, tho, since we can’t use the Tradestation workspace, which has all the detailed settings. It’s not impossible, just takes a while, but it’s a small price to pay for the ideas and strategies you provide. The other article would be the “Testing A Euro Currency Futures Scalping Strategy”, parts 1-6, a nice review of a lot of different ideas for trading the EC intraday.
Hi There,
Why not going “short” on sessions 8 and 17 ?
The results are “bad” in a good way 🙂
Hi Elad. Yes, very good. That’s worth testing. Let us know if you find anything interesting.