Accessing Two Timeframes in EasyLanguage

How To Take Advantage of Multiple Timeframes Easily! I wrote this guide to help you better utilize your programming skill by creating more powerful trading systems. This technique I'm going to show you is one that can radically improve your trading.

The Problem

I wrote this guide to help you better utilize your programming skill by creating more powerful trading systems. This technique I'm going to show you is one that can radically improve your trading. While I can’t say it will improve every trading system you work on, learning this technique is a great tool for you to know. I’ve personally seen the benefit of utilizing multiple timeframes to enhance the performance of many trading systems.

In this guide, I’m going to show you how to use two timeframes within a single chart. I will use a higher timeframe chart (daily) to filter trades on a 15-minute chart. By utilizing these two timeframes I will turn an ugly looking equity curve…

Product Dyno

…into something that looks like this…


Product Dyno

The Multi Timeframe Advantage

A common technique used by traders is utilizing multiple timeframes. Often this is done to filter trades. For example, a trader may be executing trades on a 30-minute chart but will utilize a daily chart to determine the overall bullishness or bearishness of the market. The idea is to use the higher timeframes as a guide to which direction you should be trading on the smaller timeframes. By doing this you are trading with the prevailing direction of the market on higher timeframes. Another common use of multiple timeframes is to locate a specific trade setup on a daily chart yet use an intraday timeframe to help pinpoint an exact entry point. Doing so often results in smaller stop loss values and potentially more profit.

Naturally, for those of us who would like to build a trading system, we would like to take advantage of this multi-timeframe technique as well. In this brief guide, I'm going to use TradeStation’s EasyLanguage to show you how to access information on a higher timeframe and use that as a filter. In fact, we will be using the higher timeframe to both filter trades in the direction of the overall market direction and locate trade setups. It’s a powerful concept and one you will want to use in your personal trading.

During this report, I’m going to refer to two different charts. First is our “long-term chart” which will be our highest timeframe. In this case, that will be a daily chart of the S&P E-mini. The second chart is the “primary chart” which is our 15-minute chart of the S&P E-mini. Our long-term chart will be used to determine the overall bullishness or bearishness of the market and to locate potential trading opportunities. The primary chart will be used to pinpoint our trade entry.

To get started we will need a trading model. To keep things simple I’m going to use a trading concept that we explored before on the website, EasyLanguage Mastery. The article is called “RSI and How To Profit From It.” In that article, we used a two-period RSI on a daily chart as a foundation for our entry signal. More specifically, we are going to utilize the Accumulation Method of RSI. All these means that we are going to add the RSI value over the past three days. A trade is then triggered when that 3-day sum is below 45. The formula will look like this:

RSI Total = RSI From Today Closing Price + RSI From Yesterday’s Closing Price + RSI From Two Days Ago Closing Price

Our Simple Trading Model

We will open a new position if the following rules are true:

  1. The closing price on our primary timeframe must be above the 200-day simple moving average of the long-term timeframe.
  2. The accumulated RSI Value is below 45 on our long-term chart.
  3. The accumulated RSI Value is below 45 on our primary chart.

What are we doing here? 

  1. Rule #1 ensures we are trading when the price is trading above the 200-day moving average. This means we are in an overall bullish market. 
  2. Rule #2 says we want to see a pullback on the daily chart. 
  3. Rule #3 says we want to see a pullback on our small timeframe. 

Rules #2 and #3 are working together to find a pullback that is both appearing on our higher timeframe and in our lower timeframe.

How To Do It 

Within TradeStation, we will first create our primary chart by simply opening a new chart and loading the S&P on a 15-minute interval. Next, we will need to add an additional S&P symbol to our chart to represent our long-term chart. We can do this right within our current chart. By inserting another symbol within the same chart we can tell TradeStation to place the symbol on subgraph two. Once it’s on subgraph two we can easily access the price data on that chart from our primary chart. Here is how...

The key to accessing our higher timeframe chart is to use the keyword “data2″. This keyword tells TradeStation to use the trading symbol located on subgraph two. In other words, our daily chart. It’s important to properly declare all variables associated with data from subgraph two. Let’s declare two variables: One will hold the RSI value from our primary chart while the second will hold the RSI value from our long-term chart.

Below is the variable declaration:

    RSI_Primary(0),
    RSI_LT(0,data2);

Notice that we initialized both variables to the value of zero. However, notice the extra parameter on the RSI_LT variable. This is telling TradeStation that we plan to use this variable to hold values from our subgraph (our long-term chart). From this point, we can use the following code to populate the variables with the correct data:

    RSI_Primary = RSI( Close, 2 );
    RSI_LT = RSI( Close data2, 2 );

In the example above we are filling RSI_Primary with data from our primary chart. More specifically, we are passing in the closing price of the bar that just closed on our primary chart. On the other hand, for our RSI_LT variable, we are passing in the closing price from data2.

It’s that easy to access data on our higher timeframe chart.

Building A Better Trading Model

Below is the code used to compare the current closing price on the primary chart with the 200-period moving average on the daily chart. We are setting a boolean flag to true if we are in a bullish market. This is done to ensure we are only going to take trades when the closing price is above the 200-period moving average.

    BullishFlag = Close > ( Average( Close data2, 200 ) );

Filtering Trades On The Daily Chart

Here is the code used to filter trades on the daily chart. In this case, we wish to use the same RSI accumulation method to locate a strong pullback on the daily chart. By combining this filter with our bullish market filter (above) we are following a basic trading principle of the S&P E-mini futures market. That is, we are buying pullbacks within a bullish market.

    RSI_LT = RSI( Close data2, 2 ) + RSI( Close[1] data2, 2 ) + RSI( Close[2] data2, 2 );

The final code looks like this:

Variables:        
BullishFlag( False ),
RSI_LT(0, data2),
RSI_Primary(0);
RSI_Primary = RSI( Close, 2 ) + RSI( Close[1], 2 ) + RSI( Close[2], 2 );
RSI_LT = RSI( Close data2, 2 ) + RSI( Close[1] data2, 2 ) + RSI( Close[2] data2, 2 );
BullishFlag = Close > ( Average( Close data2, 200 ) );
If ( BullishFlag ) And ( RSI_Primary < 45 ) And ( RSI_LT < 45 ) And ( EntriesToday(Date) <= 0 )
Then Buy next bar at market;
Setexitonclose;
Setstoploss(250);

There you have it - a simple trading strategy built upon RSI that utilizes two timeframes. The video below shows this process and the trading system in much more detail, so I encourage you to watch it. The code used in this strategy is available as a download from the resource section below.

You have just learned a very valuable technique that you can put to use in building more profitable trading systems. Try this technique on some of your existing systems and see if it improves them. Sometimes a simple filter on a larger timeframe will produce great results.

Video Demo #1

Video Demo #2

CONGRATULATIONS!

You’ve just learned a very powerful technique that can really transform your trading. No joke! Test this technique on every system you build. Like I said before, it may not always work but it's worth trying!

For more information visit our website, EasyLanguage Mastery for content-rich articles on all aspects of building profitable trading systems with EasyLanguage.