bharatTrader

Fixed Reference Ratio Chart

This study does a division ("/") between the ticker to benchmark symbol. It works only on day timeframe.

Often referred to as spread charts or ratio charts this is often used to measure the strength and performance of a script vis-a-vis a benchmark index. In this study, the comparison is plotted from a fixed reference session. On the current bar, the percentage change of the current ratio to the reference ratio is displayed as a label down icon, rounded to nearest integer. There are options to plot either a candle plot or line plot. The reference date can also be changed from the input dialog.

In the example above, 13-Feb-2020 is chosen as the reference date. Ratios are plotted from this reference date onwards. At the latest bar, the "60%" displays the percentage difference between ratio on 13-Feb-2020 and current date, 09-Sep-2020. This means RELIANCE performed 60% better than the benchmark NIFTY50 since 13-Feb-2020.
版本注释:
  • Added an input option to hide label
版本注释:
  • Fixed a small typo
  • Fixed Moving Average plot
版本注释:
  • Added an option for zero percentage line. This will help visualise the actual change in percentage.
版本注释:
  • Now %change is correct up to 2 places of decimal
版本注释:
  • Added separte option for "0%" label input control
版本注释:
  • Removed option to display "0%" label
  • Added label to display no valid trading session date in input
  • Made default option to true, to display the zero line
版本注释:
  • Moved the %change label to right, so that it is clearly observed
版本注释:
  • No trading session found error now label down
  • A temporary change on short title. :)
版本注释:
  • A little more change in title :)
版本注释:
  • Shortened the short title :)
  • Made "Line" as default plot option
  • Option to plot historical CRS, beyond reference date

The main highlight of this release is the ability to plot historical CRS beyond the reference date selected. This will help in doing a historical analysis of the scrip against the benchmark without the need to set the reference date. This is an advanced feature and therefore turned off by default.
版本注释:
  • Fixed default colour of historical CRS to fuchsia instead of white. Will help those not using the dark theme.
版本注释:
  • Added %change in Price to the label, along with %CRS change from reference
  • Default line width of CRS plot is 2
  • Minor cosmetic changes
版本注释:
  • Added "Performance Trend" plot. Read below for details.
  • Changed the short title of the indicator
  • Changed the name of Zero line to Reference line


The Performance Trend Plot: This option plots the difference (in %) in the CRS (symbol/benchmark) ratio from the reference date on a day-to-day basis till the current session. The plot is made as a histogram with color coding that shall be explained in the document later on. It also displays additional information.

The Absolute Zero line is the absolute zero of the %change in CRS from the reference date. Therefore any bar (Green or Red) above the zero line indicates that the symbol closed with a higher change in CRS from the reference date CRS on that date. Similarly, any bars being plotted below the reference line indicate that the CRS change was negative on that date with respect to reference date.

For the mathematically inclined, the formulae are:
CRS on a particular day = symbol close / benchmark close
%CRS Change = (CRS today - CRS reference day) / CRS reference day * 100

So if CRS today > CRS reference day ===> Plot above zero line
And if CRS today < CRS reference day ===> Plot below zero line

Note that when in the “Performance Trend” mode, the indicator removes the “Reference Line” that is plotted in the Line and Candle plots. Instead the absolute zero line is taken as a reference in this mode.

Color Coding
There could be 4 colors for the bar, irrespective of whether they are above or below zero line.

  • The color is a shade of green (dark and bright) when the close of the symbol is greater than or equal to the close of the symbol the previous day.
  • The color is a shade of red (dark and bright) when the close of the symbol is less than the close of the symbol the previous day.
  • A bright color (red or green) is applied when the trend of the performance (%CRS change) is going upwards. I.e. Current day %CRS change > Previous day %CRS change
  • A dark color (red or green) is applied when the trend of the performance (%CRS change) is going downwards. I.e Current day %CRS change < Previous day %CRS change

Label Information
By default, the label in blue is displayed. This label displays (Delta CRS) the %CRS change as of today with respect to the reference date in % terms. Delta Price is the %Price change as of today with respect to the reference date in % terms.
Additional information is displayed when the mouse is hovered above the blue label. They are described as below:
  • CRS: Current CRS value
  • Eq Price: The Equilibrium Price as of today
  • Delta Eq Price: The difference in Eq Price and Current Price in % terms.
