Outsourcing Indicator from script

Posted By: DonDiego

Outsourcing Indicator from script - 03/07/23 21:39

For training purposes I coded Vitali Aprine's HHS & LLS indicator

Code
//Vitali Aprine HHSLLS Indicator TASC 02/2016

var HHS(int Length)
	{
		vars Highs = series(priceH());
		var HHH = ifelse(Highs[0] > Highs[1], 
                  (Highs[0] - MinVal(Highs,Length)) / (MaxVal(Highs,Length) - MinVal(Highs,Length)),0);
		return EMA(HHH,Length)*100;
	}
	
var LLS(int Length)
	{
		vars Lows = series(priceL());
		var LLL = ifelse(Lows[0] < Lows[1], 
                  (MaxVal(Lows,Length)-Lows[0]) / (MaxVal(Lows,Length) - MinVal(Lows,Length)),0);
		return EMA(LLL,Length)*100;
	}


function run()
{
             ***some code here***

                  plot("HHS",HHS(20),LINE,BLUE);
		  plot("LLS",LLS(20),LINE,RED);
}


My question is, (how) can I "outsource" the indicator code into another file and call later on in a script? Has this to do with a global variable? Where would I need to store that file? In "source"?
The idea would be to build a custom indicator file over time and don't clutter scripts with that code.

Thank you
Posted By: AndrewAMD

Re: Outsourcing Indicator from script - 03/07/23 21:50

Include it as a header:
https://zorro-project.com/manual/en/include.htm
Posted By: DonDiego

Re: Outsourcing Indicator from script - 03/07/23 23:00

Thanks Andrew, I'll try that out tomorrow.
© 2024 lite-C Forums