# How to Create an Indicator with EasyLanguage

In this simple tutorial, we show you how to create an indicator with EasyLanguage for TradeStation and MultiCharts.

Let’s build an indicator in Easylanguage from scratch. As always, the simplest example is a Moving Average, but we will then complicate the code a bit to create something different from the one on the platform.

An indicator can be drawn in the price chart or the window below. There are also other types:
Paint bar
Show me

## How to Create an Indicator with EasyLanguage

First, we declare the input relative to the speed of the moving average, in this case, we put 20 periods (4 weeks), to declare an input, the reserved word Input is used.

Input: MA_length(20);

In this case, the input is a numeric value, but it could also be a True / False or a text string.

Then the variables will be declared using the reserved word Variable (or Var, Vars, Variables)

vars: MA(0);

We pass the average calculation; this is the heart of the program. We will use the average function calculating the average based on the closing price (Close), but it can also be used Open, High or Low.

MA=average(Close,MA_length);

Finally the string of code to draw the average:

Plot1( MA, “MA”);

This is the moving average already present in each platform, so let’s add some other lines of code to change the color and have some additional information.

Insert the color variable:

color(white);

At this point I want the moving average to turn red when it is descending and green when it is ascending.

To do this, I’ll have to compare the average of the current candle and the previous two:

If MA>MA[1] and MA[1]>MA[2] then

color = Green;

If MA<MA[1] and MA[1]<MA[2] then

color = Red;

I will also have to modify the code part related to the drawing:

Plot1( MA, “MA”,color,0,3 );

## The complete code in EasyLanguage:

``````Input:
MA_length(20);

vars:
MA(0),
color(white);

MA = average(Close, MA_length);

If MA>MA[1] and MA[1]>MA[2] then
color = Green;

If MA<MA[1] and MA[1]<MA[2] then
color = Red;

Plot1( MA, “MA”,color,0,3 );``````

# Moving Average Slope Trading System

Moving Average Slope Indicator

The Moving Average Slope Indicator is the most popular technical indicator, it provides useful information, but often it’s not sufficient.

To program an automated trading system, often, you need to calculate the slope of the moving average.

Calculating the slope is very simple, you have to compare the last Moving Average value with the present.

This is the classic formula, but we do not like it. Comparing just two candles is too short. There are too many changes in the slope direction and therefore, too many false signals.

We prefer to compare more candles. Notice the noise decreasing.

If you use a short moving average (less than 50-periods), to avoid the noise, you have to increase the number of bars used for the calculation.

Moving Average Slope Trading System – Strategy Backtest

We created a simple Moving Average Slope Trading System to backtest this indicator.

The strategy works well when the market is trending strong.

We backtested this strategy using a 20 MA period with EURUSD Daily from 2000 to 2010, and it works.

The automated trading system buys when the slope became green and sells when the slope became red, without stoplosses and with appropriate position sizing.

After 2010 the Moving Average Slope Trading System doesn’t work because EURUSD and the other currencies lost volatility and strength. With a weak trend, there are too many false signals.

This backtest is only for statistical research in order to understand if the strategy is connected with the market.

Moving Average Slope with ADX filter

We know that when the trend is flat, the indicator starts to change directions with random movements.

We need to filter the trend intensity and try to stop the indicator when the trend is flat.

The best indicator to examine the strength of the trend is the Average Directional Index (ADX). When ADX is high, the trend is strong; it doesn’t matter if it goes up or down.

When our ADX is under 20, the trend is weak, and the Moving Average Slope can provide false signals.

Naturally, with the ADX as a filter the results of the Moving Average Slope Trading System on EURUSD 2009/2019 improve.

The strategy with EURUSD is very weak and certainly cannot be used.

Two moving average slope indicator

Another trick to limit false signals, we can add another Moving Average Slope Indicator.

So we have, for example, a 20-periods Slope MA with a 40-periods Slope MA system.

When both indicators have the same direction, the signal is stronger. To chart this, we could use a histogram.

We can use this indicator to create different Moving Average Slope Trading Systems. But remember that Moving Average is a lagging indicator and is good exclusively for trend confirmation.

Using Moving Average Slope to filter the trend

We could use this indicator in many trading system strategies to filter the direction. A lot of traders use moving averages to filter the trend. It’s important to understand there is no trend in shorter periods.  If we need to filter the trend, we need to use at least at 40-period Moving Average.

This indicator is useful when you have many charts open simultaneously on your screens at your Trading Workstation at your office space and want to see the trend at a glance.

## More from Finance Strategy System

KEY REVERSAL PATTERN

Free EasyLanguage Indicator

Automated Trading System || The Essential Tutorial for Dummies

SuperTrend Multi Time Frame Indicator

The McClellan Summation Index || Technical Analysis

The TRIX || Triple Exponential Average Indicator || Tutorial

Ichimoku Indicator | Ichimoku Kinko Hyo | Tutorial

Coppock Curve Indicator

NAAIM Exposure Index || What is and How Use It

Parabolic SAR Indicator – Technical Analysis Tutorial

# Bollinger Bands BandWidth Indicator for TradeStation

The Bollinger Bands are already present on every platform, but using the Bollinger Bands Bandwidth Indicator, the bands will be displayed only when the volatility decreases (during periods of “congestion” or during a range-bound market).

I sometimes use this filter in mean-reverting strategies to avoid signals when volatility is low. This simple correction generally improves breakout strategies.

## How to Create a Bollinger BandWidth Indicator

Firstly, we will use the Bollinger Bandwidth function which measures the BandWidth and thus the volatility of a given financial instrument.

We begin to draw the Bollinger Bands with simple code, slightly different from what you find on the platform:

After that, we have to code the slow and fast Bandwidth and its moving average:

The result will be the distance between the bands. However, we do not just need the distance, so we’ll have to compare a fast Bandwidth with a slower one. In this example, we use a 50-period moving average.

If volatility increases the Bandwidth stays above its moving average.

In addition, we insert the fast Bandwidth above the slow Bandwidth so you can have four types of volatility already usable:

The indicator will draw congestions like this:

## How to “draw” Transparent Bollinger Bands

To display the Bollinger Bands BandWidth only during the phases of decreasing volatility, I used the Argb function.

With this function, we can define the colors in Easylanguage for only TradeStation and have much more flexibility than the few preset colors.

The code looks like this:

color_up=Argb(255,255,0,255);

In short, replace the first and the last value with a 0 and the color becomes transparent.

## …

[sociallocker id=”7256″]

[/sociallocker]

## More from Finance Strategy System

TUTORIAL

The Bollinger Bands Indicator Tutorial

The McClellan Summation Index || Technical Analysis

ATR with BOLLINGER BANDS – EASYLANGUAGE

Bollinger Bands Standard Deviation

Momentum Indicator Oscillator || 2020 Tutorial

TradeStation Strategy – Bollinger Bands Reversal Price Exit Setup

Gold Trading Strategy with Stochastic Indicator

BOLLINGERBANDS.COM: What are Bollinger Bands?

Are you searching for SuperTrend Indicator? This post if for you!

The Supertrend Indicator (ST), developed by Olivier Seban, was born as a tool to optimize the exit from trade, which is a trailing stop.

ST could be the key to unlocking predictions about future trends for intraday traders or longer term. Today is one of the most used tools by traders.

In this tutorial, we will explain what it is, how it is used, and how to calculate it. You can also download SuperTrend free versions for TradeStation, MultiCharts, MetaTrader.

## What is SuperTrend Indicator?

The ST Indicator ST belongs to the category of follower trend indicators. These types of indicators signal the direction of the trend and highlight the continuation or changes of direction.

As a trend following indicator, super trend works well in a trending market (Parabolic Sar, Moving Averages, MACD, Etc.).

The primary lesson of these indicators is for the most part: don’t open a  position contrary to the trend.

And very similar in his conception to Wilder’s Parabolic SAR. However, the Supertrend has the merit of positioning itself horizontally, in a sort of stand by, in moments of price laterality, avoiding getting us out of position before time.

We must always remember that all trend-follower indicators have a common flaw: they warn of the change of trend AFTER the change has taken place, not PRIMA.

They are all indicators that update with an inevitable delay; they are not anticipators of the trend.

Let’s see the two indicators in comparison: the SuperTrend is represented with the solid line, while the Parabolic SAR with the classic green dots (up) and red dots (down).

It is immediately noticeable that the continuous color change of the Parabolic SAR gives rise to many more false signals than the SuperTrend

However, the ST has two enormous merits:

1) It is straightforward to use because the identification of the trend takes into account the average volatility of the asset.

2) It can be used with any timeframe and all financial instruments (shares, indexes, forex).

Others do not do so and, therefore, often force them to leave the market too early.

On the other hand, the SuperTrend filters many false signals, and this allows us to keep the position open for longer and increase the average profit.

A trend follower strategy to be successful must remain on the market as long as possible.

