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)
  #21 (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

Hi guys been busy on a project so had to let this slide for a while.

mosalem2003 View Post
  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'll put up another example later today/tomorrow to show this but if you cannot wait you use one of these ACSIL functions to reference the array/s in a study on the same chart (scGetStudyArray) and/or different chart(scGetStudyArrayFromChart) and place the array/s you want to use in a SCFloatArray or Subgraph in your new Study.

sc.GetStudyArraysFromChart()

sc.GetStudyArraysFromChartUsingID()

EDIT (sorry about the lack of hyperlink this forum is dropping the end tag off the links??!!)

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

Can you help answer these questions
from other members on futures io?
NT8 - Footprint Chart adding on code
NinjaTrader
1 Minute Harmonic rotations for HHI/HSI - HKEX Futures
Traders Hideout
S&R, S&D Help Advise
Traders Hideout
Standing Desks
The Elite Circle
 
 
(login for full post details)
  #22 (permalink)
mosalem2003
Toronto
 
 
Posts: 94 since Apr 2019
Thanks: 94 given, 22 received

Thanks a lot for your prompt response Trembling Hand... I will stay tuned for your detailed example and thanks a lot for the thread... Kindly keep it alive here as it is my first day to find it and it has a lot of invaluable information...

Reply With Quote
 
(login for full post details)
  #23 (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 here is a quick and dirty example of using the arrays and input settings in a study to use as triggers for events in another study. This could be used for a trading system or another study. Using the requested scsf_HighLowForTimePeriodExtendedLines study it gets the two H/L arrays for the set time period from that study and puts them in local array SCFloatArray and it also gets the end time input for that study to check if that time has passed.

I've just used simple logic to print to the log but it would be the same to trigger for a trade. Basically it checks if the current bar start time is > or = to the ending time set in the HighLowForTimePeriod. Then checks once per bar if the close one bar ago is higher or lower than the H/L in the first study. If so prints out to the log the result.


 
Code
SCSFExport scsf_Study_Reference(SCStudyInterfaceRef sc)
{

    SCInputRef Input_StudySubgraph1 = sc.Input[0];
    SCInputRef Input_StudySubgraph2 = sc.Input[1];


    // Set configuration variables

    if (sc.SetDefaults)
    {
        sc.GraphName = "Study Reference";

        Input_StudySubgraph1.Name = "Input Study 1";
        Input_StudySubgraph1.SetStudySubgraphValues(0, 0);

        Input_StudySubgraph2.Name = "Input Study 2";
        Input_StudySubgraph2.SetStudySubgraphValues(0, 0);


        sc.CalculationPrecedence = VERY_LOW_PREC_LEVEL;

        sc.AutoLoop = 1;

        return;
    }


    // Get the array for the specified Input Data from the specified studies
    SCFloatArray HighforTimePeriodArray;
    sc.GetStudyArrayUsingID(Input_StudySubgraph1.GetStudyID(), Input_StudySubgraph1.GetSubgraphIndex(), HighforTimePeriodArray);

    SCFloatArray LowforTimePeriodArray;
    sc.GetStudyArrayUsingID(Input_StudySubgraph2.GetStudyID(), Input_StudySubgraph2.GetSubgraphIndex(), LowforTimePeriodArray);

    // Get the end Time for H/L study
    int EndTimeInput;
    sc.GetChartStudyInputInt(sc.ChartNumber, Input_StudySubgraph1.GetStudyID(), 1, EndTimeInput);

    // Get the time of the bar at the current index
    int CurrentBarTime = sc.BaseDateTimeIn[sc.Index].GetTimeInSeconds();


    // Process once per bar
    int& LastBarIndexProcessed = sc.GetPersistentInt(11);
    if (sc.Index == 0)
        LastBarIndexProcessed = -1;
    if (sc.Index == LastBarIndexProcessed)
        return;
    LastBarIndexProcessed = sc.Index;

    // Logic for signal

    // Declare a new SCString
    SCString SignalString;

    if (CurrentBarTime >= EndTimeInput) {

        // Long signal logic
        if (sc.Close[sc.Index - 1] > HighforTimePeriodArray[sc.Index - 1])
        {
            SignalString.Format("Long Signal! Close: %.2f > HighforTimePeriod: %.2f ", sc.Close[sc.Index - 1], HighforTimePeriodArray[sc.Index - 1]);
        }
        // short signal logic
        else if (sc.Close[sc.Index - 1] < LowforTimePeriodArray[sc.Index - 1])
        {
            SignalString.Format("Short Signal!  Close: %.2f < LowforTimePeriod: %.2f", sc.Close[sc.Index - 1], LowforTimePeriodArray[sc.Index - 1]);
        }
        // no trigger logic
        else
        {
            SignalString.Format("No Signal", EndTimeInput, CurrentBarTime);
        }
    }
    // before H/L for time period has ended
    else {
        SignalString.Format("CurrentBarTime %d < EndTime %d",  CurrentBarTime , EndTimeInput);
    }

    // Finally print our SignalString to Sierra Charts Log
    sc.AddMessageToLog(SignalString, 0);

}
Things to note.
Of course for this to work you need the scsf_HighLowForTimePeriodExtendedLines study on a chart and reference it as per the screen shot.
When referencing other studies you should set the sc.CalculationPrecedence to LOW_PREC_LEVEL or VERY_LOW_PREC_LEVEL to ensure that the first study has finished doing its calculations before using the values. Also note the logic that makes this study calculate just ONCE per new bar.

Attached Thumbnails
Click image for larger version

