In this tutorial, we are going to create an indicator for Tradestation or Multicharts that calculates the slope of a moving average and an RSI, making it change the color.


Moving Average Slope TradeStation Multicharts

Let’s see how to do this, starting from the code of a previous tutorial on the creation of a moving average indicator.




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

We set the “color” as a variable initializing it with “white”, at this point, we have to calculate the inclination of our moving average.

The best system is to take the value of the moving average of the last three candles and check if this value is increasing or decreasing.

You could also use the value of only the last two candles, but in this way, the average would change color too frequently.

Let’s see the code to calculate the inclination of the moving average:

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

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

As you can see it’s very simple. Just add the two square brackets to any variable and inserting the number of past candles.

The same code can be used within a strategy to implement a trend filter based on a moving average.

For example, we can identify an uptrend when prices will be above their moving average, and the trend will be further confirmed when the average will have a positive inclination and vice versa.


This operation can be done with any indicator, for example let’s see how it would work with the RSI indicator:


RSIValue( 0 ),
color(white) ;

RSIValue = RSI( Close, RSI_Length ) ;

If RSIValue>RSIValue[1] then
color = Green;

If RSIValue<RSIValue[1] then
color = Red;

Plot1( RSIValue,”RSI”,color,0,3 ) ;
Plot2( OverBought,”OverB”,white,0,3 ) ;
Plot3( OverSold,”OverS”,white,0,3 ) ;

For the RSI, I have compared only two periods because graphically, it works better. Infact, the RSI is faster  than a moving average.


Register or Login and Download the indicator for free!!

DOWNLOAD LINK:   Moving Average and RSI Slope Indicator