NexusFi: Find Your Edge


Home Menu

 





Coding required to create custom Study and adjust existing Study in SC


Discussion in Sierra Chart

Updated
    1. trending_up 553 views
    2. thumb_up 3 thanks given
    3. group 4 followers
    1. forum 9 posts
    2. attach_file 2 attachments




 
 

Coding required to create custom Study and adjust existing Study in SC

 
 Teduardo 
Melbourne, Australia
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Phillip Nova SG, IBKR
Trading: Asian markets (HSI/MHI, N225M, K200/M)
Frequency: Several times daily
Duration: Minutes
Posts: 27 since Aug 2018
Thanks Given: 21
Thanks Received: 3

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

Started this thread

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
Exit Strategy
NinjaTrader
How to apply profiles
Traders Hideout
ZombieSqueeze
Platforms and Indicators
Trade idea based off three indicators.
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
22 thanks
GFIs1 1 DAX trade per day journal
17 thanks
 
 Trembling Hand 
Melbourne, Land of Oz
 
Experience: Advanced
Platform: Sierra Chart, CQG
Broker: CQG
Trading: HSI
Posts: 246 since Jun 2011
Thanks Given: 28
Thanks Received: 360

Hi

I'm pretty sure the daily chart from intraday data just needs the session times to be set correctly into the chart settings.

On the zigzag not including the current un-closed bar is because the way zigzag is always "repainting". From my limited experience with it.

Follow me on Twitter
Thanked by:
 
 Sawtooth 
Prescott AZ USA
 
Experience: Advanced
Platform: SierraChart
Broker: Stage5, FCM:Dorman, Data:Denali, Routing:Teton
Trading: YM ES NQ
Posts: 474 since Nov 2009
Thanks Given: 219
Thanks Received: 603



Quoting 
New Study: create a Daily chart using intraday data.

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'


Quoting 
Existing Study modified: Zig Zag Cumulative Volume doesn't refresh properly

One solution would be to add the Chart Recalculation - Periodic study.

Thanked by:
 
 Teduardo 
Melbourne, Australia
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Phillip Nova SG, IBKR
Trading: Asian markets (HSI/MHI, N225M, K200/M)
Frequency: Several times daily
Duration: Minutes
Posts: 27 since Aug 2018
Thanks Given: 21
Thanks Received: 3

Thank you for the suggestions.

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

Started this thread
 
 Sawtooth 
Prescott AZ USA
 
Experience: Advanced
Platform: SierraChart
Broker: Stage5, FCM:Dorman, Data:Denali, Routing:Teton
Trading: YM ES NQ
Posts: 474 since Nov 2009
Thanks Given: 219
Thanks Received: 603

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.

See this for more information:
https://www.sierrachart.com/index.php?page=doc/helpdetails12.html

 
 Trembling Hand 
Melbourne, Land of Oz
 
Experience: Advanced
Platform: Sierra Chart, CQG
Broker: CQG
Trading: HSI
Posts: 246 since Jun 2011
Thanks Given: 28
Thanks Received: 360

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 use 9 am to 3am for HKFE

Follow me on Twitter
 
 Teduardo 
Melbourne, Australia
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Phillip Nova SG, IBKR
Trading: Asian markets (HSI/MHI, N225M, K200/M)
Frequency: Several times daily
Duration: Minutes
Posts: 27 since Aug 2018
Thanks Given: 21
Thanks Received: 3

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.

Started this thread
 
 Sawtooth 
Prescott AZ USA
 
Experience: Advanced
Platform: SierraChart
Broker: Stage5, FCM:Dorman, Data:Denali, Routing:Teton
Trading: YM ES NQ
Posts: 474 since Nov 2009
Thanks Given: 219
Thanks Received: 603

Does the Sierra Chart Historical Daily bar match the Trading View daily bar?

Are these the correct trading hours for the Hang Seng Futures?:
https://www.excalibur.com.hk/en/hk-index-futures-trading-hours/

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

 
 Teduardo 
Melbourne, Australia
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Phillip Nova SG, IBKR
Trading: Asian markets (HSI/MHI, N225M, K200/M)
Frequency: Several times daily
Duration: Minutes
Posts: 27 since Aug 2018
Thanks Given: 21
Thanks Received: 3

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. .

Hope this is not confusing

Started this thread
 
 Sawtooth 
Prescott AZ USA
 
Experience: Advanced
Platform: SierraChart
Broker: Stage5, FCM:Dorman, Data:Denali, Routing:Teton
Trading: YM ES NQ
Posts: 474 since Nov 2009
Thanks Given: 219
Thanks Received: 603


Using these settings...:

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.

Attached Thumbnails
Click image for larger version

Name:	Hang Seng Day vs Daily.PNG
Views:	24
Size:	110.8 KB
ID:	334702  
Thanked by:

 



Last Updated on September 7, 2023


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts