Sierra Chart ACSIL for Beginners. - futures io
futures io



Sierra Chart ACSIL for Beginners.


Discussion in Sierra Chart

Updated
      Top Posters
    1. looks_one Trembling Hand with 29 posts (161 thanks)
    2. looks_two mosalem2003 with 7 posts (0 thanks)
    3. looks_3 drunkcolonel with 4 posts (3 thanks)
    4. looks_4 jokertrader with 2 posts (0 thanks)
    1. trending_up 16,568 views
    2. thumb_up 166 thanks given
    3. group 44 followers
    1. forum 52 posts
    2. attach_file 5 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 150,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Sierra Chart ACSIL for Beginners.

(login for full post details)
  #11 (permalink)
 Trembling Hand 
Melbourne, Land of Oz
 
Experience: Advanced
Platform: Sierra Chart, CQG
Broker: CQG
Trading: HSI
 
Posts: 206 since Jun 2011
Thanks: 19 given, 303 received

Here is our complete code with some comments in the programming section to explain each line,

 
Code
//Make sure your custom studies source code file has the following two lines at the top of the file and in this order.
// This must be exactly "sierrachart.h" to ensure you are referencing the correct header file.
#include "sierrachart.h"
SCDLLName("SC_ACSIL_Examples")

//       So lets make a very basic study to walk through each of the above points. We'll make study that displays 2 simple moving averages (nothing too exciting to start)

// Firstly we need two supgraphs to hold our Moving averge calculationsand we need two inputs to control what period
SCSFExport scsf_SC_ACSIL_ExamplesV1(SCStudyInterfaceRef sc)
{
    // Declare All study subgraphs  
    SCSubgraphRef BarRange = sc.Subgraph[0];

    // And study inputs 
    SCInputRef BarRangeMultiplier = sc.Input[0];

    if (sc.SetDefaults)
    {
        // Set all display and input defaults here
        sc.GraphName = "SC_ACSIL_ExamplesV1";
        sc.StudyDescription = "Simple study to show basic concepts";
        sc.AutoLoop = 1;

        BarRange.Name = "Bar Range";
        BarRange.DrawStyle = DRAWSTYLE_BAR;
        BarRange.PrimaryColor = RGB(0, 0, 255);

        BarRangeMultiplier.Name = "Bar Range Multiplier";
        BarRangeMultiplier.SetInt(2);

        return;
    }



    // Data processing code	
  
    // This line calculates our main Study SubGraph
    BarRange[sc.Index] = sc.High[sc.Index] - sc.Low[sc.Index];

    // Declare a new SCString
    SCString DataString;
    // Add that text and variables to our new SCString
    DataString.Format("Bar Index: %d, High: %.2f, Low: %.2f BarRange: %.2f", sc.Index, sc.High[sc.Index], sc.Low[sc.Index], BarRange[sc.Index] );
    
    // declare a new variable and multibly or main Study SubGraph by our Input value
    float DoubleBarRange = BarRange[sc.Index] * BarRangeMultiplier.GetInt();

    // Append new text and our DoubleBarRange varible to the end of our DataString
    DataString.AppendFormat(", BarRangeX2: %.2f", DoubleBarRange);

    // Finally print our DataString to Sierra Charts Log
    sc.AddMessageToLog(DataString, 0);
   
}
Once you add the Study to a chart your log will print each something like this,

Quoting 
Chart: F.US.YMU20 Daily #1 | Study: SC_ACSIL_ExamplesV1 | Bar Index: 191, High: 27491.00, Low: 27000.00 BarRange: 491.00, BarRangeX2: 982.00 | 2020-06-27 17:02:55.597
Chart: F.US.YMU20 Daily #1 | Study: SC_ACSIL_ExamplesV1 | Bar Index: 192, High: 27352.00, Low: 26774.00 BarRange: 578.00, BarRangeX2: 1156.00 | 2020-06-27 17:02:55.597
Chart: F.US.YMU20 Daily #1 | Study: SC_ACSIL_ExamplesV1 | Bar Index: 193, High: 26865.00, Low: 24933.00 BarRange: 1932.00, BarRangeX2: 3864.00 | 2020-06-27 17:02:55.597
Chart: F.US.YMU20 Daily #1 | Study: SC_ACSIL_ExamplesV1 | Bar Index: 194, High: 25816.00, Low: 24934.00 BarRange: 882.00, BarRangeX2: 1764.00 | 2020-06-27 17:02:55.597
Chart: F.US.YMU20 Daily #1 | Study: SC_ACSIL_ExamplesV1 | Bar Index: 195, High: 25753.00, Low: 24409.00 BarRange: 1344.00, BarRangeX2: 2688.00 | 2020-06-27 17:02:55.597
Chart: F.US.YMU20 Daily #1 | Study: SC_ACSIL_ExamplesV1 | Bar Index: 196, High: 26658.00, Low: 25660.00 BarRange: 998.00, BarRangeX2: 1996.00 | 2020-06-27 17:02:55.597
Chart: F.US.YMU20 Daily #1 | Study: SC_ACSIL_ExamplesV1 | Bar Index: 197, High: 26494.00, Low: 25923.00 BarRange: 571.00, BarRangeX2: 1142.00 | 2020-06-27 17:02:55.597
Chart: F.US.YMU20 Daily #1 | Study: SC_ACSIL_ExamplesV1 | Bar Index: 198, High: 26148.00, Low: 25617.00 BarRange: 531.00, BarRangeX2: 1062.00 | 2020-06-27 17:02:55.597
Chart: F.US.YMU20 Daily #1 | Study: SC_ACSIL_ExamplesV1 | Bar Index: 199, High: 26320.00, Low: 25509.00 BarRange: 811.00, BarRangeX2: 1622.00 | 2020-06-27 17:02:55.597
Chart: F.US.YMU20 Daily #1 | Study: SC_ACSIL_ExamplesV1 | Bar Index: 200, High: 25987.00, Low: 25230.00 BarRange: 757.00, BarRangeX2: 1514.00 | 2020-06-27 17:02:55.597
Chart: F.US.YMU20 Daily #1 | Study: SC_ACSIL_ExamplesV1 | Bar Index: 201, High: 26294.00, Low: 25514.00 BarRange: 780.00, BarRangeX2: 1560.00 | 2020-06-27 17:02:55.597
Chart: F.US.YMU20 Daily #1 | Study: SC_ACSIL_ExamplesV1 | Bar Index: 202, High: 26134.00, Low: 25159.00 BarRange: 975.00, BarRangeX2: 1950.00 | 2020-06-27 17:02:55.597
Chart: F.US.YMU20 Daily #1 | Study: SC_ACSIL_ExamplesV1 | Bar Index: 203, High: 25659.00, Low: 25003.00 BarRange: 656.00, BarRangeX2: 1312.00 | 2020-06-27 17:02:55.597
Chart: F.US.YMU20 Daily #1 | Study: SC_ACSIL_ExamplesV1 | Bar Index: 204, High: 25653.00, Low: 24837.00 BarRange: 816.00, BarRangeX2: 1632.00 | 2020-06-27 17:02:55.597

Noting how we added sc.Index as the first variable in our log and on each bar it increments up by one.
As well you can change the BarRangeMultiplier in the Subgraph "Settings and Inputs" section and note how it changes the value printed to log.

Follow me on Twitter Started this thread Reply With Quote
The following 9 users say Thank You to Trembling Hand for this post:

Can you help answer these questions
from other members on futures io?
1 Minute Harmonic rotations for HHI/HSI - HKEX Futures
Traders Hideout
Standing Desks
The Elite Circle
NT8 - Footprint Chart adding on code
NinjaTrader
S&R, S&D Help Advise
Traders Hideout
 
 
(login for full post details)
  #12 (permalink)
 Trembling Hand 
Melbourne, Land of Oz
 
Experience: Advanced
Platform: Sierra Chart, CQG
Broker: CQG
Trading: HSI
 
Posts: 206 since Jun 2011
Thanks: 19 given, 303 received

All that looks like a lot of work but actually its pretty simple.

