Miro, if you'll convert this, make sure FST's namespace is used, it's no use in FSB.
This is the reason I choose this indicator to demonstrate the new parameters.
As I announced earlier, all new indicators are both compatible with FSB and FST. But that doesn't mean that there is no separation in functionality.
There is a new parameter: IsBacktester. This param is equal to true when the indicator works in FSB and false when works in FST.
You can see for an example: DateFilter
Date filter works only in FSB.
I'm using IsBacktester in constructor to set an warning message when indicator is started in FST.
if (IsBacktester)
WarningMessage = "This indicator is designed to be used in the backtester only. It doesn't work in the trader.";
This warning will be visible only in FST. I cannot demonstrate that because Date Filter is internally banned in FST, but everyone can use this technique in other indicator.
Later, In Calculation method. I'm using:
if (IsBacktester)
{
switch (IndParam.ListParam[0].Text)
{
case "Do not open positions after":
for (int bar = firstBar; bar < Bars; bar++)
if (Time[bar] < keyDate)
values[bar] = 1;
break;
...
}
}
else
{
for (int bar = firstBar; bar < Bars; bar++)
values[bar] = 1;
}
We see that the indicator calculates signals in FSB, but sets 1s for all bars in FST (Indicator confirms both direction trade).
I'll use same format but in opposite direction for Spread Limiter:
- It will be available for loading in both programs.
- It will gives reasonable signals in FST.
- It will warn that is not suitable for FSB (when loaded there)
- It will not have any effect on backtest in FSB.
- It will not be used from Generator. I'll set IsGeneratable = false; (also new param)
Why I want to use this format:
1. You never know what a user will do. It may put this indicator in FSB.
2. It will not prevent strategy written in FST with this indicator to be loaded in FSB.
3. We'll have one set of indicators for all programs.
namespace Forex_Strategy_Trader
This namespace is no longer used. We use the following namespaces for all indicators in all three programs.
using System;
using ForexStrategyBuilder.Infrastructure.Entities;
using ForexStrategyBuilder.Infrastructure.Enums;
using ForexStrategyBuilder.Infrastructure.Interfaces;
namespace ForexStrategyBuilder.Indicators.Store
{
public class DateFilter : Indicator
{
...
}
}