forex software

Create and Test Forex Strategies

forex software

develop:converting-indi-fsbpro

Converting Legacy Indicators in FSB Pro Format

FSB Pro provides some new features as working with several strategies, loading different data sets simultaneously, using different symbols and periods for an indicator in a strategy. These new features require minor changes of indicators format. In order to provide future compatibility, we modified FSB Freeware for using the new format.

I'll explain the new format by comparing and converting Footons's Adaptive MACD indicator with the already converted MACD from FSB v2.81.

I'm using Notepad++ for editing indicators in this tutorial.

The source code of Adaptive MACD can be find in this forum post: Converting Indicator in New Format

New Name Spaces

FSB Pro uses three new namespaces:

 using ForexStrategyBuilder.Infrastructure.Entities;
 using ForexStrategyBuilder.Infrastructure.Enums;
 using ForexStrategyBuilder.Infrastructure.Interfaces;

Also indicators are defined in namespace ForexStrategyBuilder.Indicators.Store

Old code:

using System;
using System.Drawing;

namespace Forex_Strategy_Builder

New Code:

using System;
using System.Drawing;
using ForexStrategyBuilder.Infrastructure.Entities;
using ForexStrategyBuilder.Infrastructure.Enums;
using ForexStrategyBuilder.Infrastructure.Interfaces;

namespace ForexStrategyBuilder.Indicators.Store

Initialization

New indicators use parameterless constructor and move initialization in Initialize method. This allows program to create an instance of an indicator and to set its slot type later.

  1. We create or copy/paste parameterless constructor.
  2. Move initialization form the old constructor in the new parameterless one.
  3. Make Initialize method from the old constructor.
  4. Delete IndParam initialization. IndParam class is created in the base Indicator class. SlotType and IndicatorName are also set in the base class.
  5. Add SlotType initialization: SlotType = slotType;
  6. Delete IndParam.CheckParam[0].Checked = PrepareUsePrevBarValueCheckBox(slotType);. FSB Pro cannot set PrevBar check box in initialization. It does it when calculates the indicator.

We don't need setting CustomIndicator = true; in a custom indicator. FSB sets it when loads the indicator.

Old code:

  public class MACD : Indicator
  {
      public MACD(SlotTypes slotType)
      {
          // General properties
          IndicatorName = "Adaptable MACD";
          PossibleSlots = SlotTypes.OpenFilter | SlotTypes.CloseFilter;
          SeparatedChart = true;
          CustomIndicator = true;
          
          // Setting up the indicator parameters
          IndParam = new IndicatorParam();
          IndParam.IndicatorName = IndicatorName;
          IndParam.SlotType = slotType;
          
          // The ComboBox parameters
          IndParam.ListParam[0].Caption = "Logic";
          IndParam.ListParam[0].ItemList = new string[]

New code:

  public class MACD : Indicator
  {
      public MACD()
      {
          IndicatorName = "Adaptable MACD";
          PossibleSlots = SlotTypes.OpenFilter | SlotTypes.CloseFilter;
          SeparatedChart = true;
      }
      
      public override void Initialize(SlotTypes slotType)
      {
          SlotType = slotType;
      			
          // The ComboBox parameters
          IndParam.ListParam[0].Caption = "Logic";
          IndParam.ListParam[0].ItemList = new string[]

Calculate Method

We push DataSet to Calculate method. DataSet keeps testing data in FSB pro. It allows giving different data to each indicator. Actually DataSet is not used in FSB Freeware but we have to set it in order to provide FSB Pro compatibility. We do not need setting SlotTypes in Calculate method since we set it in Initialize.

We have to rename slotType to SlotType in the Calculate method code since slotType is not used. Calculate uses base property SlotType.

Old code:

      public override void Calculate(SlotTypes slotType)
      {
          // Reading the parameters
          MAMethod shortmaMethod = (MAMethod )IndParam.ListParam[1].Index;
          MAMethod longmaMethod = (MAMethod )IndParam.ListParam[4].Index;

New code:

      public override void Calculate(IDataSet dataSet)
      {
          DataSet = dataSet;
          	
          // Reading the parameters
          MAMethod shortmaMethod = (MAMethod )IndParam.ListParam[1].Index;
          MAMethod longmaMethod = (MAMethod )IndParam.ListParam[4].Index;

SetDescription Method

SetDescription doesn't need slotType parameter anymore since it is stored in the base class. We remove slotType parameter from declaration.

Old code:

/// <summary>
/// Sets the indicator logic description
/// </summary>
public override void SetDescription(SlotTypes slotType)
{
	EntryFilterLongDescription = ToString() + "; the MACD line ";
	EntryFilterShortDescription = ToString() + "; the MACD line ";

New code

/// <summary>
/// Sets the indicator logic description
/// </summary>
public override void SetDescription()
{
	EntryFilterLongDescription = ToString() + "; the MACD line ";
	EntryFilterShortDescription = ToString() + "; the MACD line ";

DataPeriod Enumeration

DataPeriod was changed. New enumeration is in ForexStrategyBuilder.Infrastructure.Enums namespace. It replaces the old DataPeriods.

This change does not affect Adaptive MACD indicator.

  namespace ForexStrategyBuilder.Infrastructure.Enums
  {
      public enum DataPeriod
      {
          M1 = 1,
          M5 = 5,
          M15 = 15,
          M30 = 30,
          H1 = 60,
          H4 = 240,
          D1 = 1440,
          W1 = 10080
      }
  }