Name:	2020-12-10 13_57_50-Window.png
Views:	265
Size:	52.0 KB
ID:	307208  
Follow me on Twitter Started this thread Reply With Quote
The following 5 users say Thank You to Trembling Hand for this post:
 
(login for full post details)
  #24 (permalink)
mosalem2003
Toronto
 
 
Posts: 94 since Apr 2019
Thanks: 94 given, 22 received

No rush at all... Just to let you know , I am patiently looking forward for your follow-up examples regarding importing an on chart-studies data to the trading system... Thanks a lot in advance and have a nice day ...

Reply With Quote
 
(login for full post details)
  #25 (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


mosalem2003 View Post
No rush at all... Just to let you know , I am patiently looking forward for your follow-up examples regarding importing an on chart-studies data to the trading system... Thanks a lot in advance and have a nice day ...

Hey? Isn't that what the above example is? Its importing data from one study into another and using it.

Follow me on Twitter Started this thread Reply With Quote
 
(login for full post details)
  #26 (permalink)
mosalem2003
Toronto
 
 
Posts: 94 since Apr 2019
Thanks: 94 given, 22 received

Thanks a lot for the comprehensive example. sorry, I am new to the forum and for some reason I didn't get a notification update by email. I will study the example, and post questions if any... Once again, thanks a lot for your prompt support and efforts. Highly appreciated indeed!

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

Very few minor questions as I am new to c++ , thanks for your answer in advance ...

 
Code
 int EndTimeInput;
 sc.GetChartStudyInputInt(sc.ChartNumber, Input_StudySubgraph1.GetStudyID(), 1, EndTimeInput);
Should we change the input index to 2 as End time is In:2 for the HighLowforTmePeriod-Extended study ?

/
 
Code
/ Process once per bar
    int& LastBarIndexProcessed = sc.GetPersistentInt(11);

///Q**: Why there is a "&" appended to int ?
 --- why 11 is the index for GetPersistentInt ? 
does this mean this variable will remain 
unchanged for the program all time of execution ?

    if (sc.Index == 0)
        LastBarIndexProcessed = -1;
//Q** Does this mean when we reach the last bar, you set the integer to -1 
    if (sc.Index == LastBarIndexProcessed)

//Q*** then if we reach "after" the last bar the index will be -1 "
--can this happen-- I assumed the index is from 0 to n - index can be negative? "
,  and then we exit the whole chart bars initial calculations
 and we only work again if there is a new bar ?

        return;
    LastBarIndexProcessed = sc.Index;

 
Code
  sc.AutoLoop = 1;
Should we set it =0 when we finish the development
as I noticed if it is 1 the performance is too slow in general ?

Reply With Quote
 
(login for full post details)
  #28 (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


mosalem2003 View Post
Should we change the input index to 2 as End time is In:2 for the HighLowforTmePeriod-Extended study ?

No have a look at the docs for that function and familiarise yourself with what zero indexing is.
"InputIndex: The zero-based index of the Input to get the value for. The Input index values + 1 are displayed in the Inputs list on the Study Settings window for the study. Example: (In:1)."


mosalem2003 View Post
 
Code
  sc.AutoLoop = 1;
Should we set it =0 when we finish the development
as I noticed if it is 1 the performance is too slow in general ?

Again No. Have a look at what auto looping does in the docs. I covered it in post #8 of this thread but have a look in the docs. Its very important that you understand this - without auto looping you have to programmatically control the array indexes.

Follow me on Twitter Started this thread Reply With Quote
The following user says Thank You to Trembling Hand for this post:
 
(login for full post details)
  #29 (permalink)
mosalem2003
Toronto
 
 
Posts: 94 since Apr 2019
Thanks: 94 given, 22 received

 
Code
 int CurrentBarTime = sc.BaseDateTimeIn[sc.Index].GetTimeInSeconds();

 
Code
                  if (Result > 0) //If there has been a successful order entry, then draw an arrow at the low of the bar.
		   {
			Subgraph_BuyEntry[sc.Index-1] = sc.Low[sc.Index-1];
		    SignalString.Format("Buy Limit 1: %.2f & Buy Target1: %.2f & CurrentBarTime: %d", NewOrder.Price1, NewOrder.Price1+ NewOrder.Target1Offset, CurrentBarTime);
			sc.AddMessageToLog(SignalString, 0);
			
		   }
This is a sample of what is printed in the message log:

<< Sell Limit 3 : 3611.00 & Sell Target3: 3606.00 & CurrentBarTime: 50640 | 2020-12-15 18:38:25.489>>

How to print the CurrentBarTime to the Message log in <<Date, HH, MM, SS>> format -- I have coded it as above and it prints the time of the bar in numerical value of seconds which is not readable ?

Reply With Quote
 
(login for full post details)
  #30 (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



mosalem2003 View Post
This is a sample of what is printed in the message log:

<< Sell Limit 3 : 3611.00 & Sell Target3: 3606.00 & CurrentBarTime: 50640 | 2020-12-15 18:38:25.489>>

How to print the CurrentBarTime to the Message log in <<Date, HH, MM, SS>> format -- I have coded it as above and it prints the time of the bar in numerical value of seconds which is not readable ?

https://www.sierrachart.com/index.php?page=doc/SCDateTime.html

#SCDateTimeMember_GetDateTimeYMDHMS
 
Code
int Year, Month, Day, Hour, Minute, Second;

SCDateTimeVariable.GetDateTimeYMDHMS(Year, Month, Day, Hour, Minute, Second);

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


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