Creating Easy Indicators


When we are going to create a custom indicator its best to do this in the form of a Custom Command. This way we will have a clean bot script and a reusable command in one. The command will have 2 inputs, a chartIndex & interval and a single output, the signal.

In this example we will create a SmoothRSI. We will start by using the DefineCommand() command. This set the command name and description for the command.

Input Parameters

For the input parameters we could use DefineParameters() twice but there is an easier way. DefineEasyIndicatorParameters can do the work for us. The command creates 2 parameters for our script. The chart index and interval. It returns both parameter in object we can access.


The output will be a signal result. SingalLong, SignalShort, SignalNone. For this output type we also have an single command that takes care of everything. DefineEasyIndicatorOutput(). It will set the return type, description and suggestions for our command.

Price Data

The next stop is to get some price data to work with. We are going to use the ClosePrices() based on the interval returned by DefineEasyIndicatorParameters()


With the ClosePrices() we can calculate the RSI using the RSI() command. The command takes 2 parameters. The prices, our ClosePrices() result, and a period, the length of the RSI. For the second value we are going to use an Input field command.

After the RSI calculation it is time to smooth the RSI. Using the SMA() command will give us a nice smooth RSI result to work with. The SMA() also takes a period parameter. For this we again create an input field. The SMA() result is our smoothed RSI.

Signal Result

RSI's always work with a buy and sell level. So should ours. We could use the IsBiggerThan and IsSmallerThan command but ofcource there is an easier way. In the Signal Helpers category there are a bunch of command that will do the calculation for us. We are going to use the GetBuySellLevelSignal. This will return a SignalLong when the value is below the buy level and a SignalShort when the signal is above the sell level. For the buyLevel and sellLevel parameters we will use an Input command. The result of GetBuySellLevelSignall will be the value for the result parameter in DefineEasyIndicatorOutput().


No indicator is complete without some lines on the chart. Lets plot the RSI and the Smoothed RSI on the chart. We are using the chartIndex returned by DefineEasyIndicatorParameters() for the Plot commands.

There are also buy and sell levels we want to draw on the chart. We could use 2 PlotHorizontalLines() command but there is always an easier way. PlotBuySellZone(). This draws 2 lines with an area fill between them.

Final Indicator

The custom indicator is now finished. If we save it and run a quick test we can have a look at the chart.

Using the command

We can now use the command in any other script we like and in combination with other indicators without issues!

Last updated