NexusFi: Find Your Edge


Home Menu

 





SC programming help. Newbie question.


Discussion in Sierra Chart

Updated
    1. trending_up 2,262 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 5 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
gryandc
Amsterdam
 
Posts: 8 since Nov 2015
Thanks Given: 8
Thanks Received: 0

Hi all!

I'm trying to create a simple (I thought it would be simple!) study using sc.GetStudyArrayUsingID() to overlay onto my volume by price study. Maybe I shouldn't be using this function?

I am wanting to draw a horizontal line based on a calculation involving either the high or low of the day and the POC.

I would like to add the POC to the low of the day value if the POC is above the mid point of the day (another line that I have on the chart)

or

If the POC is below the mid point of the day I would like the POC subtracted from the high of the day.

I hope this makes sense!

Any help greatly appreciated.

Thanks Gordon


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
SEC and CFTC Unlock Customer Cross-Margining for Treasur …
Treasury Notes and Bonds
Thanks Mike. Godspeed.
The Elite Circle
Trump Truth Social Fires Hormuz From 10% to 59% -- Arsen …
Prediction Markets & Event Contracts
BofA Projects $1.1 Trillion in Sports Event Contracts -- …
Prediction Markets & Event Contracts
Four New E-mini Futures Launch June 29 -- Russell 3000, …
Emini and Emicro Index
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
205 thanks
Sober Journey With S&P
21 thanks
30 Sessions
21 thanks
Volume Indicators
8 thanks
Thanks Mike. Godspeed.
7 thanks
  #3 (permalink)
 hobart 
charlotte nc
 
Experience: Master
Platform: Sierra Chart, TOS, Tradestation, NinjaTrader
Trading: energy
Posts: 114 since Jul 2012
Thanks Given: 81
Thanks Received: 172


busy trading, but this code shows examples of how to reference other studies to perform secondary work on them

 
Code
// The top of every source code file must include this line
// SM_CCI_Alerts.cpp

#include "sierrachart.h"
#include <math.h>


/*****************************************************************************

	For reference, you want to look at the Advanced Custom Study Interface
	and Language documentation on the Sierra Chart website. 
	
*****************************************************************************/


// This line is required.
// Change the text within the quote marks to what you want to name
// your group of custom studies. 

SCDLLName("SM_CCI_Alerts DLL") 

//This is an empty study function.  Auto looping is enabled. 
SCSFExport scsf_CCI_Alerts_SM(SCStudyGraphRef sc)
{

	// Section 1 - Set the configuration variables     
	
	if (sc.SetDefaults)  // This section only run once upon adding an instance of the study to a chart
	{
		// Set the configuration and defaults
		
		sc.GraphName = "SM_CCI_Alerts";
		
		sc.StudyDescription = "CCI Alerts";
		
		sc.AutoLoop = 1;  // true
		
		sc.GraphRegion = 0;  // On main price chart.
		
		//sc.AlertOnlyOncePerBar = 1;
		
		// Uncomment the following line when you're done with your
		// development.  This makes calling your function faster.
		sc.FreeDLL = 0;  // Production setting
		//sc.FreeDLL = 1;  // Development setting
				
		return;
		
	}
		
	
	// Everything below here is run on every chart update or when the chart is
	// reloaded.
	
		sc.CCI(
			sc.BaseDataIn[SC_HLC],  // This is the input array or source data -- this is using the Last or Close from each bar
			sc.Subgraph[0],  // This designates your output array (subgraph/plot) -- this is using Subgraph 1
			sc.Index,  // This parameter is always sc.CurrentIndex
			5, 0.015);  // This is the length for the CCI and float multiplier, which is from Input 0
			
		sc.CCI(
			sc.BaseDataIn[SC_HLC],  // This is the input array or source data -- this is using the Last or Close from each bar
			sc.Subgraph[1],  // This designates your output array (subgraph/plot) -- this is using Subgraph 1
			sc.Index,  // This parameter is always sc.CurrentIndex
			20, 0.015);  // This is the length for the CCI and float multiplier, which is from Input 0
			
		sc.CCI(
			sc.BaseDataIn[SC_HLC],  // This is the input array or source data -- this is using the Last or Close from each bar
			sc.Subgraph[2],  // This designates your output array (subgraph/plot) -- this is using Subgraph 1
			sc.Index,  // This parameter is always sc.CurrentIndex
			50, 0.015);  // This is the length for the CCI and float multiplier, which is from Input 0
	

		
		//  This section is checking for CCI locations/values  //
	
		if (sc.Subgraph[0][sc.Index] >= 100)
			if (sc.Subgraph[1][sc.Index] >= 100)
				if (sc.Subgraph[2][sc.Index] >= 100)
					sc.SetAlert(7);   // all CCI's in pos. zoom
					
		if (sc.Subgraph[0][sc.Index] <= -100)
			if (sc.Subgraph[1][sc.Index] <= -100)
				if (sc.Subgraph[2][sc.Index] <= -100)
					sc.SetAlert(8);	  // all CCI's in neg. zoom
			
		float CCIdiff = abs(sc.Subgraph[0][sc.Index] - sc.Subgraph[2][sc.Index]);
		
		if (sc.Subgraph[0][sc.Index] > sc.Subgraph[2][sc.Index])
			if (CCIdiff >= 150)
				sc.SetAlert(9);  // snap back down
				
		if (sc.Subgraph[0][sc.Index] < sc.Subgraph[2][sc.Index])
			if (CCIdiff >= 150)
				sc.SetAlert(10);  // snap back UP
		
	
}


Reply With Quote
Thanked by:
  #4 (permalink)
gryandc
Amsterdam
 
Posts: 8 since Nov 2015
Thanks Given: 8
Thanks Received: 0

Thanks hobart,

Appreciate the reply during the trading day.
I still have a fair bit of study to do because that is still making very little sense to me! lol

Gordon


Reply With Quote
  #5 (permalink)
 hobart 
charlotte nc
 
Experience: Master
Platform: Sierra Chart, TOS, Tradestation, NinjaTrader
Trading: energy
Posts: 114 since Jul 2012
Thanks Given: 81
Thanks Received: 172

 
Code
sc.CCI(
			sc.BaseDataIn[SC_HLC],  // This is the input array or source data -- this is using the Last or Close from each bar
			sc.Subgraph[2],  // This designates your output array (subgraph/plot) -- this is using Subgraph 1
			sc.Index,  // This parameter is always sc.CurrentIndex
			50, 0.015);  // This is the length for the CCI and float multiplier, which is from Input 0
	

		
				if (sc.Subgraph[2][sc.Index] >= 100)
					sc.SetAlert(7);   // all CCI's in pos. zoom
In this snippit, i call the built in study CCI, store the result in sc.Subgraph[2], then reference if its current bar value (sc.index) is greater than 100.


Reply With Quote
  #6 (permalink)
gryandc
Amsterdam
 
Posts: 8 since Nov 2015
Thanks Given: 8
Thanks Received: 0

Great, Thanks again for the information Hobart.

I am slowly getting there, and all of this helps.

Gordon


Reply With Quote




Last Updated on November 23, 2015


© 2026 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 - Downloads - Top
no new posts