The longer you stay on the market, the more trends you can take advantage of.

At the same time, it also needs to come out quickly if the trade is going the wrong way.

## How do you use the ST Indicator?

From a graphical point of view, the Super Trend appears as a red or green line that accompanies price trends.

The SuperTrend buy signal and sell signal is about more than just identifying the trend. The technical indicator does not only turn green and turn red for entry signals.

The red line identifies periods characterized by a negative trend, while the green line indicates market periods with a positive trend.

When the line is below the graph, the trend will be upward, and it will, therefore, be preferable to open long positions.

When the indicator line is above the graph, the trend will be downward, and it will, therefore, be preferable to open short positions;

There are three different ways you can use this indicator:

### Filter Operations

The ST show us the current trend, remember that we do not want to go against the primary uptrend or downtrend.

So if the underlying trend is upward, we will only make long trades, if downward only short trades.

In this way, we filter several false “counter-trend” buy signal or sell signal.

The reversal of a trend occurs when prices cross the indicator line positioned at a given level from one side to the other.

This level is defined as a roof or floor, depending on whether it is above or below the price scale.

### We need it as a trailing stop.

The real promise of the SuperTrend is making a great trailing stop system using the power of the Average True Range ATR indicator. So you can use The ST to manage the exits from another trading strategy.

This indicator will keep us in the extended position until the indicator remains green or short until the indicator remains red.

We’ll get out as soon as the color changes.

We could use a Supertrend Trading Strategy to find a buy or sell signal.

We open a long position at the change of color from red to green (buy signal is generated).

Vice-Versa, we can open a short trade when green becomes red (sell signal is generated).

Positions will close the next time the indicator changes color.

Theoretically, we can always stay in the market – stop & reverse strategy – moving from long to short all the time.

With this technique, there will be no shortage of false signals, especially in phases of prolonged laterality.

It will, therefore, be of fundamental importance to close the position in stop-loss if the market does not go in the desired direction.

We prefer to suggest that you do not use it alone but integrate it into your trading systems with the use of other tools.

Even if the ST is a very valid indicator, it is better to use it in combination with at least one other.

We can use it together with the CCI, Momentum, ADX, RSI.

### Two SuperTrend Indicators – The Double Strategy

There is also the possibility to take advantage of ST not in combination with another technical indicator, but by combining two ST indicators.

We can then apply the same indicator to the graph but with two different settings, one fast and one slow.

In this case, when the fast curve crosses from bottom to top the slow curve, we have a long signal.

When the fast curve returns below the slow curve, it is time to close the operation. We practically expect both curves to have the same color.

### Which timeframe to use for SuperTrend Indicator

At first, we said that the SuperTrend has the advantage of being able to be used in every timeframe.

In general, however, on intraday trading timeframes it loses its effectiveness, there is no single rule, it is advisable to make a few attempts on the financial instrument we intend to trade.

Although it should always be remembered that the real trend exists only on long time frames, so from the daily up.

### SuperTrend Indicator MultiTimeFrame

Always to limit false signals, we have built a SuperTrend Multi Time Frame indicator.

## How is the ST Indicator calculated?

The ST is calculated based on a coefficient that is applied to the average volatility of the period considered.

The Super Trend indicator is calculated using the Average True Range (ATR).

The Average True Range is an indicator that calculates the average range of the last X seats and measures volatility.

Once volatility is identified, the Super Trend is calculated by applying to the latter a volatility multiplier and a coefficient relative to the observation period over which volatility is calculated.

It must always be borne in mind that the higher the weight of volatility, the wider the range of tolerance before a reversal of trend occurs.

The SuperTrend Indicator Formula:

Upper=(high+low)2+ (Multiplier∗ATR)

Lower=(high+low)2− (Multiplier∗ATR)

## Conclusions

Is the ST Indicator a great indicator?

The ST is, indeed, a great indicator.

However, we always remember that when long sides are formed, the Supertrend generates many false signals, but it is still the biggest flaw of all the trending indicator.

## Q&A

It is certainly possible to use it, but we do not like it as a trading system because, in the market, the ongoing trend exists are on high timeframes. A correct ST trading strategy should be based on daily timeframes or higher.

Is it the best trending indicator?
For us, it is the best trending indicator. The Super Trend Indicator is the one that provides fewer false signals, compared to parabolic SAR, for example.

#### More from Finance Strategy System

Wikipedia

Are you looking for a NinjaTrader SuperTrend?

You can find it in the NinjaTrader Forum.

# Smoothed RSI indicator with EMA

