Indicator Development

Product core language is C#, so it was a natural decision to use C# as a custom indicator development language as well. If you have some experience with it, there will be no problems. Even if it's not the case, it will be fairly easy to find a developer who can do this work for you. I will add a list of software developers who are willing to do this work at the end of this article. If you are the ony who is able to do it, just contact me - I will add your contacts here for free.

I tried to make your work as easy as possible. You don't need any external libraries, there are no dependencies. You don't need to compile the code or even build a library out of it. All you need is to edit the source code then hit F5 in the product to see the results of your work. Any text editor can handle that.

For your convinence you can use some development environment, something with syntax and error highlighting. There are plenty of great code editors on the market, so I decided not to bother about developing yet another one. You can edit the code in any external editor of your choice.

By the way, indicator code extention may be different from .cs. It may be convenient if you decide to edit them in some other editor than a default one, associated with *.cs files one in your system

Open source code of one of the sample custom indicators:

    [Indicator(Name = "Simple Moving Average", SeparateChart = false)]
public class SimpleMovingAverage : Indicator
/// ==================================================================
/// ============================ inputs ==============================
/// ==================================================================
[Input(Name = "Period", MinValue = 1)]
public int Period = 50;

As you can see, all indicators are derived from a common base class named Indicator. If you scroll, you will find it. You may reference it to find available properties, settings and attributes, they are mostly self-descriptive in nature.

Every indicator must have Indicator attribute with its display name, separate chart flag and additional parameters like fixed max/min chart range and levels.

Input properties must be marked with Input attribute. Their type and editors in indicator properties depend on their type. The most convenient part is that you can add any enum and be able to edit it without any extra work.

Output properties is what will be displayed on the chart. They must be marked with Output attribute. Type may be bars, lines or curves, depending on how do you want to visualize it. Here you can also find other settings like style and color of the lines.

        /// ==================================================================
/// ============================ outputs ==============================
/// ==================================================================
[Output(Name = "Moving Average", Type = OutputTypes.Curve, Color = "#FF0000", Thickness = 1, Style = LineStyles.Solid)]
public double[] MovingAverage;

There is only one required function in each of the indicators: Calculate. It's called on every indicator redraw, several times per second. If you do some complex calculations, better cache results to make it responsive.

        public void Calculate()
for (int i = Period; i < Bars.Length; i++)
MovingAverage[i] = Calculate(i);

When this function gets called, you get the following state:

  1. Bars is filled with an array of bars on the main chart, several times longer than the visible part. It enables you to calculate values of lagging indicators like moving averages.
  2. Ticks has up to 100 last ticks in it. If you need more, you should use it as a source of data for your internal tick storage.
  3. All output arrays lengths are equal to input ones and pre-filled with empty values, not being visible on the chart. All you need is to set up values that have a meaning.

For your convenience, I added a shortcut to the chart - F5. It compiles and reloads all active custom indicators. All you need is to edit the code, then switch to Forex Simulator and hit F5. Source code may be located anywhere, you can choose new location in indicator settings.

If there are any compilation or execution errors, you will get a detailed error report directly on the chart. Fix the error, then hit F5 again.

Don't hesitate to contact me if you get any questions or ideas. I'm always eager to help!