franzb0

Join data and union of 2 hystorical markets


How to create a union from two contiguous Tradingview tickers (series)

Francesco Marzolo March 18, 2021


Go to the older ticker of the two, for example CME: SP1! and open it on Tradingview.

On the graph thus created, add this script.

In the indicator settings select the same ticker as the chart in Symbol1

while in Symbol2 the ticker from which to retrieve the most recent data, for example: SPX500


The operation this script does is examine each bar of the two tickers, where there is a value for the second it holds this one, where it does not exist in second ticker it keeps the value of the first one. This new series is called Merge. So now in the chart there will be 4 series:

- that of the original chart without script
- the same series loaded via script (Symbol1)
- series 2 of "new" data (Symbol2)
- the Merge series that "prefers" the Symbol2 data if present, otherwise it shows Symbol1

So now you have to change the visibility of the 4 series to see the differences:

- turn off the visibility of the chart indicator
- turn off the Symbol1 series in the script properties (old data only)
- switch off the Symbol2 series as well (only new data)
- switch on the Merge series (new data if existing, old if not present in the new ticker)



Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?