Let’s see how to create our smoothed RSI indicator by using a Moving Average with Easylanguage.

For this example, we will use an RSI, and we will go to create two indicators.

The first is a classic indicator and be placed below the graph. Another indicator is a PaintPar that will color the candles according to the trend.

The yellow line is the normal ATR while the red line is the smooth ATR through its 10-period average (2-weeks).

The normal RSI is very fast and more susceptible to random market movements.

## How to create the smoothed RSI:

The formula in Easylanguage to “smooth” and make a series of data slower as the RSI line is this:

RSI_VALUE = RSI(Price, Length);
RSI_SMOOTH = Average (RSI_VALUE, Smooth);

This indicator is very useful as a trend filter.

We then build a PaintBar indicator that will color the candles green when the ATR is above 50 and red when the ATR is below.

The PaintBars available on TradeStation and Multicharts are very useful to get an immediate idea of ​​the current trend.

If we compare the PaintBar calculated with the standard RSI length, we see that have fewer signal changes.

Some traders use the RSI crossing above and below 50 to open long and short positions, but from the tests carried out, it is not a robust strategy.

It is, therefore, preferable to use this indicator exclusively to identify the primary trend.

Resources:

INVESTOPEDIA: Relative Strenght Index

## More from Finance Strategy System

How to create a Show Me Indicator

How to calculate the Relative Strength in the Stock Market

EasyLanguage – StartTime | EndTime | MultiCharts & TradeStation

MOVING AVERAGE – RSI – SLOPE

EasyLanguage & PowerLanguage Tutorial – The Inputs

RSI oscillator (Relative Strength Index) | Essential Tutorial

Ichimoku Indicator | Ichimoku Kinko Hyo | Tutorial

ATR CALCULATOR for STOP LOSS INDICATOR

# Connors RSI Strategy

Let’s build a new Tradestation Connors RSI strategy in EasyLanguage.

Today we present the excellent 2-period Connors RSI method devised by Larry Connors. We apply it to the US index using the SPDR S&P 500 Exchange Traded Fund (ETF) SPY.

First, What is the Relative Strength Index (RSI)?

From Investopedia is “The  RSI is a momentum indicator that measures the magnitude of recent price changes to evaluate overbought or oversold conditions in the price of a stock or other asset“.

Classic Relative Strength Index and Connors RSI:

We have many strategies with RSI Indicator. This is our custom indicator that shows also the direction:

## The original Connors RSI strategy

BUY: When the Relative Strength Index indicator is oversold below the 5 levels.

EXIT: When the price closes above the simple 5-period moving average on PriceClose.

Connors also uses a trend filter through a 200-period moving average to determine the big trend.

Today we will change the original strategy. We using an oversold level of 10 and we will not use the trend filter.

However, the system will only go long on a daily time frame. Caution: The system does not have adequate position sizing and buys \$ 10,000 with an initial capital of \$ 30,000 and has a huge stop loss of \$ 2,000.

## EasyLanguage Code for TradeStation and MultiCharts

There are many strategies that you could code in EasyLanguage for TradeStation.

This is only one alternative version.

Input:

RSI_Period(2),

RSI_OverBought(10),

MA_Exit_Period(5);

Then we declare the variables:

Variables:

RSI_Value(0),

Exit_MA(0),

Max_Risk(000);

Then we code the RSI calculations for the entry signal and the moving average for the exit:

RSI_Value = RSI(Close,RSI_Period);

Exit_MA = Average(Close, MA_Exit_Period);

Finally, we insert the code to send the order and manages the exit:

If ( RSI_Value <= RSI_OverBought )  Then buy(“Buy”)  this bar at close;

If ( MarketPosition <>  0 ) And ( Close > Exit_MA ) Then sell(“Exit”) this bar at close;

If ( Max_Risk > 0 ) Then SetStopLoss( Max_Risk );

This is the Trading System’s equity line and results:

## Conclusions

We coded the Larry Connors RSI 2 strategy in EasyLanguage for TradeStation and we like it!

The results of our trading operation utilizing strategy: 22trades with an average profit of \$44 per trade, with a very good percent of profitable trades at 70%.

We can improve it by adding a trend filter with position sizing rules. The size of the position must depend on implicit or historical volatility.

Tradestation and MultiCharts Strategy RSI Connors – Easylanguage final code:

## More from Finance Strategy System

STATE STREET SPDR: SPDR S&P 500 ETF SPY

WIKIPEDIA: Larry Connors

How the Stock Market Moves