NexusFi: Find Your Edge


Home Menu

 





Questions and discussion for Sierra Chart ACSIL for Beginners


Discussion in Sierra Chart

Updated
      Top Posters
    1. looks_one Trembling Hand with 43 posts (35 thanks)
    2. looks_two mosalem2003 with 40 posts (0 thanks)
    3. looks_3 1m1k3 with 20 posts (0 thanks)
    4. looks_4 bradhouser with 6 posts (9 thanks)
      Best Posters
    1. looks_one bobwest with 3.5 thanks per post
    2. looks_two bradhouser with 1.5 thanks per post
    3. looks_3 brach with 1 thanks per post
    4. looks_4 Trembling Hand with 0.8 thanks per post
    1. trending_up 28,140 views
    2. thumb_up 53 thanks given
    3. group 30 followers
    1. forum 119 posts
    2. attach_file 25 attachments




 
Search this Thread

Questions and discussion for Sierra Chart ACSIL for Beginners

  #101 (permalink)
1m1k3
Budapest, Hungary
 
Posts: 21 since Dec 2022
Thanks Given: 4
Thanks Received: 0

Hi everyone,

I have two questions.
1, How can I limit the number of bars the study would use for the calculations. So it wouldn't make a full chart calculation when I open the chartbook, refresh the chart or change the time frame.

2, How can I make a separator line in the Study Settings Menu?
Like this:


I did look through the Input array section but couldn't find anything which would do this.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
ZombieSqueeze
Platforms and Indicators
 
  #102 (permalink)
bradhouser
Northern California where the girls are warm
 
Posts: 122 since Nov 2010
Thanks Given: 15
Thanks Received: 72


1m1k3 View Post
Hi everyone,

I have two questions.
1, How can I limit the number of bars the study would use for the calculations. So it wouldn't make a full chart calculation when I open the chartbook, refresh the chart or change the time frame.

2, How can I make a separator line in the Study Settings Menu?

1. Assume auto looping and you want a maximum of 1000 bars, put this before the calculations:
 
Code
if (sc.Index < sc.ArraySize - 1000)
   return;
2. Create an SCInputRef variable and call it Line1 or something.
 
Code
Line1.Name = "-------------- ENTRY SETTINGS ---------------";
Line1.SetString("----------------------");

Reply With Quote
Thanked by:
  #103 (permalink)
1m1k3
Budapest, Hungary
 
Posts: 21 since Dec 2022
Thanks Given: 4
Thanks Received: 0



bradhouser View Post
1. Assume auto looping and you want a maximum of 1000 bars, put this before the calculations:
 
Code
if (sc.Index < sc.ArraySize - 1000)
   return;
2. Create an SCInputRef variable and call it Line1 or something.
 
Code
Line1.Name = "-------------- ENTRY SETTINGS ---------------";
Line1.SetString("----------------------");

I tried the sc.ArraySize but without the if and the sc.Index part. I thought I have to declare it. And I was trying with the SetString input too but the information on the SC site was not enough for my knowledge.
I still have a lot to learn.

Thank you for the quick respond!

Reply With Quote
  #104 (permalink)
1m1k3
Budapest, Hungary
 
Posts: 21 since Dec 2022
Thanks Given: 4
Thanks Received: 0

Hi everyone,

I've run into another puzzle. I'd like make a bar period changer study which works according another chart's bar period.
For this I set this study onto Chart#1:

 
Code
SCSFExport scsf_BarPeriodReading(SCStudyInterfaceRef sc)
{
	SCSubgraphRef TimeFrame = sc.Subgraph[0];
	
	if (sc.SetDefaults)
	{
		// Set the configuration and defaults.

		sc.GraphName = "Bar Period Reading";

		sc.AutoLoop = 0;
		sc.GraphRegion = 0;
		sc.UpdateAlways = 1;
		
		TimeFrame.Name = "TF";
		TimeFrame.DrawStyle = DRAWSTYLE_IGNORE;
		TimeFrame.PrimaryColor = RGB(0,128,0);
		
		return;
	}

	
	n_ACSIL::s_BarPeriod BarPeriod;
	sc.GetBarPeriodParameters(BarPeriod);

	if (BarPeriod.ChartDataType == INTRADAY_DATA && BarPeriod.IntradayChartBarPeriodType == IBPT_DAYS_MINS_SECS)
	{
		int SecondsPerBar = BarPeriod.IntradayChartBarPeriodParameter1;
	}

	TimeFrame[sc.Index] = BarPeriod.IntradayChartBarPeriodParameter1;
	

}

