Relative performance log chart

I used the relative performance chart in the basic charts folder and added chartLogarithmic to the code and set it in the chart parameters, but it looks as if the Y (price axis) is still Linear. I can export to Excel, I like the look of the AB charts.
Here is the code.


_N( TickerList = ParamStr("Tickers", "^DJI,MSFT,GE") );
NumBars = 20;
fvb = Status("firstvisiblebar");
Plot( 100 * ( C - C[ fvb ] ) / C[ fvb ], Name(), colorBlue );
for( i = 0; ( symbol = StrExtract( TickerList, i ) ) != ""; i++ )
 fc = Foreign( symbol, "C" );

 if( ! IsNull( fc[ 0 ] ) )
   Plot( 100 * ( fc - fc[ fvb ] )/ fc[ fvb ], symbol, colorLightOrange + ( (2*i) % 15 ), styleLine );
PlotGrid( 0, colorYellow );
_N( Title = "{{NAME}} - Relative Performance [%]: {{VALUES}}" );

Thank you for any help.

It is happening because of the first Mode = 0 parameter of SetChartOptions().

SetChartOptions( 1, chartShowArrows|chartShowDates|chartLogarithmic );

Mode = 1 (always) overwrite previously set chart pane options, Mode = 0 does not.

1 Like

Thank you Cougar. I changed the Chart parameters as you suggested, but the Y axis is still linear. No worries, I'm just going to export the lines to Excel and chart it there.
Thanks again!

You're welcome!

Are you sure, we concur at characteristics of Linear v/s Log scale?

[Right click on image to open it on a New Tab for better view]

Previously shared recommendation works, here is proof:

Chart scale type can also be changed from Parameters -> Axes & Grid:

It is like calling an orange painted Apple - an Orange - as it's colored orange. Because, I've no capacity to introspect or any intensity to explore true reality.

This is not customer service where you would expect, "customer is always right!".

Rather this is an open constructive forum where newcomer, longtimer AmiBroker users participate to help each-other, share knowledge.

We invest time in producing an appropriate response to all our queries with sole intention to spread awareness or learn tons of features this amazing software offers. So, it becomes necessary to substantiate your counter-question or contradiction with "evidence", otherwise, you are simply propagating USELESS notion(s) to others and also disrespecting the person who meticululousy architect every nitty-gritty of it for over 2 decades with utmost care.


P.S. Captain James Cook, an 18th century cartographer, explorer, author of an exciting book Captain Cook's Voyages once wrote and I quote, "When your mind tries to verify a preconceived notion, you can miss the obvious".

1 Like

Just WOW! Talk about preconceived notions. Look, I am not knocking the great and venerable AmiBroker. I have been using it for over 20 years. Here is the difference between Linear and Log defined here that I am looking for:

  • A linear scale plots data points using a unique unit value to give an equal vertical distance between values. On the other hand, a logarithmic chart scaling plots using percentage change as the distance between data points.

I was simply looking to see if a log scale such as is found in Excel (defined above) can be done here. Now I may be wrong, and not seeing your example for what it is, but it looks as if the price scale in each example is evenly spaced. I followed your instructions and I see the chart change slightly, like in your example, BUT when plotting the SPY vs a 60/40 Buy and hold portfolio the price scale stays linear (evenly spaced). Again I am not criticizing AmiBroker, I do a lot of my finished work in Excel and it is a one click format there and for this project I am time crunched.
If you or anyone can show an example of the relative strength of two issues that have drastically different prices using the percentage change for the distance between data points, I would be grateful.

Thanks again for your help.

Seriously, what good would it do to have a Relative Performance chart in Log scale? Relative Performance makes sense linearly as the comparisons are in percentage terms.

It was implied several times:

To begin with, I asked myself, is he not seeing "Warning 902 can not plot a chart in logarithmic scale as a data set contains negative value(s)" red-colored message in AB chart upon loading that Relative Performance code in Log scale. :face_with_raised_eyebrow:

In my first response, if I would've stated that natural logarithm is same everywhere (including Excel) and log( -negativeInteger ) has an imaginary part (i) that results as a complex number, this conversation would've diverted to a tennis match on how you can plot Relative Chart in Excel with "single-click" and not in AB.

What you consider as Logarithmic Relative Chart in Excel, is also Linear!

While plotting Relative performance, -ve integers (including 0s) are bound to occur. Changes for AmiBroker v5.67.0 (as compared to 5.66.0) reads:

a new "Warning 902 can not plot a chart in logarithmic scale as a data set contains negative value(s)" message is displayed on attempt to use log scale with negative data and the chart is plotted in linear scale instead.

Took this detour to ensure that you see "Warning 902 can not plot a chart in logarithmic scale as a data set contains negative value(s)" but still ignore it. That's why I previously quoted Captain Cook, "When your mind tries to verify a preconceived notion, you can miss the obvious".


You're welcome, cheers! :slight_smile:

1 Like

Log scale may only be used for data greater than zero, as such it can’t be used for percent change as change can be negative. Trying to use log scale for negative or zero data will fail.