Login Page - Create Account

Support Board


Date/Time: Mon, 21 Apr 2025 23:48:00 +0000



[Programming Help] - Is it possible to have a drop down list as an input for a study setting?

View Count: 319

[2025-02-18 21:24:13]
LTSys - Posts: 68
Hi,

Two questions

Q1: Is it possible to have a drop down list as an input for a study setting?

Q2: Is there a way to get a list of all the account names?

For example I would like to have a drop down selection for all the possible accounts?

Something like...

List accounts = // call something to get list of accounts

sc.Input[0].Name = "Account";
sc.Input[0].SetDropDown(accounts);

TIA
[2025-02-19 00:05:56]
User719512 - Posts: 309
Have you looked at all the sample .cpp files in C:\SierraChart\ACS_Source?
Tons of examples to inspire from.

SetCustomInputStrings()

Also good to read everything under ACSIL Interface Members - Introduction
Search for "account" under Functions...
[2025-02-19 00:49:49]
seandunaway - Posts: 348
probably something like this

#include <sierrachart.h>

SCDLLName("account menu")
SCSFExport scsf_account_menu (SCStudyInterfaceRef sc)
{
  SCInputRef account_id = sc.Input[0];

  if (sc.SetDefaults)
  {
    sc.GraphName = "account menu";
    sc.GraphRegion = 0;

    SCString custom_input_string;
    int number_of_accounts = sc.GetNumTradeAccounts();

    for (int i = 0; i < number_of_accounts; i++)
    {
      SCString account_name;
      sc.GetTradeAccountAtIndex(i, account_name);

      custom_input_string.Append(account_name);
      custom_input_string.Append(";");
    }

    account_id.Name = "account";
    account_id.SetCustomInputStrings(custom_input_string);
    account_id.SetCustomInputIndex(0);

    return;
  }

  SCString output;
  output.AppendFormat("Account selected - ID: %d Name: %s\n", account_id.GetIndex(), account_id.GetSelectedCustomString().GetChars());

  sc.AddMessageToLog(output, 1);
}

Date Time Of Last Edit: 2025-02-19 00:53:13
imageaccount_menu.png / V - Attached On 2025-02-19 00:53:09 UTC - Size: 68.85 KB - 37 views
[2025-02-19 01:00:01]
seandunaway - Posts: 348
you know, if you spend a couple of hours reviewing the acsil documentation and examples instead of piecemealing each feature of your study into separate forum threads, you'll be able to create whatever you imagine while also saving time in the end. :)

the documentation is very thorough and very well organized once you understand the overview
Date Time Of Last Edit: 2025-02-19 01:06:48
[2025-02-19 01:44:38]
LTSys - Posts: 68
probably something like this

Thanks for that... I'll look more into the samples.

Some things I just can't find... for example:

SCDateTime orderTime = order.EntryDateTime;

I'm trying to find a function to get the seconds or milliseconds since epoch from the SCDateTime object.

I'm also trying to find out how to get the offset from GMT for the SCDateTime... or is it already in GMT time?

TIA
[2025-02-19 01:59:00]
seandunaway - Posts: 348
here's the interface to SCDateTime

https://www.sierrachart.com/downloads/2700/ACS_Source/scdatetime.h
Working with the SCDateTime Variables and Values

check out SCDateTime::ToUNIXTime() and similar, or use the many helpful built-in methods for comparing dates and times

also, remember you're just using c/c++.. all the standard libraries (and even platform and external libraries) are also available to you
Date Time Of Last Edit: 2025-02-19 02:03:55
[2025-02-19 15:23:53]
LTSys - Posts: 68
check out SCDateTime::ToUNIXTime()

Thanks, I didn't see that one in the docs.

remember you're just using c/c++.. all the standard libraries

Yes, but if it exists in the Sierra API I'd rather use it instead to keep the lines of code down to a minimum.

Is there a function to get the Broker's time or to get the server time that is being used for order time? I need to compare that server time against gmt time.

TIA
Date Time Of Last Edit: 2025-02-19 16:28:12
[2025-02-19 20:03:31]
ForgivingComputers.com - Posts: 1042
Is there a function to get the Broker's time or to get the server time that is being used for order time?

If your Sierra Chart instance is set to use NTP, your PC clock will be within milliseconds of the broker's. You can then use sc.CurrentSystemDateTime in your study.

Network Time Protocol Client
[2025-02-19 20:12:12]
LTSys - Posts: 68
If your Sierra Chart instance is set to use NTP, your PC clock will be within milliseconds of the broker's. You can then use sc.CurrentSystemDateTime in your study.

I can't rely on my customers to configure chart settings. They'll forget and it will cause too many issues.

I appreciate your help.

Thanks
[2025-02-19 22:20:16]
ForgivingComputers.com - Posts: 1042
I can't rely on my customers to configure chart settings. They'll forget and it will cause too many issues.

It's a one-time setup. Everything is at the URL.

You can also set Windows to auto-update, but that is less frequent.

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account