Help with Custom Indicator Not Showing in cTrader

Created at 11 Sep 2024, 19:43
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
TH

thabangpromise21

Joined 09.09.2024

Help with Custom Indicator Not Showing in cTrader
11 Sep 2024, 19:43


Hi everyone, I’m working on a custom indicator in cTrader that combines multiple indicators (MFI, RSI, ADL, VWAP, and ATR) into a Market Demand Index (MDI). However, I’m facing issues with the indicator not showing on the chart. Here’s what I’ve tried so far:

  • I’ve initialized all the required indicators (Money Flow Index, Relative Strength Index, etc.).
  • Used AverageTrueRange with MovingAverageType.Exponential.
  • Output series is correctly declared with [Output("MDI Smooth", LineColor = "Green")].
  • I’m calculating and smoothing the final MDI index using a 5-period Exponential Moving Average.
  • Added debug Print statements to check the values, but the indicator still doesn’t show up on the chart.
  • Checked that there are enough bars (14+) for the calculation.

Things I’ve checked:

  • Debugged with Visual Studio to verify variable values, and they seem correct.
  • Ensured I’m not plotting NaN or zero values.
  • I’m plotting in a separate indicator panel (IsOverlay = false).
Any advice on what might be causing the issue, or suggestions on further troubleshooting steps?

[Output("MDI Smooth", LineColor = "Green", PlotType = PlotType.Line)]
public IndicatorDataSeries MdiSmooth { get; set; }

protected override void Initialize()
{
    mfi = Indicators.MoneyFlowIndex(14);
    rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 14);
    atr = Indicators.AverageTrueRange(14, MovingAverageType.Exponential);
    mdiEma = Indicators.ExponentialMovingAverage(MdiSmooth, 5);

    adlSeries = CreateDataSeries();
    vwapSeries = CreateDataSeries();
}

public override void Calculate(int index)
{
    if (index < 14) return;

    double typicalPrice = (Bars.HighPrices[index] + Bars.LowPrices[index] + Bars.ClosePrices[index]) / 3;
    double vwap = (typicalPrice * Bars.TickVolumes[index]) / Bars.TickVolumes.Sum(14);
    vwapSeries[index] = vwap;

    double adl = ((Bars.ClosePrices[index] - Bars.LowPrices[index]) - (Bars.HighPrices[index] - Bars.ClosePrices[index])) / (Bars.HighPrices[index] - Bars.LowPrices[index]) * Bars.TickVolumes[index];
    adlSeries[index] = adl;

    double mdi = (normMfi * 0.3) + (normRsi * 0.2) + (normAdl * 0.3) + (normVwap * 0.2);
    MdiSmooth[index] = mdiEma.Result[index];
}


Thanks in advance for your help!

@thabangpromise21
Replies

PanagiotisCharalampous
12 Sep 2024, 09:12

Hi there,

Please share with us the complete indicator's code so that we can run it as well.

Best regards,

Panagiotis


@PanagiotisCharalampous

firemyst
18 Sep 2024, 05:47

Could part of your problem is the mdiEma values are based on the calculated values of the MdiSmooth;

But then your MdiSmooth values are based on your mdiEma.

You seem to have an infinite recursion. It's like asking, what came first, the seed or the plant?


@firemyst