Template for SierraChart study

/* 

TEMPLATE & SETUP

1) Create new project
Installed Templates / Visual C++ / Win32 / Win32 Project
Application type: DLL
Additional options: Empty project

2) Copy s:\ACS_Source\*.h to project dir (dir with *.vcxproj),
and add them all as Existing Items to project Header Files section.

3) Copy this file to project dir with proper name.
and add it as Existing Item to project Source Files section.

4) Set up project properties
Configuration Properties / C/C++ / General / Additional Include Directories - d:\ATS\Projects\common.h
Configuration Properties / C/C++ / Code Generation - Runtime Library: Multi-Threaded
Configuration properties / C/C++ / Precompiled Headers - Precompiled Header : Not Using Precompiled Headers

5) Add to Build Events in Post-Build Event command
copy /b "$(OutputPath)$(TargetFileName)" "S:\Data"

*/

#include "sierrachart.h"
#include "ATS.h"

SCDLLName("GroupName") 

SCSFExport scsf_StudyName(SCStudyGraphRef sc)
{	
	if (sc.SetDefaults) // Set the configuration variables and defaults
	{
		sc.GraphName = "StudyName";	
		sc.FreeDLL   = 1;  // 1-when develop, 0-for (release to improve performance).
		sc.AutoLoop  = 1;  // Auto looping is enabled. 		
		return;
	}	
	// Main algorithm body starting from here
}

Lines with text ATS is about injecting my GUI library. If you not use it - just skip this lines.

Template creating process detailed description available here. There are a lot of detail in text and screenshots. Here is the very brief extraction:

1.Create new project

1) Create new project in Visual Studio

File / New /Project ...

2) Select Win32 Project template,

Installed Templates / Visual C++ / Win32 / Win32 Project

set project name and location at the bottom of wizard window and press Ok.

3) On next wizard screen click Next > and set

Application type: DLL
Additional options: Empty project

and click Finish.

2.Create main source code file

1) In Solution explorer window right click your project and select:

Add / New Item ...

2) In Installed templates select

Visual C++ / C++ File (.cpp)

set appropriate file name at the bottom of wizard window and press Ok.

3) In Solution explorer window double click just created cpp-file and copy-paste this text inside source code:

#include "sierrachart.h"

SCDLLName("GroupName") 

SCSFExport scsf_StudyName(SCStudyGraphRef sc)
{	
	if (sc.SetDefaults) // Set the configuration variables and defaults
	{
		sc.GraphName = "StudyName";	
		sc.FreeDLL   = 1;  // 1-when develop, 0-for (release to improve performance).
		sc.AutoLoop  = 1;  // Auto looping is enabled. 		
		return;
	}	
	// Main algorithm body starting from here
}

Place study into group

When you add custom studies to SierraChart, they are grouped into names hierarchy. Every top level leaf of the studies list tree got it's name from the line:

SCDLLName("GroupName")

Instead of “GroupName”, you must use any meaningful name. If you want to see all your studies in one subtree - you must use instead of “GroupName” the same name.

Give study name

All studies must have there own unique1) name. This name you give them in line:

sc.GraphName = "StudyName";	

Instead of “StudyName”, you must use any meaningful name.

3.Configure project properties

In Solution explorer window right click your project and select Properties. In opened window select Configuration: All configurations, and set:

Configuration Properties / C/C++ / General / Additional Include Directories - d:\ATS\Projects\common.h
Configuration Properties / C/C++ / Code Generation - Runtime Library: Multi-Threaded
Configuration properties / C/C++ / Precompiled Headers - Precompiled Header : Not Using Precompiled Headers

In Post-Build Event set:

copy /b "$(OutputPath)$(TargetFileName)" "S:\Data"

How does it work

To ensure that all is done Ok and study will work - add some “debug” code:

// Main algorithm body starting from here
sc.GraphRegion = 0; // Use the main price graph region
s_UseTool Tool;
Tool.Clear();
Tool.LineNumber    = 123456789;
Tool.DrawingType   = DRAWING_TEXT;
Tool.ChartNumber   = sc.ChartNumber;
Tool.AddMethod     = UTAM_ADD_OR_ADJUST;
Tool.BeginIndex    = sc.ArraySize-1;
Tool.BeginValue    = sc.Close[sc.ArraySize-1];
Tool.Text          = "I am here ->";
Tool.TextAlignment = DT_RIGHT;
Tool.Color         = COLOR_RED;
sc.UseTool(Tool);

This lines draw text box (Tool.DrawingType) with right-aligned (Tool.TextAlignment) red (Tool.Color) text (Tool.Text) at the last bar (Tool.BeginIndex) on close price (Tool.BeginValue). Just build the project and look how text “I am here →” follows current price.

1) together with SCDLLName(“GroupName”).
 
Copyright © 2014 AlgoTrading.Solutions