NexusFi: Find Your Edge


Home Menu

 





Need help modifying an existing SC study


Discussion in Sierra Chart

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




 
Search this Thread

Need help modifying an existing SC study

  #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?
MC PL editor upgrade
MultiCharts
REcommedations for programming help
Sierra Chart
ZombieSqueeze
Platforms and Indicators
About a successful futures trader who didnt know anythin …
Psychology and Money Management
Trade idea based off three indicators.
Traders Hideout
 
  #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


© 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