Adding a custom indicator to Watchlist
How to add a custom indicator to Watchlist panel properly? This guide will show you a useful method using which you can easily add an indicator.
Ok, let’s imagine, you have created a custom indicator and it works correctly when you add it to the ‘Chart’. But you want to add it to the ‘Watchlist’ panel too. Yes, OptimusFLOW supports this feature. Open ‘Watchlist’ -> click on ‘Indicators lookup’ -> and… you can’t find it. Hmm, something is wrong. And two questions come up: “Why I can’t see it on the list?” and “How can I add my indicator to the list?”.
Well, the reason is that your indicator doesn’t implement special "IWatchlistIndicator" interface. This is the marker which is used for filtering content into ‘Indicators lookup’ in ‘Watchlist’.
public class Best_Indicator : Indicator, IWatchlistIndicator
… Best_Indicator code.
For example: OptimusFLOW platform has the built-in "Price Action Zones" indicator. It’s designed only for work on the ‘Chart’ panel because it uses custom drawing. It doesn’t implement this interface, and you can’t use it in the ‘Watchlist’.
Ok, let’s remember. Before adding the indicator to the chart you need to select ‘TimeFrame’ and ‘Depth of history’. But after adding an indicator to the ‘Watchlist’ you can customize input parameters and timeframe only. Hmm… “How does the Watchlist understand how deep the history needs to be downloaded?”.
Input parameters of any indicator on Watchlist panel
‘IWatchlistIndicator’ interface provides ‘MinHistoryDepths’ property which must return a minimal history depths value for the current indicator. You need to implement it correctly and that’s all.
public class DoubleSMA: Indicator, IWatchlistIndicator
[InputParameter("First SMA period", 0, 1, 999, 1, 1)]
public int FirstPeriod = 5;
[InputParameter("Second SMA period", 1, 1, 999, 1, 1)]
public int SecondPeriod = 10;
public int MinHistoryDepths => this.FirstPeriod + this.SecondPeriod ;
… DoubleSMA indicator code