TradingView
twingall
7. Jul. 2022 20:03

Overlay Mini Plot(s) of Correlated Asset(s) 

Euro Fx/U.S. DollarFXCM

Beschreibung

Overlay a small plot of a correlated asset of your choosing. Shrink/expand, Set vertical and horizontal position, plot multiple mini-plots via duplicate indicators with varied settings.

Plots the last X bars of any asset; including the live candle currently painting
Useful for low time frame trading when you want to see correlated asset price movement right alongside the price movement you're watching.
Useful for quick and simple comparisons; when you don't want the clutter of split screen or multi-pane view.
Useful for backtesting.
Price scale agnostic; just plots the shape of the recent price action, with several optional labels: Asset+timeframe | Live Price | Highest price over X bars | Lowest price over X bars.
Works fine with all the assets i've tested it on.

~~User inputs~~
-number of bars to paint.
-horizontal offset: plot to right X bars or to left X bars
-vertical offset: shift up or down, shrink or expand; by using 2 'spacer' inputs
-color/transparancy of candles and price labels.
-width (pixels) of candle bodies.
-choose to display price labels or not
-choose to display asset label or not

~~Tips~~
--Add several of these indicators; changing the vertical 'Shift/Shrink' settings on each to visually separate them.
--In the above chart or EurUsd, there are three indicators =>> three mini-plots overlaid: DXY, EurGbp and GbpUsd. Using the following settings for Space Above:Space Below: DXY- 0.1:4.5 | EurGbp- 1.8:1.8 | GbpUsd- 4.5:0.1
--the more you add, the more you'll have to vertically shrink the plots
© twingall

Versionshinweise

fixed rounding issue with live price label printed price: now shows appropriate significant figures

Versionshinweise

-updated to show multi timeframe: User select higher timeframe. Note that when using HTF option this will only plot 10 bars

Versionshinweise

-updated some names/titles for clarity

Versionshinweise

-update chart to show multi-timeframe

Versionshinweise

(cleaned up, removed old code)

Versionshinweise

-add option to auto plot on current ticker symbol

Versionshinweise

Choose vertical position (top/middle/bottom)

Versionshinweise

Cleaned up settings panel, added groups

Versionshinweise

-added option to show / not show mini plots when base asset market is closed (i.e. backtesting use-case Vs live trading use-case )
Kommentare
TradeShotsPro
Very Nice Script.. Thank you .. :)

Some improvements may be if anyone could incorporate:

1. Option to display 3 assets
2. Option to adjust timeframe for other assets.
twingall
@TradeShotsPro, Updated to work on multi timeframe now.. Note that it only shows 10 bars userInputTimeframe option. You can add more to the code (max of 40x security calls, but will be slower to load the more you add)

As regards plotting 3 assets, not doable without fundamental change in the code/ different method.
TradeShotsPro
@twingall, Thank You for the update :)

I found some issues while using different timezones ..... i.e
1. Open a non-active ticker chart
2. Now open an active chart i.e DXY (active approx. for full day) on different timeframe .........Then the candles are not similar for overlay chart.

and once again Thankyou .... I was missing the HTF feature very much .... Have a Great DAY !!
twingall
@TradeShotsPro, thanks will look into it
twingall
@twingall, ah i see; i don't think it has to do with timezones. Just that it will treat the last bar of overlay plot as the one that occured when the base asset stopped trading. So on ZW (wheat); stops trading at 14:00 NY time; and =>> the DXY overlay shows the last bar as the 14:00 DXY bar, even when there are more bars for DXY..
No easy fix for this, Keep an eye on the live price for activity on overlay. as clue to this happening.. Also maybe switch to Extended trading hours (ETH) over RTH where possible, may mitigate this some.
twingall
@TradeShotsPro, actually there seems to be an easy fix, will test it out over time and maybe add it as option.
using 'barstate.isrealtime' you can stop it plotting overlay mini plots if/when the base asset is not live. If you want to try it out you can do the following:
line 54 add: if barstate.isrealtime
Indent by one tab lines 55-76
append to line 89: and barstate.isrealtime
jakubmarcinik
Hey @twingall, Thank you for this amazing script. I wanted to ask you if it would be possible to show in bar's style instead of candles. Thank you!
twingall
@jakubmarcinik, No I'm afraid i can't see a way to do this without a completely different approach. Thanks, T
ronaldmcisaac
timesaver. thank you. great work.
Mehr