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 concept. This key concept 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 concept: most opening gaps on the S&P market close if the gaps are less than 4 points. This key concept is very simple, and testable. It is from such observation that I’ll often start to build a trading system from.

### The Key Concept

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 concept.

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 concept 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 concept 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 concept holds up across each session. Here are the basic sessions:

1. “Pre-Market” Between 05:30 and 08:30
2. “Open” Between 08:30 and 9:00
3. "Morning" Between 9:00 and 11:30
4. “Lunch” Between 11:30 and 13:15
5. “Afternoon” Between 13:15 and 14:30
6. “Close” Between 14:30 and 15:15
7. “Post-Market” Between 15:00 and 18:00
8. “Night” Between 18:00 and 05:30

From this list of basic sessions I created several more “sessions” based upon combinations of the above.

1. “Pre-Market” + “Open”
2. “Pre-Market” + “Open” + “Morning”
3. “Open” + “Morning”
4. “Open” + “Morning” + “Lunch”
5. “Lunch” + “Afternoon”
6. “Lunch” + “Afternoon” + “Close”
7. “Daily Session”
8. “Night” + “Pre-Market”
9. “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 ) ThenBegin// Trade Logic goes HereEnd;`

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.

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 concept 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 concept 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 concept.

Let’s now isolate the session input value to 12 and execute our key concept 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 concept 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 concept vs. different market sessions. My goal is to locate the best possible market sessions for my key concept. 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 concept. 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.

### About the Author Jeff Swanson

Jeff is the founder of EasyLanguage Mastery - a website and mission to empowering the EasyLanguage trader with the proper knowledge and tools to become a profitable trader. Join our EasyLanguage FaceBook group to interact with other EasyLanguage traders! Click the FaceBook icon to join.

• Stephen says:

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

• Derek says:

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.

• Jeff Swanson says:

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.

• rob says:

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

• Jeff Swanson says:

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.

• David Shaffer says:

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?

• Jeff Swanson says:

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.

• Kevin says:

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. 🙂 )

• Jeff Swanson says:

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!

• Kevin says:

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.