dboichenko

Get intraday extended data

dboichenko Mis à jour   
If you have interacted with Pine for some time, you probably noticed that if you are using DWM resolutions, you will not be able to obtain complete data from the extended intraday ticker using the usual functions request.security() and request.security_lower_tf(). This is quite logical if you understand the principle of mapping data from the secure context to the main one. The main reason is the different opening and closing times of the intraday data with extended clocks and DWM.

This script visualizes one of the approaches to solving this problem. I will briefly describe the principle of operation:

For example, take the symbol NASDAQ:AAPL.
Our main resolution is 1D, but we want to receive extended data from a 4-hour interval. The daytime bar opens at 09:30 and closes at 16:00. The same period at a resolution of 4 hours covers 4 bars:
04:00 - 08:00
08:00 - 12:00
12:00 - 16:00
16:00 - 20:00
So, if we use the request.security_lower_tf() function, we will not get the bars 04:00 - 08:00 and 16:00 - 20:00 because their closing times are not within the range of the main context (09:30 - 16:00).

If we use the request.security() function, we will get the bar 04:00 - 08:00, but we will not get the bar 16:00 - 20:00 because its closing time will be in the future, and it is impossible to get values from the future.

So, what I propose is to use the upgraded request.security() function, inside which another function will be executed, storing all the bars in a var array and putting the post-market bars in the array of the next day. Next, all we have to do is isolate these bars, place them in the previous array, and remove them from the current one.

I visualized the received data simply as text, but you can do it differently using the proposed mechanism.

In order for everything to work, you need to fill in the inputs correctly:
"Symbol for calculate" - This is the symbol from which we will receive extended data.
"Intraday data period" - The period from which we will receive extended data.
"Specify your chart timeframe here" - This is an input that allows you to operate with data from the main context while being inside the secure one. Enter your current chart timeframe here. If there are problems, a warning will appear informing you about this.

If you want to use these developments, take the get_data() function, it will return:
1. the number of past items - it is useful for outputting values in real time, because it is not possible to simply delete them there, because they will always arrive and it is easier to make a slice with an indentation for this number
2. cleared object of type Inner_data containing arrays of open, high, low, close, volume, time, time_close intraday data
3. its same value from the previous bar
Notes de version:
bugs fix
Notes de version:
changed input logic on security
Notes de version:
change comment
Notes de version:
improve
Script open-source

Dans le véritable esprit de TradingView, l'auteur de ce script l'a publié en open-source, afin que les traders puissent le comprendre et le vérifier. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais la réutilisation de ce code dans une publication est régie par le règlement. Vous pouvez le mettre en favori pour l'utiliser sur un graphique.

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.

Vous voulez utiliser ce script sur un graphique ?