...and set this study onto Chart#2:

 
Code
SCSFExport scsf_TF_Receiver2(SCStudyInterfaceRef sc)
{
	SCInputRef ChartStudy = sc.Input[0];
	SCInputRef MultiPlier = sc.Input[1];

	// Set configuration variables

	if (sc.SetDefaults)
	{
		// Set the configuration and defaults

		sc.GraphName = "TF Receiver 2";
		sc.CalculationPrecedence = LOW_PREC_LEVEL;
		sc.StudyVersion = 10;
		sc.AutoLoop = 0;

		ChartStudy.Name = "Study Reference";
		ChartStudy.SetChartStudyValues(1, 1);
		MultiPlier.Name = "Multiplier Value";
		MultiPlier.SetInt(3);
				
		return;
	}

	// Array references

	// Define a graph data object to get all of the study data
	SCGraphData StudyData;

	// Get the index in the specified chart that is 
	// nearest to current index.
	int RefChartIndex = sc.GetNearestMatchForDateTimeIndex(ChartStudy.GetChartNumber(), sc.Index);


	// Get the study data from the specified chart
	sc.GetStudyArraysFromChartUsingID(ChartStudy.GetChartNumber(), ChartStudy.GetStudyID(), StudyData);

	// Define a reference to the first Subgraph array
	SCFloatArrayRef BarPeriodReference = StudyData[0];

	// Array is empty. Nothing to do.
	if (BarPeriodReference.GetArraySize() == 0)
		return;

	// Get the index in the specified chart that is nearest
	// to current index.
	RefChartIndex = sc.GetNearestMatchForDateTimeIndex(ChartStudy.GetChartNumber(), sc.Index);

	float NearestSubgraphValue = BarPeriodReference[RefChartIndex];

	// Get the index in the specified chart that contains 
	// the DateTime of the bar at the current index.
	RefChartIndex = sc.GetContainingIndexForDateTimeIndex(ChartStudy.GetChartNumber(), sc.Index);

	float ContainingSubgraphValue = BarPeriodReference[RefChartIndex];

	// Get the index in the specified chart that exactly
	// matches the DateTime of the current index.
	RefChartIndex = sc.GetExactMatchForSCDateTime(ChartStudy.GetChartNumber(), sc.BaseDateTimeIn[sc.Index]);

	if (RefChartIndex != -1)					//-1 means that there was not an exact match and therefore we do not have a valid index to work with
	{
		float ExactMatchSubgraphValue = BarPeriodReference[RefChartIndex];
	}

	float NewTF = (BarPeriodReference[RefChartIndex] * MultiPlier.GetInt());

	
	SCString DebugString;
	DebugString.Format("TF Ref: %f, NewTF: %f", BarPeriodReference[RefChartIndex], NewTF);

	sc.AddMessageToLog(DebugString, 1);
}
When I change the bar period on the Chart#1 the study sets the wanted bar period on the Chart#2 but in that instant something resets the BarPeriodReference[RefChartIndex] to zero which makes the Chart#2 to recalculate. Then the study sets the wanted bar period and make the reset again. And this goes on till the current bar on chart#2 closes and with the new bar stops and stays as it should.

What should I modify to avoid that reset and the whole annoying recalculete process?

Thanks.

Reply With Quote
  #105 (permalink)
1m1k3
Budapest, Hungary
 
Posts: 21 since Dec 2022
Thanks Given: 4
Thanks Received: 0

It seem for some reason I didn't copy the whole code.
So here it is again:

 
Code
SCSFExport scsf_TF_Receiver2(SCStudyInterfaceRef sc)
{
	SCInputRef ChartStudy = sc.Input[0];
	SCInputRef MultiPlier = sc.Input[1];

	// Set configuration variables

	if (sc.SetDefaults)
	{
		// Set the configuration and defaults

		sc.GraphName = "TF Receiver 2";
		sc.CalculationPrecedence = LOW_PREC_LEVEL;
		sc.StudyVersion = 10;
		sc.AutoLoop = 0;

		ChartStudy.Name = "Study Reference";
		ChartStudy.SetChartStudyValues(1, 1);
		MultiPlier.Name = "Multiplier Value";
		MultiPlier.SetInt(3);
				
		return;
	}

	// Array references

	// Define a graph data object to get all of the study data
	SCGraphData StudyData;

	// Get the index in the specified chart that is 
	// nearest to current index.
	int RefChartIndex = sc.GetNearestMatchForDateTimeIndex(ChartStudy.GetChartNumber(), sc.Index);


	// Get the study data from the specified chart
	sc.GetStudyArraysFromChartUsingID(ChartStudy.GetChartNumber(), ChartStudy.GetStudyID(), StudyData);

	// Define a reference to the first Subgraph array
	SCFloatArrayRef BarPeriodReference = StudyData[0];

	// Array is empty. Nothing to do.
	if (BarPeriodReference.GetArraySize() == 0)
		return;

	// Get the index in the specified chart that is nearest
	// to current index.
	RefChartIndex = sc.GetNearestMatchForDateTimeIndex(ChartStudy.GetChartNumber(), sc.Index);

	float NearestSubgraphValue = BarPeriodReference[RefChartIndex];

	// Get the index in the specified chart that contains 
	// the DateTime of the bar at the current index.
	RefChartIndex = sc.GetContainingIndexForDateTimeIndex(ChartStudy.GetChartNumber(), sc.Index);

	float ContainingSubgraphValue = BarPeriodReference[RefChartIndex];

	// Get the index in the specified chart that exactly
	// matches the DateTime of the current index.
	RefChartIndex = sc.GetExactMatchForSCDateTime(ChartStudy.GetChartNumber(), sc.BaseDateTimeIn[sc.Index]);

	if (RefChartIndex != -1)					//-1 means that there was not an exact match and therefore we do not have a valid index to work with
	{
		float ExactMatchSubgraphValue = BarPeriodReference[RefChartIndex];
	}

	float NewTF = (BarPeriodReference[RefChartIndex] * MultiPlier.GetInt());
	
	n_ACSIL::s_BarPeriod BarPeriod;
	sc.GetBarPeriodParameters(BarPeriod);


	if (BarPeriod.ChartDataType == INTRADAY_DATA && BarPeriod.IntradayChartBarPeriodType == IBPT_DAYS_MINS_SECS)
	{
		int SecondsPerBar = BarPeriod.IntradayChartBarPeriodParameter1;
	}
	
	if (BarPeriod.ChartDataType != INTRADAY_DATA
		|| BarPeriod.IntradayChartBarPeriodType != IBPT_DAYS_MINS_SECS
		|| BarPeriod.IntradayChartBarPeriodParameter1 != NewTF)
	{
		n_ACSIL::s_BarPeriod NewBarPeriod;
		NewBarPeriod.ChartDataType = INTRADAY_DATA;
		NewBarPeriod.IntradayChartBarPeriodType = IBPT_DAYS_MINS_SECS;
		NewBarPeriod.IntradayChartBarPeriodParameter1 = NewTF;
		
		//Set the bar period parameters. This will go into effect after the study function returns.
		sc.SetBarPeriodParameters(NewBarPeriod);
	}
	
	
	SCString DebugString;
	DebugString.Format("TF Ref: %f, NewTF: %f", BarPeriodReference[RefChartIndex], NewTF);

	sc.AddMessageToLog(DebugString, 1);
}
Thanks.

