Support Board
Date/Time: Sun, 24 Nov 2024 03:37:32 +0000
Post From: Time Zone and Evening Trading Session
[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
|