Custom Indicator not moving as time passes
Created at 19 Apr 2022, 14:07
Custom Indicator not moving as time passes
19 Apr 2022, 14:07
Hello,
I have the below code for an indicator, to show USD strength based on 7 major pairs. But it is delayed to show the result and seems not moving along as time passes.
Please help and advise. Thank you. :)
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class StrengthAndWeakness : Indicator
{
[Output("USD", LineColor = "FFFF0005", Thickness = 2, PlotType = PlotType.DiscontinuousLine)]
public IndicatorDataSeries USD { get; set; }
private Bars EURUSD;
private Bars GBPUSD;
private Bars AUDUSD;
private Bars NZDUSD;
private Bars USDCAD;
private Bars USDCHF;
private Bars USDJPY;
protected override void Initialize()
{
EURUSD = MarketData.GetBars(Bars.TimeFrame, "EURUSD");
GBPUSD = MarketData.GetBars(Bars.TimeFrame, "GBPUSD");
AUDUSD = MarketData.GetBars(Bars.TimeFrame, "AUDUSD");
NZDUSD = MarketData.GetBars(Bars.TimeFrame, "NZDUSD");
USDCAD = MarketData.GetBars(Bars.TimeFrame, "USDCAD");
USDCHF = MarketData.GetBars(Bars.TimeFrame, "USDCHF");
USDJPY = MarketData.GetBars(Bars.TimeFrame, "USDJPY");
}
public override void Calculate(int index)
{
USD[index] = 200*( (1/EURUSD[index].Close)
*(1/GBPUSD[index].Close)
*(1/AUDUSD[index].Close)
*(1/USDCAD[index].Close)
*(1/NZDUSD[index].Close)
* (USDCHF[index].Close)
* (USDJPY[index].Close)
-137);
}
}
}
Capt.Z-Fort.Builder
20 Apr 2022, 03:24
RE:
Thank me, the problem has been resolved.
There are some bars gaps between the data series to the bars' index number. Get the gap value e.g gap_EURUDS and put them in the right place as below would fix the problem.
@Capt.Z-Fort.Builder