What's wrong with this Highest ?

Questions about MultiCharts and user contributed studies.
Automeq
Posts: 108
Joined: 16 Apr 2014
Has thanked: 15 times
Been thanked: 1 time

What's wrong with this Highest ?

Postby Automeq » 18 Sep 2019

If I plot this in a 30 minutes chart:

Code: Select all

plot2( highS(1) - openS(1) ); //green

plot3( openS(1) - lowS(1) ); //red
I get a straight line, for each plot, during the entire session, which is what we expect.

However, when I plot this:

Code: Select all

plot1( Highest( highS(1) - openS(1) , openS(1) -lowS(1) ) ); //blue
Sometimes I don't get a straight line. How is that possible knowing that the arguments of the Highest are the same during the entire session ?

Highest.JPG
(184.4 KiB) Downloaded 158 times

User avatar
Anna MultiCharts
Posts: 560
Joined: 14 Jul 2017
Has thanked: 42 times
Been thanked: 140 times

Re: What's wrong with this Highest ?

Postby Anna MultiCharts » 25 Sep 2019

Hello, Automeq!

The Highest function returns the highest price over a range of bars.
http://help.TS.com/09_01/tsde ... kanchor142
The second parameter is Len (number of bars). We found it surprising that your Len = openS(1) -lowS(1) (difference of Open and Low prices of the previous session).
The following script will work correctly:

Code: Select all

var: vrs1(0), vrs2(0);
vrs1= highS(1)- openS(1);
vrs2 = openS(1) -lowS(1);

plot1( Highest(vrs1 , vrs2 ),"max", blue);
//plot1( maxlist(vrs1 , vrs2 ),"max", blue);

plot2( vrs1,"h-o", green);

plot3( vrs2 ,"o-l",red);
While reviewing this case we found the improper working of the same script if vrs1 and vrs2 are not used, which is why they shouldn’t be omitted from our sample code. This and the strange value of Plot1 near the blue arrow on your screenshot is to be fixed in the next MultiCharts version.
Sometimes I don't get a straight line. How is that possible knowing that the arguments of the Highest are the same during the entire session ?
If you use Highest in this line:

Code: Select all

plot1( Highest(vrs1 , vrs2 ),"Higest", blue);
then the value of Plot1 will change during the session. Because vrs2 is the number of bars back from the current one, and Highest(vrs1 , vrs2 ) is the last maximum of vrs1 at the vrs2 distance from the current bar.
When the range of bars for Highest includes bars from different sessions and vrs1 increases from session to session, then Plot1’s value is expected to change.

If you expect Plot1 not to change during the session, then instead of Highest you should use MaxList, then the value of the plot won’t change:

Code: Select all

plot1( maxlist(vrs1 , vrs2 ),"Higest", blue);
You can uncomment the line in our example and check the result.


Return to “MultiCharts”