Support Board
Date/Time: Sun, 24 Nov 2024 03:47:27 +0000
[Programming Help] - Time Zone and Evening Trading Session
View Count: 1750
[2023-03-14 17:43:13] |
Chris900 - Posts: 6 |
Hi, I have the following challenge. I am in the Timezone CET+1 (Germany) And I have NVDA from NASDAQ in my charts. My trading session is defined from 9:30 to 16:00 In my time zone the US Market currently opens for me at 14:30 and normally at 15:30. (daylight saving switch from Europe) My problem is now if it is passed 16:00 in my time zone, then I dont see the data anymore. Only if I switch on Evening/Trading Session. Since the market opens usually for me at 15:30 (9:30 US Eastern Time). Then I only have 30mins data and then it is not displayed anymore only if I use the "Evening/Trading Session" feature. Can you please describe to me how I need to setup the time zone, so that it is synced to the Market/Stock that I trade. In this case the US Market with NASDAQ. So that the "Evening/Trading Session" is really the time where the regular trading is stopped. Thanks for your help Chris |
[2023-03-14 20:33:27] |
John - SC Support - Posts: 36238 |
The easiest thing to do is to set your chart to be in the same time zone as the exchange itself. This way, you do not need to worry about the time changes. But, in general, you just need to know what time zone you have set for the chart and then make sure that the Session Times are correct relative to that time zone. So if you do set the chart to be the same as the exchange (Eastern US in this case), you would have your Session Times set as the following: - Start Time: 09:30:00 - End Time: 15:59:59 - Evening Start Time: 16:00:00 - Evening End Time: 09:29:59 Refer to the following regarding Time Zones: Time Zone Setting And refer to the following regarding Session Times: Chart Session Times For the most reliable, advanced, and zero cost futures order routing, use the Teton service: Sierra Chart Teton Futures Order Routing |
[2023-03-14 23:40:26] |
Tony - Posts: 516 |
Chris, Do you need to display your local date and time on your chart? |
[2023-03-15 08:27:18] |
Chris900 - Posts: 6 |
@John: Thanks for the reply. I think this solves it. I have two options either go with the Market itself or adjust the session time to my time zone. @Tony: Ideally yes, I want to show my local time on the chart. Usually I trade US Market from 15:30 to 22:00 my time. I guess I have to set the session time to that timeframe, then it also works with "Evening Session" on and off. Or I set the chart clock to US Eastern and Session Time to 9:30 to 16:00 but then I don't see my own time anywhere. The only challenge I have when I set my local time and use session time from 15:30 to 22:00 then I have the two weeks in the spring (now) and autumn, since the US time switch is on a different date then the German time switch. Then the session is actually from 14:30 to 21:00 my time. I think there is no good way to see my own time and make sure that it always syncs throughout the year. |
[2023-03-15 09:27:18] |
Sierra_Chart Engineering - Posts: 17154 |
I think there is no good way to see my own time and make sure that it always syncs throughout the year. Yes. Refer to:Time Zone Setting: Resolving Differences with the Transition To/From Daylight Savings Time in Different Time Zones Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, use the Teton service: Sierra Chart Teton Futures Order Routing |
[2023-03-15 13:09:21] |
Tony - Posts: 516 |
@Chris, The only challenge I have when I set my local time and use session time from 15:30 to 22:00 then I have the two weeks in the spring (now) and autumn, since the US time switch is on a different date then the German time switch. Then the session is actually from 14:30 to 21:00 my time. I think there is no good way to see my own time and make sure that it always syncs throughout the year. kein problem, all you have to do is set session time always from 14:30 to 22:00, and go to "Chart Settings --> Chart Data", set "Load Zero Value" to "No", you will get the identical result as if you would manually change the session starting/ending times. You don't get any data after 21:00 right now, and after March 26th, you will not get any data from 14:30 to 15:30, but there will be no bar printed during those periods anyway. This is what I am doing on my charts (for different reasons) If you know how to do "Remote Build", I will send you a simple ACSIL, that display New York time and Frankfurt time on chart (automatically adjusted to different Daylight Time schedules). You will just set the chart time zone to New York time as John suggested. Let me know. Cheers, Tony Date Time Of Last Edit: 2023-03-15 19:01:19
|
[2023-03-15 13:27:57] |
Chris900 - Posts: 6 |
@Tony: thanks a lot. I will try what you suggested. And it would be Great to get the Acsil file. I just went through the instructions how to use them, I think i can figure this out. Thanks for the help. |
[2023-03-15 14:54:27] |
Tony - Posts: 516 |
@Chris You are welcome, just a quick and dirty solution, sorry, I was in a rush, if you are into coding, you could definitely make it fancier, see the final result in the attach image. I wrote on Sierra Chart's template, you will have to change the text color/size in Subgraphs tab, and after change horizontal or vertical positions, you might have to hide and unhide the study to make the change effective. Not sure why, could be my OS issue. To display date or week, change those values from 0(No) to 1(Yes) // The top of every source code file must include this line #include "sierrachart.h" // This line is required. Change the text within the quote // marks to what you want to name your group of custom studies. SCDLLName("Display New York and Local Times") //This is the basic framework of a study function. Change the name 'DisplayTimes' to what you require. SCSFExport scsf_DisplayTimes(SCStudyInterfaceRef sc) { SCInputRef DisplayDate {sc.Input[0]}; SCInputRef DisplayWeek {sc.Input[1]}; SCInputRef Horizontal {sc.Input[2]}; SCInputRef Vertical {sc.Input[3]}; SCSubgraphRef TextSizeColor {sc.Subgraph[0]}; // Section 1 - Set the configuration variables and defaults if (sc.SetDefaults) { sc.GraphName = "Display New York and Local Times"; sc.AutoLoop = 1; //Automatic looping is enabled. sc.GraphRegion = 0; TextSizeColor.Name = "Adjust Text Size and Color"; TextSizeColor.DrawStyle = DRAWSTYLE_CUSTOM_TEXT; TextSizeColor.PrimaryColor = RGB (225, 215, 185); TextSizeColor.LineWidth = 10; DisplayDate.Name = "Display Date"; DisplayDate.SetInt(0); DisplayWeek.Name = "Display Week"; DisplayWeek.SetInt(0); Horizontal.Name = "Horizontal Position (0-150)"; Horizontal.SetInt(5); Vertical.Name = "Vertical Position (0-100)"; Vertical.SetInt(80); return; } // Section 2 - Do data processing here SCString WeekDays {"SunMonTueWedThuFriSat"}; SCString Months {"NulJanFebMarAprMayJunJulAugSepOctNovDec"}; SCDateTime NewYorkLocal { sc.IsReplayRunning() ? sc.ConvertDateTimeFromChartTimeZone(sc.BaseDataEndDateTime[sc.Index], TIMEZONE_NEW_YORK) : sc.ConvertDateTimeFromChartTimeZone(sc.CurrentSystemDateTime, TIMEZONE_NEW_YORK) }; SCDateTime FrankurtLocal { sc.IsReplayRunning() ? sc.ConvertDateTimeFromChartTimeZone(sc.BaseDataEndDateTime[sc.Index], TIMEZONE_BRUSSELS) : sc.ConvertDateTimeFromChartTimeZone(sc.CurrentSystemDateTime, TIMEZONE_BRUSSELS) }; SCString DisplayText {""}; DisplayText.Format(""); if (sc.IsReplayRunning()) DisplayText.AppendFormat("Chart Is Replaying ... \n\n"); if (DisplayDate.GetInt()) DisplayText.AppendFormat("%s %d ", Months.GetSubString(3,3*NewYorkLocal.GetMonth()).GetChars(), NewYorkLocal.GetDay()); if (DisplayWeek.GetInt()) DisplayText.AppendFormat("%s ", WeekDays.GetSubString(3,3*NewYorkLocal.GetDayOfWeek()).GetChars()); DisplayText.AppendFormat("%02d:%02d:%02d [New York]\n\n", NewYorkLocal.GetHour(), NewYorkLocal.GetMinute(), NewYorkLocal.GetSecond()); if (DisplayDate.GetInt()) DisplayText.AppendFormat("%s %d ", Months.GetSubString(3,3*FrankurtLocal.GetMonth()).GetChars(), FrankurtLocal.GetDay()); if (DisplayWeek.GetInt()) DisplayText.AppendFormat("%s ", WeekDays.GetSubString(3,3*FrankurtLocal.GetDayOfWeek()).GetChars()); DisplayText.AppendFormat("%02d:%02d:%02d [Frankfurt]\n\n", FrankurtLocal.GetHour(), FrankurtLocal.GetMinute(), FrankurtLocal.GetSecond()); sc.AddAndManageSingleTextUserDrawnDrawingForStudy(sc, 0, Horizontal.GetInt(), Vertical.GetInt(), TextSizeColor, 1, DisplayText, 1, 0, 0); } Date Time Of Last Edit: 2023-03-16 05:41:36
|
Frankfurt.png / V - Attached On 2023-03-15 15:01:07 UTC - Size: 56.1 KB - 240 views |
[2023-03-15 17:50:40] |
Chris900 - Posts: 6 |
@Tony: Great Stuff, thanks a lot. I just loaded into the system and it works nicely. Really cool that you wrote a quick coding for me! Thanks :-) :-) As for anybody else who might want to have this in the future. Here is the guideline to load this: How to Build an Advanced Custom Study from Source Code And then make sure like Tony said to go into Analysis-->Studies-->click on settings for the study-->go to tab subgraph And change the color and width/size (bigger) so that you can see it on the chart. Took me a while to figure this out. Really nice, now I see both times all the time very quickly. |
[2023-03-15 18:07:39] |
Tony - Posts: 516 |
You are very welcome Chris, I'm glad it works for you, thanks for your consideration of other traders might need this feature. Would like to add a list of time zones that Sierra Chart provides (make sure all capital letters), in case the source code needs to be modified. TIMEZONE_HONOLULU TIMEZONE_ANCHORAGE TIMEZONE_LOS_ANGELES TIMEZONE_PHOENIX_ARIZONA TIMEZONE_DENVER TIMEZONE_CHICAGO TIMEZONE_NEW_YORK TIMEZONE_HALIFAX TIMEZONE_LONDON TIMEZONE_BRUSSELS TIMEZONE_CAPE_TOWN TIMEZONE_ATHENS TIMEZONE_BAGHDAD TIMEZONE_DUBAI TIMEZONE_ISLAMABAD TIMEZONE_NEW_DELHI TIMEZONE_DHAKA TIMEZONE_JAKARTA TIMEZONE_HONG_KONG TIMEZONE_TOKYO TIMEZONE_BRISBANE TIMEZONE_SYDNEY TIMEZONE_AUCKLAND Date Time Of Last Edit: 2023-03-16 17:58:13
|
[2023-03-16 01:04:18] |
User90125 - Posts: 715 |
Chris & Tony, Great work here! Can you help me figure out the best way to modify the code and make it a user-selectable list of TimeZones? Thanks :) |
[2023-03-16 01:19:56] |
Tony - Posts: 516 |
@User90125, It's definitely doable, by using list of strings, ACSIL Interface Members - sc.Input Array: sc.Input[].SetCustomInputStrings() For general purpose, ideally 2 lists of time zones, one for the instrument, one for trader's location. Unfortunately, there will be some work involved, I will have to squeeze some time in the future, maybe Sierra would add that as one of those default studies. In the meantime, you can always modify the source code by replacing whatever timezones you want. In those 2 pairs of braces "{ }" after SCDateTime NewYorkLocal
And SCDateTime FrankurtLocal
Date Time Of Last Edit: 2023-03-16 15:20:53
|
[2023-03-16 05:12:26] |
Tony - Posts: 516 |
I just realized, when chart is replaying, the time should be showing the last close, instead of current time, fixed and updated the source code in post #8. This is essential, especially when we have to look at trading log while replaying chart.
Date Time Of Last Edit: 2023-03-16 05:51:52
|
[2023-03-16 09:41:48] |
User431178 - Posts: 541 |
Variation on above with selectable time zones. // The top of every source code file must include this line #include "sierrachart.h" // This line is required. Change the text within the quote // marks to what you want to name your group of custom studies. SCDLLName("Display New York and Local Times") //This is the basic framework of a study function. Change the name 'DisplayTimes' to what you require. SCSFExport scsf_DisplayTimes(SCStudyInterfaceRef sc) { auto& DisplayDate = sc.Input[0]; auto& DisplayWeekday = sc.Input[1]; auto& Horizontal = sc.Input[2]; auto& Vertical = sc.Input[3]; auto& TimeZone1 = sc.Input[4]; auto& TimeZone2 = sc.Input[5]; auto& TextSizeColor = sc.Subgraph[0]; if (sc.SetDefaults) { sc.GraphName = "Display Times"; sc.AutoLoop = 0; sc.GraphRegion = 0; TextSizeColor.Name = "Adjust Text Size and Color"; TextSizeColor.DrawStyle = DRAWSTYLE_CUSTOM_TEXT; TextSizeColor.PrimaryColor = RGB(225, 215, 185); TextSizeColor.LineWidth = 10; DisplayDate.Name = "Display Date"; DisplayDate.SetYesNo(0); DisplayWeekday.Name = "Display Weekday"; DisplayWeekday.SetYesNo(0); Horizontal.Name = "Horizontal Position (0-150)"; Horizontal.SetInt(5); Horizontal.SetIntLimits(0, 150); Vertical.Name = "Vertical Position (0-100)"; Vertical.SetInt(80); Vertical.SetIntLimits(0, 100); TimeZone1.Name = "Time Zone 1"; TimeZone1.SetTimeZone(TIMEZONE_NEW_YORK); TimeZone2.Name = "Time Zone 2"; TimeZone2.SetTimeZone(TIMEZONE_LONDON); return; } const auto dT1 = sc.IsReplayRunning() ? sc.ConvertDateTimeFromChartTimeZone(sc.LatestDateTimeForLastBar, TimeZone1.GetTimeZone()) : sc.ConvertDateTimeFromChartTimeZone(sc.CurrentSystemDateTime, TimeZone1.GetTimeZone()); const auto dT2 = sc.IsReplayRunning() ? sc.ConvertDateTimeFromChartTimeZone(sc.LatestDateTimeForLastBar, TimeZone2.GetTimeZone()) : sc.ConvertDateTimeFromChartTimeZone(sc.CurrentSystemDateTime, TimeZone2.GetTimeZone()); auto displayText = SCString{}; if (sc.IsReplayRunning()) displayText.AppendFormat("Chart Is Replaying ... \n\n"); if (DisplayDate.GetYesNo()) displayText.AppendFormat("%s %d ", SHORT_NAME_FOR_MONTH[dT1.GetMonth()], dT1.GetDay()); if (DisplayWeekday.GetYesNo()) displayText.AppendFormat("%s ", SHORT_NAME_FOR_DAY_OF_WEEK[dT1.GetDayOfWeek()]); displayText.Append(sc.DateTimeToString(dT1, FLAG_DT_COMPLETE_TIME)); displayText.AppendFormat(" [%s]\n\n", TIME_ZONE_NAME_STRINGS[TimeZone1.GetTimeZone()]); if (DisplayDate.GetYesNo()) displayText.AppendFormat("%s %d ", SHORT_NAME_FOR_MONTH[dT2.GetMonth()], dT2.GetDay()); if (DisplayWeekday.GetYesNo()) displayText.AppendFormat("%s ", SHORT_NAME_FOR_DAY_OF_WEEK[dT2.GetDayOfWeek()]); displayText.Append(sc.DateTimeToString(dT2, FLAG_DT_COMPLETE_TIME)); displayText.AppendFormat(" [%s]\n\n", TIME_ZONE_NAME_STRINGS[TimeZone2.GetTimeZone()]); sc.AddAndManageSingleTextUserDrawnDrawingForStudy(sc, 0, Horizontal.GetInt(), Vertical.GetInt(), TextSizeColor, 1, displayText, 1, 0, 0); } |
displaytimes.png / V - Attached On 2023-03-16 09:40:30 UTC - Size: 54.06 KB - 187 views |
[2023-03-16 15:16:00] |
Tony - Posts: 516 |
Thanks User431178! That was quick! Good to know the sc.Input[0].SetTimeZone(), not listed in the Members List on Sierra's web site. I guess I will have to read head files in ACS_Source folder when I have time. For things like SHORT_NAME_FOR_MONTH[] etc. Thanks again! Date Time Of Last Edit: 2023-03-16 15:46:26
|
[2023-03-24 23:50:49] |
Tony - Posts: 516 |
Here is the pre-market and post-market background color on TradingView in Sierra Chart: (For stocks traded on NYSE or NASDAQ, time zone on the chart can be anywhere) *** When multiple studies are loaded, this one should be the first one, so it will stay at very bottom (beneath other studies) *** // The top of every source code file must include this line #include "sierrachart.h" // This line is required. Change the text within the quote // marks to what you want to name your group of custom studies. SCDLLName("PrePostBackground") //This is the basic framework of a study function. Change the name 'TemplateFunction' to what you require. SCSFExport scsf_PrePostBackground(SCStudyInterfaceRef sc) { // Section 1 - Set the configuration variables and defaults if (sc.SetDefaults) { sc.GraphName = "Pre and Post Market Background"; sc.AutoLoop = 1; //Automatic looping is enabled. sc.DrawStudyUnderneathMainPriceGraph = 1; sc.GraphRegion = 0; sc.Subgraph[0].Name = "BackgroundTop"; sc.Subgraph[0].DrawStyle = DRAWSTYLE_FILL_TOP; sc.Subgraph[0].PrimaryColor = RGB (255, 234, 204); sc.Subgraph[1].Name = "BackgroundBottom"; sc.Subgraph[1].DrawStyle = DRAWSTYLE_FILL_BOTTOM; sc.Subgraph[1].PrimaryColor = RGB (211, 234, 253); sc.Input[0].Name = "Pre-Market Color"; sc.Input[0].SetColor(255, 234, 204); sc.Input[1].Name = "After-Market Color"; sc.Input[1].SetColor(211, 234, 253); return; } // Section 2 - Do data processing here for (int IndexCount {sc.Index}; IndexCount>=sc.IndexOfFirstVisibleBar; IndexCount--) { sc.Subgraph[0][IndexCount] = 0; sc.Subgraph[1][IndexCount] = 0; int IndexInNewYorkTimeInSeconds { sc.ConvertDateTimeFromChartTimeZone(sc.BaseDateTimeIn[IndexCount], TIMEZONE_NEW_YORK).GetTimeInSeconds() }; if (IndexInNewYorkTimeInSeconds>=(4*3600) && IndexInNewYorkTimeInSeconds<(9*3600+30*60)) { sc.Subgraph[0][IndexCount] = sc.YPixelCoordinateToGraphValue(0); sc.Subgraph[1][IndexCount] = sc.YPixelCoordinateToGraphValue(sc.ChartRegion1BottomCoordinate); } // pre-market goes from 4 am to 9:30 am ? if (IndexInNewYorkTimeInSeconds>=(16*3600) && IndexInNewYorkTimeInSeconds<=(20*3600)) { sc.Subgraph[0][IndexCount] = sc.YPixelCoordinateToGraphValue(sc.ChartRegion1BottomCoordinate); sc.Subgraph[1][IndexCount] = sc.YPixelCoordinateToGraphValue(0); } // post-market goes from 4 pm to 8 pm ? sc.Subgraph[0].DataColor[IndexCount] = sc.Input[0].GetColor(); sc.Subgraph[1].DataColor[IndexCount] = sc.Input[1].GetColor(); } } Date Time Of Last Edit: 2023-03-25 00:22:06
|
To post a message in this thread, you need to log in with your Sierra Chart account: