Login Page - Create Account

Using the Microsoft Visual C++ Development Environment

What Is Visual C++

The Sierra Chart Advanced Custom Study Interface and Language or ACSIL for short, allows you to create your own custom studies/indicators and trading systems. It is based on the C++ language. For more information about ACSIL, refer to Advanced Custom Study Interface and Language. Sierra Chart offers a simple development environment consisting of a text editor and C++ compiler. This is accessed through the Analysis menu from within Sierra Chart. To use the simple development environment, refer to the step-by-step instructions. This development environment is used to create and edit the study source code files and to generate the necessary executable file which is actually used by Sierra Chart to run your studies.

Visual C++ is an integrated development environment which provides a source code editor, compiler, and debugger. It is an alternative to the more simplified development environment provided by Sierra Chart. It needs to be downloaded and separately installed.

Why Use Visual C++

The following are the reasons why you would want to use Visual C++

  • Auto completion of function and variable names. This makes coding a study or trading system easier.
  • Step-By-Step Debugging. This is an essential feature in order to debug your source code in order to identify exactly where the problem is and resolve it. Otherwise, it gets to be quite difficult.
  • The ability to use all of the Microsoft Windows API (Application Programming Interface) instead of the more limited subset that the Sierra Chart development environment offers.

Step-by-Step Instructions to use Visual C++

You can use the Visual C++ development environment when creating Advanced Custom Studies for Sierra Chart.

Download and Install Microsoft Visual C++

Navigate to the Visual Studio Download Page. You will want to install the Visual Studio Community edition which includes Visual C++.


  • The installation is straightforward. It is mostly a matter of running the installation and clicking next to all the default options.
  • You can install it anywhere on your computer and it is independent of your Sierra Chart location.
  • The software is free.
  • Once you install, you will have 30 days after which Microsoft will require that you register and obtain a license. Although there is no cost for this.

Creating the Sierra Chart Custom Studies DLL Project

  1. In Visual C++ select File >> New >> Project. The New Project window should appear.
  2. In the New Project window:
    1. Select the project type as Win32 Project.
    2. Enter a project name (In our example and the accompanying image it is My Custom Study DLL).
    3. Click Ok.
  3. The next window is just a welcome message to the Win32 Application Wizard. Click Next.
  4. In the Application Settings window:
    1. Under Application Type, select DLL.
    2. Under additional options, select Empty Project.
    3. Click Finish.
  5. At this point you are done creating the initial project. Your workspace will look something like the image below.

Add Source Code to Your Project

So far we have a project but as you see, the source folder is empty.

  1. Add an empty c++ file - under Solution Explorer, right click Source Files and select Add >> New Item... like so
  2. In the Add New Item window, select C++ File. Fill in the Name and press Add. For your example, MyCustomStudy is the name of the file.
  3. Notice that MyCustomStudy.cpp has been added to the project and will be open for editing on the right. If not, double clicking the file in Solution Explorer will open the file for editing.
  4. Copy and paste the following code into the MyCustomStudy.cpp source code editor window:
    // The top of every source code file must include this line
    #include "sierrachart.h"
    // For reference, refer to this page:
    // https://www.sierrachart.com/index.php?page=doc/AdvancedCustomStudyInterfaceAndLanguage.php
    // This line is required. Change the text within the quote
    // marks to what you want to name your group of custom studies. 
    SCDLLName("Custom Study DLL")
    //This is the basic framework of a study function. Change the name 'TemplateFunction' to what you require.
    SCSFExport scsf_TemplateFunction(SCStudyInterfaceRef sc)
    	// Section 1 - Set the configuration variables and defaults
    	if (sc.SetDefaults)
    		sc.GraphName = "Template Function";
    		sc.AutoLoop = 1;  //Automatic looping is enabled. 
    		sc.Subgraph[0].Name = "Name";
    		sc.Subgraph[0].DrawStyle = DRAWSTYLE_LINE;
    		sc.Subgraph[0].PrimaryColor = RGB (0, 255, 0);
    		sc.Input[0].Name = "Float Input";
    	// Section 2 - Do data processing here
  5. Select File >> Save to save the file. You now have all the elements of a custom study. Next we will configure the project and build the custom study DLL file.

Configuring Project Properties

There are some things that need to be configured for the project in Visual C++ in order for the project to work smoothly with Sierra Chart.

  1. Change to Expert Settings. In Visual C++, select Tools >> Settings >> Expert Settings.

  2. In Visual C++, select View >> Solution Explorer to display the Solution Explorer window.
  3. Open the Project Properties window by right clicking on the project name in Solution Explorer and selecting Properties.
  4. Notice the My Custom Study DLL appears twice in the image below. The outer node in the hierarchy is the Solution. The inner node is the Project. A Solution can contain more than one Project. Although in our case we will always work with just a single Project contained within the Visual C++ Solution.

  5. From the list on the left of the Project Properties window, select Configuration Properties.
  6. At the top beside Configuration, select AllConfigurations . Using this option will allow us to change the settings for both the Debug and Release builds.

  7. Edit the Output Directory. In the Project Properties window, under Configuration Properties >> General, edit the Output Directory field by setting it to the Sierra Chart data folder. Make sure there is a \ at the end of the path.

  8. The Sierra Chart Data Files Folder is a folder located in your Sierra Chart installation folder. To find it, simply open Sierra Chart, and look under Global Settings >> General Settings >> Data Files Folder.

  9. Edit the Additional Include Directories, still in the Project Properties window. Under Configuration Properties >> C/C++ >> General edit the Additional Include Directories by filling it in with the ACS_Source folder in your Sierra Chart installation folder. This folder contains the sierrachart.h file that is used with all of the custom studies DLLs to access the ACSIL Interface.

  10. Disable pre-compiled headers under Configuration Properties >> C/C++ >> Precompiled Headers. Select Not Using Precompiled Headers.

  11. Set the project to link statically to the Runtime Libraries. This is absolutely necessary to ensure that your custom studies DLL can run on other users systems without having Visual C++ installed. It is first necessary to set the Configuration to either Release or Debug at the top of the Project Properties window. In this particular case you cannot use All Configurations.

    Select Configuration Properties >> C/C++ >> Code Generation >> Runtime Library >> Multi-Threaded (/MT) for a Release build configuration. Do not choose the ones with DLL. In the case of a Debug build configuration use Multi-Threaded Debug (/MTd).

  12. Press OK to save the modified Project Properties.

Build The Custom Study DLL and see your study in Sierra Chart

Building is the process of converting source code to a DLL. To do this in Visual C++, do the following:

  1. Right click the project name. From the menu, select Build . Again, be sure you are right clicking on the Project and not on the Solution.
  2. You can see that the build was successful by noting a couple of things:
    1. The output window shows a log of the build. A good build will not have any errors or warnings in the output window. See below an image of what a clean build looks like. When there is a problem and the source code fails to compile, the output window will present a message. Although often cryptic to the beginner, this message will provide some guidance as to the specific problem.
    2. As stated above, the result of the build is taking your source code and converting it to a DLL file. We specified in the Project Properties in Visual C++ that the DLL name should the same as the Project name and that the location is the Sierra Chart Data Files Folder.

    Successful build

    The DLL that was created

    Failed build
  3. Open the Add Custom Study window in Sierra Chart by selecting Analysis >> Studies >> Add Custom Study on the bottom left hand corner..
  4. The custom study should appear in the Add Study window similar to the image below.


Solution/Project/Source - in Visual C++ you have 3 elements that you should be aware of. Looking at the Solution Explorer window, you will see a hierarchy - there is the solution (yellow highlight), a project (green highlight) and source (blue highlight).

  1. A solution can hold multiple projects. It is nothing more than a way to organize your workspace and shows which projects are open. When you work on a project, it is always in the context of solution. Sort of like always having a Chartbook when you have a chart open.
  2. A project is the unit of build/compilation. The project properties define the result of building the project and determines how those things will be built. You should generally not be making any changes to your project beyond what is described here.
  3. After setting up the initial solution and project, 99.9% of your time will be with the source.

Build Configurations Debug/Release Version - as mentioned above, a project has properties which define what products are created as a result of a build and how they are created. By default, each project is first created with two such configurations namely Debug and Release.

The differences between them lies in that Debug defines build properties that produce a DLL that can be used for debugging while a Release configuration defines the same properties for a more optimized DLL that would be used in production. In most cases, especially while developing your code, you will be working with the Debug configuration.

So there are two parts to this.

First is configuring the properties for each configuration type. We did this in the steps above where we set the project properties. You generally need to do that for each configuration you plan on building. In the project properties window, you can change between configurations and edit them in turn (see below how to switch between them).

Next there is selecting the active configuration which is used for building your project. Whenever you build your project, the active configuration properties are used to determine what will be built. You select the active configuration in the main window.

In general, if you are just starting out with Visual C++, you can use the debug configuration.

Including Access to All of the Windows API

When using the Visual C++ development environment, it is possible to have full access to the Windows API (Application Programming Interface). Place the following line at the very top of your source code file (.cpp) and above the #include SierraChart.h line: #include <windows.h> to gain full access to the Windows API.


#include <windows.h> //must be above the following line
#include "SierraChart.h"

Resolving Precompiled Header Errors

When using the Visual C++ development environment and you add your own source code files (CPP files) to the Solution and Project we provide, you may receive this error when building your project:

Fatal Error C1010: unexpected end of file while looking for precompiled header. Did you forget to add "#include "stdafx.h" to your source?

To resolve this, you need to go to View >> Solution Explorer in Visual C++. Locate your file in the list of Source files. Right-click on the file and select Properties. The Property Pages window will display. Navigate through the tree on the left to Configuration Properties >> C/C++ >> Precompiled Headers. You will want to select the Not Using Precompiled Headers option. You should do this for each of your configurations, both Debug and Release.

*Last modified Thursday, 08th November, 2018.