Eq Price is the equilibrium price, the price at which the symbol would be at zero RS value with reference. For more details on equilibrium price refer to this link.
版本注释:
  • Fixed a bug around Delta Eq Price computation
版本注释:
  • Fixed Delta Eq. Price (again) :)
If Delta Eq. Price (%) negative, it indicates that the price of the scrip should fall by this much % as of today in a future date if it has to come down to CRS ratio of Reference Date. If it is positive, it means that the scrip needs to rise by this much % to reach the CRS of Reference date.
版本注释:
  • Changed default reference data for RS 3-July-2020
版本注释:
  • Support for the newly introduced Time Input in Trading View (TV)
  • CRS Trend Indication based on Rate of Change (inbuilt roc method of TV)
  • Support on all time frames, limited to maximum loadable bars by TV for a resolution

Time Input
Instead of those dreary text boxes we now have an actual datetime input. The timezone is automatically adjusted to the selected exchange timezone. No changes are required unless, you know what you are doing.

CRS Trend
The indicator now calculates internally the CRS trend. This is done by calculating the RateOfChange (roc) method of TV. The length for lookback of roc is user input, 13 by default. The output is displayed as "Up" or "Down" on the label description. "Up" indicates that the trend of the CRS since the roc lookback is "positive". "Down" indicates that the trend of the CRS since roc lookback is "negative".

Time Frame Support
The indicator now adjusts to all timeframes, Daily, Weekly, Monthly, Hourly, Minutes. Seconds is not tested. In case the exact reference date is not matched (for example ARS reference date is 3rd July and a Weekly timeframe is selected) then the next candle after the input reference date is selected as reference. The "adjusted" reference date is indicated in the label text. In case of lower timeframes, if the last available bar is before the input ARS reference date, then a warning is displayed as a valid percentage deviation cannot be calculated. In this case only the CRS trend and the plot is displayed. To mitigate this, either shift to a higher timeframe that can include the reference date or set the reference to a closer date.
版本注释:
  • Added label color
The color of the label is set based on Delta CRS > Reference Line. It helps in easy and quick identification, especially if using on mobile device (Not recommended, though).
版本注释:
  • Changed the trend indication calculation
The CRS Trend ("UP" or "Down") earlier was calculated using the RoC method. It is now updated to use the linear regression slope instead. A negative slope indicates "Down" and a positive slope indicates "UP"
版本注释:
  • Coloured bubbles on CRS Line (aka RS Line)
  • Soothing colours for label and text on it
Bubbles will be displayed on the CRS line with the following legend:
Orange: New high of CRS Line
Green: CRS Line crosses over the CRS mean line from below. CRS mean length is defined at "Moving Average Length" input
Maroon: CRS Line crosses below the CRS mean line from above.
Blue: Consistently rising CRS values for look-back period. Defined from input, max 500 bars only.

Also applied some smoothing to the colour of the labels and the label text for visual peace.
版本注释:
  • Fixed colour combination of label text
  • Small typos in input box
版本注释:
  • Changed ARS default date to reflect new ARS date from today
  • Removed an experimental feature leak
版本注释:
  • Overhauled the input dialog, using the latest formatting options introduced in pinescript
  • Possible to select custom colors for the label box and text color
  • Separated MA X'over bubbles from RS high and RS rising bubbles
Now, the green and the maroon bubbles (MA X'over) bubbles have to be enabled from the input box. Both the options must be turned on to view the MA X'over bubbles. If only interested in viewing the RS High and RS rising bubbles, select the "Show Bubbles on CRS Line" only.
版本注释:
  • Some strange and unexplained problem with historical CRS plot.
Fixed by fluke :)
版本注释:
  • Fixed the overlapping label box, especially irritating during smaller time frames.
版本注释:
  • Change default reference date (aka ARS Date)
  • Current CRS color to purple

受保护脚本
该脚本是闭源发布的,您可以自由使用它。您可以收藏它以在图表上使用。您无法查看或修改其源代码。
免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其他类型的意见或建议。请在使用条款阅读更多信息。

想在图表上使用此脚本?