dboichenko

Get intraday extended data

dboichenko تم تحديثه   
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
ملاحظات الأخبار:
bugs fix
ملاحظات الأخبار:
changed input logic on security
ملاحظات الأخبار:
change comment
ملاحظات الأخبار:
improve
نص برمجي مفتوح المصدر

قام مؤلف هذا النص البرمجي بنشره وجعله مفتوح المصدر، بحيث يمكن للمتداولين فهمه والتحقق منه، وهو الأمر الذي يدخل ضمن قيم TradingView. تحياتنا للمؤلف! يمكنك استخدامه مجانًا، ولكن إعادة استخدام هذا الكود في منشور تحكمه قواعد الموقع. يمكنك جعله مفضلاً لاستخدامه على الرسم البياني.

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.

هل تريد استخدام هذا النص البرمجي على الرسم البياني؟