RightEdge - The Ultimate Backtesting and Trading System Development Platform

Creating an Indicator

This topic is intended by software developers that would like to include their own indicators in the RightEdge Indicator Pane.

Implementing plugins requires some programming knowledge.  It also requires a programming environment capable of compiling code into .NET library assemblies.

Note: Microsoft provides a free version of their development environment that can be used to create RightEdge plugins.  Visit http://msdn.microsoft.com/vstudio/express/ for more information.

 

1.Launch your version of Visual Studio
2.Select New Project from the File Menu
3.Select Class Library from either the C# or Visual Basic project types.

Name the class library MyIndicator.  Change the location to the desired folder.

4.Add a reference to RightEdge.Common.
5.Right click on the References node in the Solution Explorer and select Add Reference... Click the Browse tab and navigate to the RightEdge program directory (C:\Program Files\Yye Software\RightEdge is the default location).  Find the Common.dll assembly and double click each one of them to add them.
6.Begin indicator implementation.

There are three base classes that implement IIndicator which aid in implementing an indicator.  We'll briefly discuss the benefits of each of these base classes.

IndicatorBase

IndicatorBase is the simplest of all interfaces.  This is implemented by an indicator that does not need to look back at previous or support indicator chaining.

SeriesCalculatorBaseSimple

If an indicator is doing a simple calculation on its inputs, you may simply want to calculate the value from the inputs every time the value is requested, instead of storing the entire series of values.  If this is the case, you can derive from this class and implement your calculation in the Item indexer.  This is the recommended base class when backward lookups on previously calculated indicator values are not required.

SeriesCalculatorBaseWithValues

Implements base functionality for an ISeriesCalculator indicator that calculates and stores it's value each time a new bar comes in.  When deriving from this class, call the base constructor with the number of inputs required, and implement the CalcNewValue and Reset functions.  Use this base class when access to previously calculated data is required and may need to be changed or reset.

Let's implement this indicator using IndicatorBase.  To keep the emphasis on implementation as opposed to the details of the indicator itself, we'll implement the average price indicator.  Average price is a simple indicator that takes bar data and returns the average of the High, Low and Close values.  The math is simple:

averagePrice = (high + low + close) / 3.0;

Below is the indicator implemented.  You can paste the contents right into your environment.

 

C#

using System;

using System.Collections.Generic;

using System.Text;

using System.Drawing;

using RightEdge.Common;

namespace MyIndicator

{

 [YYEIndicatorAttribute(System.Drawing.KnownColor.Black,

  YYEIndicatorAttribute.EIndicatorGroup.Trend,

  Name = "Average Price Indicator",

  Description = "An average of the bar's high, low and closing prices",

  Id = "{BE86C408-99C2-45bf-BC21-45D2B8623AD0}",

  HelpText = "A simple indicator that takes bar data and returns the average of the High, Low and Close values.")]

 [Serializable]

 public class AveragePriceSample : IndicatorBase

 {

  public AveragePriceSample()

   : base(true)

  {

  }

  public override List CalcSeriesValues(IList bars)

  {

   return base.CalcSeriesValues(bars);

  }

  public override double CalcNextValue(BarData bar)

  {

   if (bar.EmptyBar)

   {

    return double.NaN;

   }

   return (bar.High + bar.Low + bar.Close) / 3.0;

  }

 }

}

A few items to note.  First, the attributes at the top of the class declaration tell the RightEdge user interface some specific details about this indicator.  The first item is the default color proposed to the user whenever they drag and drop this indicator to a chart or System Designer.  The next attribute is the group that the indicator will fall under in the user interface.  The description is a brief, one sentence bit of information about this indicator.  The Id is a unique identifier which allows this indicator to be identified even if the name, version or other attributes are changed.  The HelpText attribute is long text describing this indicator in detail.  It is recommended that you give an overview of the indicator, its recommended uses and how to interpret the values produced.

Finally, the indicator plugin has been created successfully.  Now it must be copied to the RightEdge plugin directory.  The plugin directory is located off of the main application directory (specified during the installation).  The directory is named "Plugins".  After the plugin has been copied to this directory, start RightEdge and the plugin, if implemented properly, will be found and displayed in the proper place in the user interface.  No further installation is required.

See Also

Plugin Overview

Technical Indicator List

Indicator Pane