Problem on indicator performance
Problem on indicator performance
03 Nov 2021, 04:46
Hi support,
I have this screen pop up during having 4 indicators on my chart. Can you give me suggestion where/which area should I fine tune my custom indicators to eliminate this issue?
Thanks in advance.
Noppanon
Replies
kenneyy_eur
05 Nov 2021, 16:38
( Updated at: 05 Nov 2021, 16:59 )
RE: I have the same issue with cTrader Desktop 4.1 . Can cTrader tell us what criteria they have used in determining if an indicator has performance issues?
Here is my code
[Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
public class KF_GHL_v3 : Indicator
{
[Parameter("Period", DefaultValue = 10)]
public int Period { get; set; }
[Parameter(DefaultValue = "High")]
public DataSeries SourceH { get; set; }
[Parameter(DefaultValue = "Low")]
public DataSeries SourceL { get; set; }
[Parameter(DefaultValue = "Close")]
public DataSeries SourceC { get; set; }
[Parameter("Timeframe", DefaultValue = "Minute5")]
public TimeFrame Timeframe { get; set; }
[Parameter(DefaultValue = MovingAverageType.Simple)]
public MovingAverageType MaType { get; set; }
[Output("Result")]
public IndicatorDataSeries Result { get; set; }
private MovingAverage _smaHigh;
private MovingAverage _smaLow;
private int Hld, Hlv;
private Bars bars;
protected override void Initialize()
{
if(this.Timeframe != this.Chart.TimeFrame)
{
bars = MarketData.GetBars(Timeframe);
while (bars.OpenTimes[0] > Bars.OpenTimes[0])
bars.LoadMoreHistory();
SourceH = bars.HighPrices;
SourceL = bars.LowPrices;
SourceC = bars.ClosePrices;
}
_smaHigh = Indicators.MovingAverage(SourceH, Period, MaType);
_smaLow = Indicators.MovingAverage(SourceL, Period, MaType);
}
public override void Calculate(int index)
{
var index1 = this.Timeframe == this.Chart.TimeFrame ? index : bars.OpenTimes.GetIndexByTime(Bars.OpenTimes[index]);
if (index1 < 1) return;
double close = SourceC[index1];
double smaHigh = _smaHigh.Result[index1 - 1];
double smaLow = _smaLow.Result[index1 - 1];
if (close > smaHigh)
Hld = 1;
else
{
if (close < smaLow)
Hld = -1;
else
Hld = 0;
}
if (Hld != 0) Hlv = Hld;
switch(Hlv)
{
case -1: Result[index] = smaHigh; break;
case 0: Result[index - 1] = double.NaN; break;
case 1: Result[index] = smaLow; break;
}
}
}
It is simply plotting a moving average line of a higher timeframe than the current chart. This is needed when trading!
When this indicator is placed onto a XAUUSD M5 chart and set to the following parameters
Period: 272
MaType: TimeSeries
Timeframe : 15 minutes
Then run back test, that's when the issue occurs
@kenneyy_eur
PanagiotisCharalampous
08 Nov 2021, 08:27
Hi noppanon,
Please skip the following part of the code during backtesting and let us know if this resolves the issue
while (bars.OpenTimes[0] > Bars.OpenTimes[0])
bars.LoadMoreHistory();
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
... Deleted by UFO ...
amusleh
03 Nov 2021, 07:58
Hi,
Your Stochastic_Flipe_Sep-30 indicator causing this issue, we can't help you unless you post the code of that indicator.
If an indicator/cBot is causing such as issue the only way you can fix it is to tweak the indicator/cBot code.
@amusleh