How to Create an Indicator with EasyLanguage

This simple tutorial shows 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 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 moving average speed; 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.


Finally, the string of code to draw the average:

Plot1( MA, “MA”);


How to add colors

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:


At this point, I want the moving average to turn red when 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 );

How To create an indicator in TradeStation

The complete code in EasyLanguage:



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 );