NexusFi: Find Your Edge


Home Menu

 





Need help modifying an existing SC study


Discussion in Sierra Chart

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




 
Search this Thread
  #1 (permalink)
 boze man 
South Jersey
 
Experience: Advanced
Platform: Sierra
Broker: IB
Trading: ES, CL
Posts: 98 since Apr 2011
Thanks Given: 21
Thanks Received: 62

I want to modify the stock 'Highest High Lowest Low over N bars' study to include the "use current bar value" input (see below)

I have been able to hack this piece of code into some of the easier studies (SCStudyGraphRef sg.) but not the more complex (SCStudyInterfaceRef sc.)

 
Code
sg.Input[5].Name="Use current bar value?";
sg.Input[5].SetYesNo(0);  // No
Here is the code for HH LL over N bars from STUDIES7.cpp

Thanks in advance for any help

 
Code
/*==========================================================================*/
SCSFExport scsf_HighestHighLowestLowOverNBars(SCStudyInterfaceRef sc)
{
	SCSubgraphRef HighestHigh = sc.Subgraph[0];
	SCSubgraphRef LowestLow = sc.Subgraph[1];

	SCInputRef Length = sc.Input[3];
	SCInputRef InputDataHigh = sc.Input[5];
	SCInputRef InputDataLow = sc.Input[6];

	if (sc.SetDefaults)
	{
		sc.GraphName = "Highest High / Lowest Low Over N Bars";

		sc.GraphRegion = 0;
		sc.AutoLoop = 1;

		HighestHigh.Name= "Highest High";
		HighestHigh.DrawStyle = DRAWSTYLE_LINE;
		HighestHigh.PrimaryColor = RGB(0,255,0);
		HighestHigh.DrawZeros = true;

		LowestLow.Name = "Lowest Low";
		LowestLow.DrawStyle = DRAWSTYLE_LINE;
		LowestLow.PrimaryColor = RGB(255,0,255);
		LowestLow.DrawZeros = true;

		Length.Name = "Length";
		Length.SetInt(5);
		Length.SetIntLimits(1, MAX_STUDY_LENGTH);

		InputDataHigh.Name = "Input Data High";
		InputDataHigh.SetInputDataIndex(SC_HIGH);

		InputDataLow.Name = "Input Data Low";
		InputDataLow.SetInputDataIndex(SC_LOW);

		return;
	}

	sc.DataStartIndex = Length.GetInt()  - 1;

	if (sc.Index < sc.DataStartIndex)
		return;

	double Lowest = FLT_MAX;
	double Highest = -FLT_MAX;
	for(int BarIndex = sc.Index - (Length.GetInt() - 1); BarIndex <= sc.Index; BarIndex++)
	{
		if(Highest < sc.BaseDataIn[InputDataHigh.GetInputDataIndex()][BarIndex])
			Highest = sc.BaseDataIn[InputDataHigh.GetInputDataIndex()][BarIndex];

		if(Lowest > sc.BaseDataIn[InputDataLow.GetInputDataIndex()][BarIndex])
			Lowest = sc.BaseDataIn[InputDataLow.GetInputDataIndex()][BarIndex];
	}

	HighestHigh[sc.Index] = (float)Highest;
	LowestLow[sc.Index] = (float)Lowest;
}


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trump Lands in Beijing on CPI Day: Iran Peace Expires To …
Prediction Markets & Event Contracts
Sundays Verdict: Lebanon Locked at 99.85% as Iran June 7 …
Prediction Markets & Event Contracts
Friday Update: Markets Now Pricing Fed Rate HIKES as Sta …
Traders Hideout
Thanks Mike. Godspeed.
The Elite Circle
El Clasico Draws $9.2M in Prediction Market Action -- Bi …
Prediction Markets & Event Contracts
 
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
20 thanks
Volume Indicators
8 thanks
Thanks Mike. Godspeed.
7 thanks
  #3 (permalink)
 swandro 
England
 
Experience: Advanced
Platform: SierraChart
Posts: 70 since Jul 2009
Thanks Given: 9
Thanks Received: 80


I have created a version that I think does what you want.

Hope this helps.


Attached Files
Elite Membership required to download: ModifiedHighestHighLowestLow.cpp
Reply With Quote
Thanked by:
  #4 (permalink)
 boze man 
South Jersey
 
Experience: Advanced
Platform: Sierra
Broker: IB
Trading: ES, CL
Posts: 98 since Apr 2011
Thanks Given: 21
Thanks Received: 62

Thanks!

Will give it a go.


Started this thread Reply With Quote




Last Updated on February 2, 2016


© 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