Set up a Visual Studio .dll project and set the parameters for SC (Output directory, Include Directory, Set Not using Headers and delete un-needed files)

Paste the SC ACSIL template from here in the .cpp file.

Declare the Subgraphs you want to plot and the Inputs you'll need to control the Study

Set Defaults for you Study, Subgraphs and Inputs in sc.SetDefaults code block

Then program your calculations to produce the Study you wants.

Follow me on Twitter Started this thread Reply With Quote
The following 6 users say Thank You to Trembling Hand for this post:
 
(login for full post details)
  #13 (permalink)
 Trembling Hand 
Melbourne, Land of Oz
 
Experience: Advanced
Platform: Sierra Chart, CQG
Broker: CQG
Trading: HSI
 
Posts: 206 since Jun 2011
Thanks: 19 given, 303 received


I'll have another example to build on in a few days, I've been busier than I thought this week. Stay tuned......

Follow me on Twitter Started this thread Reply With Quote
The following 7 users say Thank You to Trembling Hand for this post:
 
(login for full post details)
  #14 (permalink)
 Trembling Hand 
Melbourne, Land of Oz
 
Experience: Advanced
Platform: Sierra Chart, CQG
Broker: CQG
Trading: HSI
 
Posts: 206 since Jun 2011
Thanks: 19 given, 303 received

Ok I'm going to do another rather simple example to expand on a few fundamentals then I'll start taking request.

Firstly when making a new Study we can, from here, start it in two ways. We could start a new VS project like in the first post and make a completely new study or we can just add another SCSFExport scsf_FunctionName(SCStudyInterfaceRef sc) function to our existing project. That way we can avoid having to set all the properties etc and we keep all the Examples ACSIL in one file and sub-menu in SC.

So remember the template for all SC ACSIL Studies.

 
Code
#include "sierrachart.h"

SCDLLName("Custom Study DLL") 


SCSFExport scsf_FunctionName(SCStudyInterfaceRef sc)
{
// Declare SubGraphs and inputs here
    if (sc.SetDefaults)
    {
        //Code in this section
        return;
    }
    // Data processing code	
}
When adding another study to an existing project you only need the code for the SCSFExport function code block. As we have already told the project to include "sierrachart.h" header file with all the SierraChart referances in the first line of our .cpp file and The SCDLLName("Custom Study DLL") is the name that SierraChart uses in Chart>Studies>Add Custom Studies list.

So below the very last curly bracket } of our SC_ACSIL_Examples .cpp paste the above bit of code without the first two lines. And change the study name scsf_FunctionName to scsf_SimpleMaExamples

Now this is very important. It MUST have the scsf_ at the start of the study name or SC when loading all the .dlls will skip it.

In the last Study we only had one SubGraph and one Study input. For this we will have multiple of each. So we need to declare each and give them a name.