Reply With Quote
  #106 (permalink)
 58LesPaul 
Owensboro, KY
 
Platform: TradingView
Trading: ES/NQ
Posts: 198 since Sep 2015
Thanks Given: 197
Thanks Received: 101

I'm trying to write my first study/code but when It shows up in SC studies it says Template Function. What does that mean? It doesn't show anything when added to a chart..

Thanks

Reply With Quote
  #107 (permalink)
 Trembling Hand 
Melbourne, Land of Oz
 
Experience: Advanced
Platform: Sierra Chart, CQG
Broker: CQG
Trading: HSI
Posts: 246 since Jun 2011
Thanks Given: 28
Thanks Received: 360


58LesPaul View Post
I'm trying to write my first study/code but when It shows up in SC studies it says Template Function. What does that mean? It doesn't show anything when added to a chart..

Thanks

Impossible to tell without you posting your code to check.

Follow me on Twitter Started this thread Reply With Quote
  #108 (permalink)
1m1k3
Budapest, Hungary
 
Posts: 21 since Dec 2022
Thanks Given: 4
Thanks Received: 0


Trembling Hand View Post
Impossible to tell without you posting your code to check.

Hello,

How about my code? The bar period changer. I keep putting aside then try again with renewed enthusiasm but I can't figure out why doesn't work properly.

Could you have a look at it?

Pleeeeeese

Thanks!

Reply With Quote
  #109 (permalink)
 Trembling Hand 
Melbourne, Land of Oz
 
Experience: Advanced
Platform: Sierra Chart, CQG
Broker: CQG
Trading: HSI
Posts: 246 since Jun 2011
Thanks Given: 28
Thanks Received: 360


1m1k3 View Post
Hello,

How about my code? The bar period changer. I keep putting aside then try again with renewed enthusiasm but I can't figure out why doesn't work properly.

Could you have a look at it?

Pleeeeeese

Thanks!

You don't need a study to do that. You can use the link numbers and bar period and chart settings.

Follow me on Twitter Started this thread Reply With Quote
  #110 (permalink)
1m1k3
Budapest, Hungary
 
Posts: 21 since Dec 2022
Thanks Given: 4
Thanks Received: 0



Trembling Hand View Post
You don't need a study to do that. You can use the link numbers and bar period and chart settings.

I can't set any multiplier number in the chart settings.
In nut shell... I want to change a chart's bar period with a pre set multiplier number by changing another chart's bar period.
For example I change the bar period on chart 1 from 25 sec to 30 sec then chart 2's bar period does change from 75 sec to 90 sec because I set the multiplier to 3.

Therefore I wrote a study to read the bar period and put that into a subgraph. This study is on chart 1.
And another study which gets that subgraph multiply it and set the bar period to that number. This study is on chart 2.
But it's not working properly. Sometimes works fine but most of the times something keep makes the chart 2 to recalculate for a while as if I'd press tha 'Insert' button continuously.

Reply With Quote




Last Updated on April 23, 2024


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts