RightEdge System Conversion Guide

 

There have been a number of breaking changes between RightEdge 1.1 and RightEdge 1.2.  We believe that these changes are ultimately going to make it easier for all, but a side effect is that existing systems will have to be changed to work with RightEdge 1.2.  The goal of this guide is to provide some basic guidance to get you converted faster.  A number of functions were renamed or moved to different classes to be clearer or more discoverable.  This document outlines the steps to convert a system to RightEdge 1.2.  We recommend first reading the "RightEdge Development Guide" which covers the basics of writing systems in RightEdge 1.2.  Also see the RightEdge 1.2 Release Notes for more changes.

 

The biggest change is that in addition to the system class you can create what we are calling a "symbol script" class.  One copy of the symbol script class is created for each symbol that you are running your system with.  This allows us to provide you access to frequently used data (such as bars, indicators, etc.) without you having to specify the symbol.  This makes the code simpler to read and write.  It is also now much easier to store symbol-specific information.  You just need to declare a variable in your symbol script class, and there will be a copy of that variable for each symbol.

 

First things first, make a backup copy of your RightEdge 1.1 trading system.  Next, launch RightEdge 1.2.  Let's create a new system to be used as a basis for the conversion.  Name it ConversionSystem.  We create this so that new RightEdge boilerplate code can be migrated to your old system.  You'll notice that there are two files created.  The main system code, as in previous versions, resides in your ConversionSystem.cs/.vb file.  But in addition to that is a file named "BaseClasses.cs/vb".  This file is auto-generated and will be automatically generated when you open your old system for the first time in RightEdge 1.2.

 

Let's briefly take a look at the new system code.

 

public class MySymbolScript : MySymbolScriptBase

{

    public override void Startup()

    {

        // Perform initialization here.

    }

    public override void NewBar()

    {

        // Put your trading code here

    }

    public override void OrderFilled(Position position, Trade trade)

    {

        // This method is called when an order is filled

    }

    public override void OrderCancelled(Position position, Order order, string information)

    {

        // This method is called when an order is cancelled or rejected

    }

}

 

The overrides are nearly the same, but there are two notable differences.  First, we automatically override OrderFilledPosition and OrderCancelled.  These were difficult to discover for most, so we have automatically presented the overrides.  By default, they do nothing.  You may remove them if you don't use them.

 

The second and most important difference is the NewBar() override.  Previously, by default, RightEdge would override NewSymbolBar which would give you the current symbol that was being operated on and the current bar.  Since this is all wrapped in base classes, you can now always access the Symbol property to get the current symbol and use Bars.Current to get the most recent bar.  In addition to this, we've added Open, High, Low, and Close collections to quickly access bar elements.  To get the current open value, use Open.Current.

 

Migrating Your Code

To begin migrating your code to the new model, open your trading system in RightEdge 1.2.  For this demonstration, I'll use the MovingAverageHold system available for download and convert it to 1.2.  Remember the location of the ConversionSystem as we'll need to reference some of the boilerplate.

 

The meat of MovingAverageHold as it is in RightEdge 1.1 is shown below.

 

public override void NewSymbolBar(Symbol symbol, BarData bar)

{

    ISeries sma = Indicators["SMA"][symbol];

    double smaValue = sma.Values[sma.Values.Count - 1];

    if (OpenPositions.Count == 0)

    {

        if (smaValue < bar.Close)

        {

            OpenPosition(symbol, PositionType.Long, OrderType.Market);

        }

    }

    else

    {

        if (smaValue > bar.Close)

        {

            List<Position> positions = PositionManager.GetOpenPositions(symbol);

            ClosePosition(positions[0].PosID);

        }

    }

}

 

The first thing to do is to copy your system logic to another file or into another editor so that it can be copied into the new format.  In this case, I'm going to copy the contents of NewSymbolBar to a safe location.  Next, I will copy the boilerplate from ConversionSystem in its entirety into MovingAverageHold.cs.  Note, you may want to run two instances of RightEdge and have ConversionSystem opened in one instance and MovingAverageHold in another.

 

The SMA indicator was created in drag and drop, but let's remove it from drag and drop for two reasons.  First, to demonstrate how simple it is to create indicators and second, for those who need to migrate indicators that were not created in drag and drop.  The first thing we do is declare an SMA in our symbol script class.

 

private SMA sma;

 

Second, we instantiate it in Startup()

 

public override void Startup()

{

    // Perform initialization here.

    sma = new SMA(200, Close);

}

 

Finally, we migrate our NewSymbolBar to NewBar.

 

public override void NewBar()

{

    if (OpenPositions.Count == 0)

    {

        if (sma.Current < Close.Current)

        {

            OpenPosition(PositionType.Long, OrderType.Market);

        }

    }

    else

    {

        if (sma.Current > Close.Current)

        {

            OpenPositions[0].CloseAtMarket();

        }

    }

}

 

Some changes worth noting here, we no longer have to access our indicators through the IndicatorManager via hash tables and strings.  SMA instances are created for each symbol since it is declared in the symbol script class.  Second, since it's typical to request the current value of a series, there is no need to get a count and access Count - 1.  The Current property, as shown above, will always contain the most recent value.

 

The introduction of Open, High, Low and Close series are demonstrated above as well.  For those interested in accessing the entire bar as done previously, the Bars.Current property is available to get the most recent bar.

 

Other items were changed in the above code, such as OpenPosition and ClosePosition.  A complete list of changes can be found in the release notes.

 

A Word About Indexers in Series

One of the most far reaching changes is the fact that we've reversed the way series data is accessed.  It is far more likely that system developers want to have access to the current value and work their way back rather than the other way around (which is how traditional arrays are structured).  To facilitate this, we've implemented a Current property which always contains the most recent value.  To go backwards in time we provide a method called LookBack which takes a positive number specifying the number of periods to go backwards.  Noticeably missing are traditional indexers ([ ]) or parenthesis in Visual Basic .NET.  This is intentional due to the fact that accessing a series with indexers, if we left them in, would still compile.  And with the series reversed, would create serious problems at run-time.  The decision was tough, but we hope moving forward you'll come to appreciate the simplicity we've introduced.

 

The final step to ensure a successful 1.2 experience is setting your SystemClass and Symbol Script class in the Project Properties.  To access Project level properties, right click on the system name in the Trading System pane and select Properties.

Add the names MySystem and MySymbolScript as highlighted.
This is the final step to get your system properly converted to 1.2.

 

We're Here to Help!

Finally, we understand the short term pain we're causing existing system writers.  We know firsthand because we had to go back and perform these conversions ourselves and will have many more to perform as all of the systems on the web site will be updated for 1.2 when it becomes generally available.  With that being said, we'd like to offer free help converting existing systems.  It can be as simple as asking how to make a simple change, to making complete conversions.  Nothing is off limits.  Please send your request to resupport at rightedgesystems dot com and our engineers will do the conversion for you or answer any questions you may have with your conversion.