Below the first { paste this code,

 
Code
    SCSFExport scsf_SimpleMaExamples(SCStudyInterfaceRef sc)
{
    // Declare All study subgraphs  
    SCSubgraphRef SimpleMA = sc.Subgraph[0];
    SCSubgraphRef SCSimpleMA = sc.Subgraph[1];
    SCSubgraphRef SlowMA = sc.Subgraph[2];

    // And study inputs 
    SCInputRef SimpleMAPeriod = sc.Input[0];
    SCInputRef SCSimpleMAPeriod = sc.Input[1];
    SCInputRef SlowMAPeriod = sc.Input[2];
    SCInputRef Input_MovingAverageType = sc.Input[3];



    // Declare SubGraphs and inputs here
    if (sc.SetDefaults)
    {
        //Code in this section
        return;
    }
    // Data processing code	
}
So we have now initiated and named 3 sc.Subgraph. As you can see that each sc.Subgraph has a differant index starting from 0. This is something to be sure not to get wrong because if you have two sc.Subgraph with the same index they will both hold the same values for the last calculation you do with them even if they have a different name. So always double check that they all have unique indexes. And the same applies to SCInputRef. They also need a unique index. You can have up to 60 Subgraph in one study and 128 SCInputRef.

Follow me on Twitter Started this thread Reply With Quote
The following 7 users say Thank You to Trembling Hand for this post:
 
(login for full post details)
  #15 (permalink)
 Trembling Hand 
Melbourne, Land of Oz
 
Experience: Advanced
Platform: Sierra Chart, CQG
Broker: CQG
Trading: HSI
 
Posts: 206 since Jun 2011
Thanks: 19 given, 303 received

 
Code
SCSFExport scsf_SimpleMaExamples(SCStudyInterfaceRef sc)
{
    // Declare All study subgraphs  
    SCSubgraphRef SimpleMA = sc.Subgraph[0];
    SCSubgraphRef SCSimpleMA = sc.Subgraph[1];
    SCSubgraphRef SlowMA = sc.Subgraph[2];

    // And study inputs 
    SCInputRef SimpleMAPeriod = sc.Input[0];
    SCInputRef SCSimpleMAPeriod = sc.Input[1];
    SCInputRef SlowMAPeriod = sc.Input[2];
    SCInputRef Input_MovingAverageType = sc.Input[3];



    if (sc.SetDefaults)
    {

        sc.GraphName = "Simple MA Examples";
        sc.AutoLoop = 1;
        sc.GraphRegion = 0;

        SimpleMA.Name = "Simple MA";
        SimpleMA.PrimaryColor = RGB(0, 255, 0);
        SimpleMA.DrawStyle = DRAWSTYLE_DASH;
        SimpleMA.LineWidth = 1;

        SCSimpleMA.Name = "SC Simple MA";
        SCSimpleMA.PrimaryColor = RGB(0, 0, 255);
        SCSimpleMA.DrawStyle = DRAWSTYLE_LINE;
        SCSimpleMA.LineWidth = 1;

        SlowMA.Name = "Slow MA";
        SlowMA.PrimaryColor = RGB(200, 0, 0);
        SlowMA.DrawStyle = DRAWSTYLE_LINE;
        SlowMA.LineWidth = 1;


        SimpleMAPeriod.Name = "Simple MA Period";
        SimpleMAPeriod.SetInt(5);

        SCSimpleMAPeriod.Name = "SC Simple MA Period";
        SCSimpleMAPeriod.SetInt(5);

        SlowMAPeriod.Name = "Slow MA Period";
        SlowMAPeriod.SetInt(20);

        Input_MovingAverageType.Name = "Moving Average Type";
        Input_MovingAverageType.SetMovAvgType(MOVAVGTYPE_SIMPLE);

        return;
    }


    // Data processing code	
}
Ok we have declared our required Subgraphs and Inputs now we have to set the Defaults for the Study and for each of our above Subgraphs and Inputs.

The first three lines of the if (sc.SetDefaults) code block deal with the general Study settings. sc.GraphName is self explanatory. sc.AutoLoop = 1; is the important one as it tells SC that the study uses auto looping. Generally for simple Studies you use Auto looping. as your studies become more complex or require extra control you would look to use manual looping but for now you should use stick with the easier to program auto looping and get a handle on the other parts of ACSIL. Yhen sc.GraphRegion = 0; sets the study default to display on the main chart region.

Now we move on to the individual Subgraphs. For each Subgraph at a minimum in the defaults you have to set a name, sc.Subgraph[0].Name If you don't set a individual name it will not be graphed in your study. You can still use it in the study to hold values and reference in calculations but it will effectively be hidden from the chart display. The other thing to be careful of is that you don't repeat names. As like the Subgraph indexes if they are not unique they will both hold the same values for the last calculation. In the code Docs you will also notice that they use the Subgraph index instead of the declared name value we set when declaring the Subgraphs. I think its much easier to read and follow using the names but just be aware that this,

 
Code
SimpleMA.Name     = "Simple MA";
SCSimpleMA.Name     = "SC Simple MA";
SlowMA.Name        = "Slow MA";
is the same as this,
 
Code
sc.Subgraph[0].Name = "Simple MA";
sc.Subgraph[1].Name = "SC Simple MA";
sc.Subgraph[2].Name = "Slow MA";


After we set each sc.Subgraph[0].Name we have to set the default Color, DRAWSTYLE and line width. There are as always with SC a heap of setting you can control, have a look here.

Then again you have to set a sc.Input[].Name for each Input value and its a good idea to set Default values. All the default Input settings you can contraol are here,
https://www.sierrachart.com/index.php?page=doc/ACSIL_Members_scInputs.html

Follow me on Twitter Started this thread Reply With Quote
The following 7 users say Thank You to Trembling Hand for this post:
 
(login for full post details)
  #16 (permalink)
 jokertrader 
NYC, NY
 
Experience: Intermediate
Platform: Sierra, TT
Broker: N/A
Trading: Spread Researcher and crypto degen
 
Posts: 653 since May 2013
Thanks: 545 given, 360 received

This is very helpful. How about how to extract depth data from the depth files - would be good to know


Sent using the futures.io mobile app

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #17 (permalink)
 brach 
Austin
 
Experience: Intermediate
Platform: NT, SC, MT
Trading: NQ, ES, Micros
 
brach's Avatar
 
Posts: 85 since May 2018
Thanks: 181 given, 268 received

Thanks for this thread. I noticed that SC stopped maintaining VS solution and project templates so I was going to have to set that up myself for VS 2019.

Reply With Quote
 
(login for full post details)
  #18 (permalink)
 brach 
Austin
 
Experience: Intermediate
Platform: NT, SC, MT
Trading: NQ, ES, Micros
 
brach's Avatar
 
Posts: 85 since May 2018
Thanks: 181 given, 268 received

I added calls to sc.MovingAverage to populate the subgraphs for the scsf_SimpleMaExamples study.

I also changed that study's SimpleMA subgraph to use DrawStyle of line and LineStyle of dash to get a dashed-line effect.

Thanks again to @Trembling Hand for this tutorial.

 
Code
//Make sure your custom studies source code file has the following two lines at the top of the file and in this order.

// This must be exactly "sierrachart.h" to ensure you are referencing the correct header file.
#include "sierrachart.h"

// Change the text within the quote marks to what you want to name your group of custom studies. 
SCDLLName("SC_ACSIL_Examples")

//This is the basic framework of a study function.
SCSFExport scsf_SC_ACSIL_ExamplesV1(SCStudyInterfaceRef sc)
{
    // declare all study subgraphs and study inputs here

    SCSubgraphRef BarRange = sc.Subgraph[0];
    SCInputRef BarRangeMultiplier = sc.Input[0];

    if (sc.SetDefaults)
    {
        // set all display and input defaults here
        sc.GraphName = "SC_ACSIL_ExamplesV1";
        sc.StudyDescription = "Simple study to show basic concepts";
        sc.AutoLoop = 1;

        BarRange.Name = "Bar Range";
        BarRange.DrawStyle = DRAWSTYLE_BAR;
        BarRange.PrimaryColor = RGB(255, 0, 0);

        BarRangeMultiplier.Name = "Bar Range Multiplier";
        BarRangeMultiplier.SetInt(2);
        
        return;
    }
    // Data processing code	
    BarRange[sc.Index] = sc.High[sc.Index] - sc.Low[sc.Index];

    SCString DataString;
    DataString.Format("Bar Index: %d, High: %f, Low: %f BarRange: %f", sc.Index, sc.High[sc.Index], sc.Low[sc.Index], BarRange[sc.Index]);
    
    float DoubleBarRange = BarRange[sc.Index] * BarRangeMultiplier.GetInt();
    DataString.AppendFormat(", BarRangeX2: %.2f", DoubleBarRange);

    sc.AddMessageToLog(DataString, 0);
}

SCSFExport scsf_SimpleMaExamples(SCStudyInterfaceRef sc)
{
    // Declare All study subgraphs  
    SCSubgraphRef SimpleMA = sc.Subgraph[0];
    SCSubgraphRef SCSimpleMA = sc.Subgraph[1];
    SCSubgraphRef SlowMA = sc.Subgraph[2];

    // And study inputs 
    SCInputRef SimpleMAPeriod = sc.Input[0];
    SCInputRef SCSimpleMAPeriod = sc.Input[1];
    SCInputRef SlowMAPeriod = sc.Input[2];
    SCInputRef Input_MovingAverageType = sc.Input[3];

    if (sc.SetDefaults)
    {

        sc.GraphName = "Simple MA Examples";
        sc.AutoLoop = 1;
        sc.GraphRegion = 0;

        SimpleMA.Name = "Simple MA";
        SimpleMA.PrimaryColor = RGB(0, 255, 0);
        SimpleMA.DrawStyle = DRAWSTYLE_LINE;
        SimpleMA.LineStyle = LINESTYLE_DASH;
        SimpleMA.LineWidth = 1;

        SCSimpleMA.Name = "SC Simple MA";
        SCSimpleMA.PrimaryColor = RGB(0, 0, 255);
        SCSimpleMA.DrawStyle = DRAWSTYLE_LINE;
        SCSimpleMA.LineWidth = 1;

        SlowMA.Name = "Slow MA";
        SlowMA.PrimaryColor = RGB(200, 0, 0);
        SlowMA.DrawStyle = DRAWSTYLE_LINE;
        SlowMA.LineWidth = 1;


        SimpleMAPeriod.Name = "Simple MA Period";
        SimpleMAPeriod.SetInt(5);

        SCSimpleMAPeriod.Name = "SC Simple MA Period";
        SCSimpleMAPeriod.SetInt(10);

        SlowMAPeriod.Name = "Slow MA Period";
        SlowMAPeriod.SetInt(20);

        Input_MovingAverageType.Name = "Moving Average Type";
        Input_MovingAverageType.SetMovAvgType(MOVAVGTYPE_SIMPLE);

        return;
    }

    // Data processing code	

    sc.MovingAverage(
        sc.BaseDataIn[SC_LAST],
        SimpleMA,
        Input_MovingAverageType.GetMovAvgType(),
        SimpleMAPeriod.GetInt());

    sc.MovingAverage(
        sc.BaseDataIn[SC_LAST],
        SCSimpleMA,
        Input_MovingAverageType.GetMovAvgType(),
        SCSimpleMAPeriod.GetInt());

    sc.MovingAverage(
        sc.BaseDataIn[SC_LAST],
        SlowMA,
        Input_MovingAverageType.GetMovAvgType(),
        SlowMAPeriod.GetInt());
}

Reply With Quote
The following 2 users say Thank You to brach for this post:
 
(login for full post details)
  #19 (permalink)
Kuuluud
Revali, EE
 
 
Posts: 47 since Aug 2015
Thanks: 1 given, 82 received


jokertrader View Post
This is very helpful. How about how to extract depth data from the depth files - would be good to know


Sent using the futures.io mobile app

+1 for that. That would be really helpful to know

Reply With Quote
 
(login for full post details)
  #20 (permalink)
mosalem2003
Toronto
 
 
Posts: 94 since Apr 2019
Thanks: 94 given, 22 received


Thanks for the valuable thread, and hope it can continue with trading system turorials.
  1. How to import SC studies to be used in a trading system code ?
  2. Should I import the whole code of that study in the new trading system code to use it?
I assume it is part of the SC library and we have the two lines at the front of the code to import it but it seems this is only working for ACSIL interface members that can be called by using sc.membername

Is there any sample code for importing studies?
The only examples in the ACS source is only for using sc.movingavg which is a member function of ACSIL and not a study ..

If I would like to import SCSFExport scsf_HighLowForTimePeriodExtendedLines(SCStudyInterfaceRef sc how to do this ..

I would appreciate anyone refer to me to a code example for trading systems that import other SC studies... I was doing this so easily in the spreadsheets but not sure how to do it in ACSIL ..

Thanks for the examples in advance...

Reply With Quote


futures io Trading Community Platforms and Indicators Sierra Chart > Sierra Chart ACSIL for Beginners.


Last Updated on June 14, 2022


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
     



Copyright © 2022 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada), info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts