Peshocore

GMT Offset, without using security fn - showcase

Peshocore Mis à jour   
This script is a demo of how one can avoid the use of the request.security function and get values for a number of previous day's open/high/low/close
where the user can define a custom "start of the day" using the GMT input. This allows the user to be independent of the exchange timezone
that the security function uses internally.

Implications of this include:
Suppose you want to treat the start of your day as the NZX market open which is at 2000 UTC+0 and base you indicator calculations
on the NZK market midnight as opposed to the chart exchange timezone.
The indicator purpose is to showcase how that can be achieved in code.

If security function in the future is modified to accept a timezone parameter - obviously this code will no longer be needed as such.

We do two things here:
We plot the values for open high low close using the calc_ohlc_daysback as circles
Then we use the f_security function to get the same values but using security and plot them using solid lines
We do this both on the daily and weekly values.
What we expect to see is the lines matching thus proving that the calc_ohlc_daysback works correctly as compared to security function.

Note - the chart gmt default value is set to 0 which means the comparison will work correctly out of the box on exchanges that have weekend data.
The script is designed to work on intraday timeframes highest being 4 hour and lowest being 3 min
(programmatically the script is no bounded as sich to the intraday timeframe however if not enough data is present at a particular timeframe
values needed to display the lines will be null and hence the lines will not print.)
You can get the same results on other exchanges but might need to change the value of chart gmt
Script does not work on exchanges that have gaps on the weekend at this time

Now all of this can obviously be done with the security function - why go through the trouble? Well with security function you are bound to
the timezone of the exchange you are on. Doing it this way you are no longer bound by the exchange timezone and you can effectively change
the time at which the day starts independent of any exchange. Go ahead - change the GMT offset in settings


Future enhancements:
a) Deal with exchanges where "bar merge" is required - if possible (detect that an exchange does not have weekend data basically)
b) Deal with lower timeframes if possible (on the minute timeframe there is usually not enough data in the series to calc values several weeks back)
c) Make a library for this functionality - this will be optimal so one does not need to copy paste code.
d) Expand library to add GMT auto adjust (specifically around DST in different countries). Today this is a challenge as no relizble way exists to
extract the UTC offset from an syminfo.timezone given that syminfo.timezone returns text such as "America/New York"
For example - one might have 3 session thst they want to work with. Tokio, London and New York. Tokio does not follow DST so the market session starts at the same time all year round. London observes DST but at a different time from New York. So in order to have all this in the same chart and have it auto adjust is a bit of a challenge. With the DST offset functions - this is possible to do. (
Well, that is unless the awesome TV devs push out v6 where that is build in the security function (for it to accept a timezone offset other) in which case the code here will become useless.


Foot notes:
This script is inspired by Traders Reality indicator by @infernixx (developed by @plasmapug with additional modifications by @infernixx and @Peshocore)
Special thanks to @JayRogers for INSECURITY() which inspired the development of calc_ohlc_daysback
Notes de version:
fixed input text and grouping.
Updated calc bars back to calculate the bars back needed as opposed to hardcoding them
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 ?