Login Page - Create Account

Support Board


Date/Time: Mon, 01 Jul 2024 21:12:35 +0000



Post From: Time Zone and Evening Trading Session

[2023-03-15 14:54:27]
Tony - Posts: 485
@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
imageFrankfurt.png / V - Attached On 2023-03-15 15:01:07 UTC - Size: 56.1 KB - 207 views