Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Coding required to create custom Study and adjust existing Study in SC
Hi all, I need a new Study created and an existing Study modified for SC.
New Study: create a Daily chart using intraday data.
I use IB for brokerage & data with SC for Asian markets. The Daily data is unreliable - volume is randomly offset by a day and chart doesn't show yesterdays daily bar or the most recent overnight trading data. The intraday data however seems to be reliable and can be used as a basis for creating a Daily chart. I tried a 1440min chart but it creates 6 bars per week (Fri/Sat overnight trading is a separate bar) and Day labels are offset by a day (ie Monday is labelled as Sunday etc). The Study needs to create a Daily bar chart (5 bars - Monday to Friday) using intraday data with days labelled correctly. Volume must also be accurate for when volume indicator is added to the chart.
Existing Study modified: Zig Zag Cumulative Volume doesn't refresh properly
The indicator generally works well but doesn't re-calculate "live" (or gets miscalculated along the way) and constantly needs refreshing. There is an Input to "Calculate New Values on Bar Close" which SC suggests to set to 'Yes' as a solution, however the current bar's data is treated as separate to previous data until the close and so doesn't keep the indicator updated "live". This appears like a simple issue of Study behaviour but may actually be quite complicated to resolve. The Study needs to calculate the Zig Zags live as the current bar is unfolding and either add the current bar's volume to existing Zig Zag or in the case of a valid reversal, create a new Zig Zag including any prior bars which are also in the same direction of the reversal.
I'm not sure how complicated the above may be to code but if you think you're able to assist please reach out to discuss further.
Thanks
Can you help answer these questions from other members on NexusFi?
A 'daily' chart can be created from intraday data:
- Set 'Chart Data Type' to 'Intraday'
- Set 'Bar Period Type' to 'Days-Min-Sec-MS per bar'
- Set 'Bar Period Value' to 1-0-0
- Set Session times to 00:00:00 to 23:59:59
(these times must correspond to the timezone of the traded market, and the chart's timezone setting, both of which must me the same.)
- Set 'Weekend data' to 'Do not load weekend data'
One solution would be to add the Chart Recalculation - Periodic study.
Chart Recalculation study works well for keeping Zig Zag accurate. I wasn't aware of this study, so thanks!
I experimented with session times for the Daily chart and the other settings but still can't get the right result...the specific market in question is the Mini Hang Seng futures.
- Setting sessions to 00:00:00 to 23:59:59 removes the weekend bar but daily bar consists of half of what should be todays bar and half of yesterdays bar (ie the daily bar data is shifted back by half a trading day), so not what I need. (Chart was already set to UTC+8 HKT)
- Setting sessions to 17:15 to 16:29:29 (to match actual trading) gets close to the result and is mostly correct. Labelling is offset by 1 day (ie Monday is labelled Sunday etc - could live with this) but more importantly it chops off Monday's evening session trading. I think this is where the issue is as Monday's Daily bar actually spans 4 days: from Fri 17:15 to Sat 02:00 for Evening session, and Mon 09:15 to 16:30 for Day session with Sunday (no trading) in between. This is unlike the US markets where Monday's Evening session is from Sunday 18:00 til Day session open at 09:30 (NY time).
Any ideas how I might overcome this hurdle?
I've attached a picture showing 3 different charts for clarity - 1) Trading View chart with correct data, 2) SC chart with session time 17:15 to 16:29:29 and 3) SC chart with session time 00:00:00 to 23:59:00. SC Daily charts
Sierra Chart Daily bars are created from *.dly files
Intraday bars are created from *scid files
The latter cannot be made to always match the former, but with trial and error, you can get close.
You might need to 'Use Evening Session'.
It is unknown how TradingView combines these data, to get what you perceive is the accurate version.
I don't think you should have the session times as 00:00:00 to 23:59:59.
The evening sessions finishes at 3 AM. Thats part of the previous days trading.
I agree, using 00:00:00 to 23:59:59 doesn't give the correct result.
So I'm still left with not being able to create an accurate intraday Daily chart in SC using Session time manipulation etc.
What's next? Do I need to have a Study coded to do this? Does anyone know someone who can assist with this? (I have no coding knowledge whatsoever).
BTW - to confirm intraday data is a valid substitute for a Daily chart, I manipulated intraday data in Excel to create Daily OHLCV data and compared this to TradingView and they are very close with only minor discrepancies - but totally acceptable.
If you set the Intraday Data Only chart session times to 08:45:00 to 02:59:59, it closely matches the Sierra Chart Historical Daily OHLCV bars.
Chart Time Zone: Hong Kong UTC +8
Chart Data Type: Intraday Data Only
Bar Period Type: Day-Min-Sec
Bar Period Value: 1-0-0
New Bar At Session Start: Yes
Weekend Data: Do Not Load Weekend Data
Yes, SC Historical Daily bars match TradingView, except for volume which is offset by 1 day and has random anomalies. This is a problem with Interactive Brokers data and another reason I'm trying to do this.
Yes, the hours are correct in general, however the Daily bar 'clock' actually starts from the previous day's evening session (just like US futures) and ends at the close of the next Day session, so Session time should be set to 17:15:00 to 16:29:29 to be correct. But as mentioned earlier, the quirk with Asian markets is that Monday's evening session actually starts from Fri 17:15 until Sat 03:00. SC doesnt include that data in Mondays bar when creating the Daily chart from intraday data, it creates a separate 6th Daily bar and calls it Saturday. If you don't load Weekend Data then it ommits Mondays evening session (ie Fri/Sat trading) from the chart all together. .
Chart Time Zone: Hong Kong UTC +8
Chart Data Type: Intraday Data Only
Bar Period Type: Day-Min-Sec
Bar Period Value: 1-0-0
Session Start Time: 17:15:00
Session End Time: 02:59:59
Use Evening Session: Yes
Evening Start Time: 08:45:00
Evening End Time: 16:29:59
New Bar At Session Start: Yes
Weekend Data: Load Saturday Data
...I am able to match the days, and most of the OHLCV data.
See attached pic.
Since the days match, it would be possible to create OHLC bars using this setting in the Spreadsheet Study study:
"https://www.sierrachart.com/index.php?page=doc/SpreadsheetStudyInputs.html#UsePriceGraphStyle"
(copy/paste this link)
Since you were able to use Excel to create accurate bars, you should be able to create them with this option in this study.
You might need to add supporting charts, with the Spreadsheet Study study on each, then reference their values.