Bug in Extremum function  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
jarym
Posts: 58
Joined: 16 Feb 2015
Has thanked: 14 times
Been thanked: 6 times

Bug in Extremum function

Postby jarym » 29 Mar 2015

I've noticed the Extremum functions (e.g. ExtremeLow) do not behave as expected. I used dotPeek to have a look and it appears that the offset is being ignored during calculation:

Code: Select all

public static T Extremum<T>(this ISeries<T> seria1, int length, int offset, IComparer<T> comparator, ref int extremeBar)
{
if (length <= 0)
throw new ArgumentOutOfRangeException("length", "Parameter should be > 0.");
int num = 0;
T y = seria1[0];
for (int index = 1; index < length; ++index)
{
if (comparator.Compare(seria1[index], y) > 0)
{
y = seria1[index];
num = index;
}
}
extremeBar = offset + num;
return y;
}
If I'm not mistaken, surely the for loop should or the access of seria1 should adjust for the offset parameter.

Update: I believe the code should look something like this *UNTESTED*:

Code: Select all


public static T Extremum<T>(this ISeries<T> seria1, int length, int offset, IComparer<T> comparator, ref int extremeBar)
{
if (length <= 0)
throw new ArgumentOutOfRangeException("length", "Parameter should be > 0.");
int num = [b]offset[/b];
T y = seria1[[b]offset[/b]];
for (int index = 1[b]+offset[/b]; index < length[b]+offset[/b]; ++index)
{
if (comparator.Compare(seria1[index], y) > 0)
{
y = seria1[index];
num = index;
}
}
extremeBar [b]= num;[/b]
return y;
}

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Bug in Extremum function

Postby Henry MultiСharts » 30 Mar 2015

Hello jarym,

Please send us (support@multicharts.com) the following information for further analysis:
- workspace you are using;
- in QuoteManager select the symbols you are using, make a right click on it->Export data->Export instrument (without data). Send us the QMD export file for analysis;
- in PowerLanguage .NET editor->File->Export->export the studies you are using for replicating this behavior; send us the pln file;
- specify the version and build number of MultiCharts you are running (in MultiCharts go to Help tab-> About);
- instructions for replicating the error;
- specify the expected values for the study.

jarym
Posts: 58
Joined: 16 Feb 2015
Has thanked: 14 times
Been thanked: 6 times

Re: Bug in Extremum function

Postby jarym » 30 Mar 2015

Hello jarym,

Please send us (support@multicharts.com) the following information for further analysis:
- workspace you are using;
- in QuoteManager select the symbols you are using, make a right click on it->Export data->Export instrument (without data). Send us the QMD export file for analysis;
- in PowerLanguage .NET editor->File->Export->export the studies you are using for replicating this behavior; send us the pln file;
- specify the version and build number of MultiCharts you are running (in MultiCharts go to Help tab-> About);
- instructions for replicating the error;
- specify the expected values for the study.
Hi Henry,

I've created my own version of the function and it is behaving according to my expectations. I've tested it and so far I've no problems with it. It is the same code that I posted in my update above.

I won't be sending in a support request because it isn't something I need MultiCharts to fix however you are welcome to verify the behaviour of your own function and use my code if you determine it is not behaving as you yourselves would expect.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Bug in Extremum function  [SOLVED]

Postby Henry MultiСharts » 31 Mar 2015

This issue will be fixed in MultiCharts .NET 9.0 Release 7.


Return to “MultiCharts .NET”