This has been surprisingly difficult for me to figure out but I'm new to C so bear with me.
I want to do a simple trend check on the hourly time frame and draw that as a trendline on the daily timeframe.

If the last 5-hour bars lows are higher -> uptrend
If the last 5-hour bar highs are lower -> downtrend

I think I've got that part figured out but wouldn't mind a second pair of eyes.

What I want to do next is the difficult part.
If I'm in one of those trends then:

I want to a linear regression on those last 5 points
Draw that line as a trendline on the daily.
Enter a trade if price touches that line.

I can not for the life of me figure out why I can't draw that trendline.

Maybe someone can review my current crazed attempt and point me in the right direction.
Or even something as simple as hit me up with an example of them using the plot function to draw trendlines
in one timeframe or across multiple.

Here's what I've got so far.

Code
// The ZEN Indicator v4

void run(){
	
	set(PLOTNOW,LOGFILE,TESTNOW,PARAMETERS);
	// StartDate = 20180101;
	EndDate = 20181231;
	// BarMode = BR_WEEKEND+BR_SLEEP;
	BarPeriod = 60;
	TimeFrame = 24; // frameSync(24);
	LookBack = 100;
	MaxLong = MaxShort = 1;
	
	// var day = 24; 
	// if (Train) Detrend = TRADES;
	
	// NumWFOCycles = 10;
	// NumCores = -1;
	
	// asset(loop("EUR/USD", "USD/JPY", "GBP/USD","USD/CHF", "USD/CAD", "AUD/USD", "EUR/NZD"));
	
	asset("SPY");
	
	// if(is(INITRUN)){
		// assetHistory(asset, FROM_STOOQ);
	// }
	
	vars Prices = series(price());
	vars Highs = series(priceHigh());
	vars Lows = series(priceLow());
	
	// while(asset(loop("EUR/USD", "USD/JPY", "GBP/USD","USD/CHF", "USD/CAD", "AUD/USD", "EUR/NZD"))){
		static var lowReg;
		static var highReg;
		// var threshold = -(optimize(0.001, 0.000, 0.01, 0.001));
		var threshold = 0;
		print(TO_LOG,"\n#### LOWS: %f %f %f %f %f", Lows[0], Lows[1], Lows[2], Lows[3], Lows[4]);
		print(TO_LOG,"\n#### HIGHS: %f %f %f %f %f", Highs[0], Highs[1], Highs[2], Highs[3], Highs[4]);
		
		if(Lows[0] > Lows[1] and Lows[1] > Lows[2] and Lows[2] > Lows[3] and Lows[3] > Lows[4]){
			print(TO_LOG,"\n#### \n#### UPTREND \n#### \n####");
			// print(TO_LOG,"\n#### \n#### Lows: %f \n#### \n####", Lows);
			lowReg = LinearReg(Lows, 5) +threshold;
			plot("lowReg",lowReg,MAIN,GREEN);
		}else if(Highs[0] < Highs[1] and Highs[1] < Highs[2] and Highs[2] < Highs[3]and Highs[3] < Highs[4]){
			print(TO_LOG,"\n#### \n#### DOWNTREND \n#### \n####");
			highReg = LinearReg(Highs, 5) -threshold;
			plot("highReg",highReg,MAIN,RED);
		}
		
		if(Lows[0] < lowReg){
			enterLong();
			// lowReg = -999999999;
			// highReg = 999999999;
		}else if(Highs[0] > highReg){
			enterShort();
			// lowReg = -999999999;
			// highReg = 999999999;
		}
		
		// if(crossOver(Lows, trendLine)){
			// enterLong();
		// }else if(crossUnder(Highs, trendLine)){
			// enterShort();
		// }

	// }

}