Support and Resistance Zones/Cluster

Posted By: TCC

Support and Resistance Zones/Cluster - 07/24/17 13:49

Hi all,

I got some simple trading system which works not that bad. One component of the system is the usage of support and resistance zones/price clusters.

Does anyone know if there is a function / indicator already available in Zorro or anywhere else as lite-C script?

I searched all zorro documentation but was not able to find one....

Best wishes
TCC
Posted By: firecrest

Re: Support and Resistance Zones/Cluster - 07/25/17 02:05

Hi TCC,

I think you need to code it yourself for price clusters detection. I am thinking the code is to find the price range which most of the prices fall in and that is the support and resistance zone.

Regards
Posted By: Smon

Re: Support and Resistance Zones/Cluster - 08/17/17 03:22

I'm working on a support and resistance indicator. I think the significant price levels are fairly well detected and am now looking for ways to improve it. I'd be happy for any ideas or suggestions to improve it (maybe implement the price levels as structs containing other useful information like the age of the level, how often it was respected or not respected and so on, a return value that tells the script where price is in between two levels / similar to Williams %Range). Send me a message if you want to collaborate!

Code:
// Support and Resistance indicator

function run()
{
	//set(STEPWISE);
	set(PLOTNOW);
	StartDate = 20150101;
	EndDate = 20170301;
	BarPeriod = 1440;
	LookBack = 100; //default - rising this gives more levels to start with
	//BarZone = CET;
	LifeTime = 1;
	

	
	if(is(INITRUN)) printf("nnnnnn===============================");
	
	static var SnR[100]; //array containing all price levels found -> needs to be dynamic in the future
	static int n_SnR = 0; 	//integer needed to fill the support and resistance array
	

	vars Price = series(price());
	//vars Highs = series(priceHigh());    //maybe used later to determine the thickness of the support
	//vars Lows = series(priceLow());      //and resistance levels
	vars Open = series(priceOpen());
	vars Close = series(priceClose());

	var Factor = 0.5;
	
	int Cycle = Factor*DominantPeriod(Price,20);
	
	
	//ZigZag(Price,20*PIP,Cycle*Factor,BLUE);   //replace 20*PIP with ATR to account for volatility and different timeframes...?
	ZigZag(Price,3*ATR(20),Cycle*Factor,BLUE);
	plot("rSlope", rSlope, NEW|SQUARE, BLACK);
	plot("rPeak", rPeak, NEW|SQUARE, BLACK);
	plot("rSign", rSign, NEW|SQUARE, BLACK);
	plot("rLength", rLength, NEW|SQUARE, BLACK);
	plot("Cycle", Cycle, NEW, BLACK);

	vars RSign = series(rSign,2);
	vars RPeak = series(rPeak,2);
	
	
	if (RSign[0] != RSign[1])	//direction changed
	{
		enterLong(); ColorEquity = ColorDD = 0; //just to help the stepwise flag
		//printf("ndirection changed!"); //debugging
		
		int n = min(RPeak[1], LookBack-2); //prevent to look further back than LookBack, otherwise bullshit is happening like SnR[n_SnR] = 0 or SnR[n_SnR] = incredible high number
		
		
		//printf("nnn is: %d", n); //debugging
		//printf("n rPeak[1]-1: %.0f, rPeak[0]: %.0f", RPeak[1]-1, RPeak[0]);
		
		while (n > 0)
			{
			if (rSign < 0) // looking for resistance
				{
				
					if (n == min(RPeak[1], LookBack-2)) //first loop - n still has it's initial value //store maximum of the oldest candle in the SnR array
					{
						//printf("nlooking for resistancenZigZag: %.5f", max(Close[rPeak], Open[rPeak]));
						SnR[n_SnR] = max(Close[n], Open[n]); 
					}
					
					SnR[n_SnR] = max(SnR[n_SnR], max(Close[n+1], Open[n+1])); //compare the subsequent candle and replace the old maximum if a higher price is found  //ZigZag high if its higher (rise lookback!!!)
					//printf("n%dth pot. Res.: %.5f, Max: %.5f", n, SnR[n_SnR], max(Close[n+1], Open[n+1]));
					
					if (n == 1) //last loop
					{
						//printf("nresistance:%.5f, rPeak = %.5f", SnR[n_SnR], max(Close[rPeak], Open[rPeak]));
					}
					
				}
				if (rSign > 0) // looking for support
				{
					
					if (n == min(RPeak[1], LookBack-2)) //first loop - n still has it's initial value //store min of the oldest candle in the SnR array
					{
						//printf("nlooking for supportnnZigZag: %.5f", max(Close[rPeak], Open[rPeak]));
						SnR[n_SnR] = min(Close[n], Open[n]);
					}
					
					SnR[n_SnR] = min(SnR[n_SnR], min(Close[n+1], Open[n+1])); //compare the subsequent candle and replace the old minimum if a lower price is found //ZigZag low if its lower (rise lookback!!!)
					//printf("n%dth pot. Sup.: %.5f, Min: %.5f", n, SnR[n_SnR], min(Close[n+1], Open[n+1]));
					
					if (n == 1) //last loop
					{
						//printf("nsupport:%.5f, rPeak = %.5f", SnR[n_SnR], min(Close[rPeak], Open[rPeak]));
					}
			}
			n--;	
			}
		
		n_SnR++; //prepare to write into next slot in the SnR array
		
		if(n_SnR > 99)
		{
			n_SnR = 0;			
			//as the S&R Array is still static, this will overwrite the oldest values to prevent errors.
		}
	}
	
	int n;
	for(n=0; n<100; n++)
	{
		if(SnR[n] != 0)
		{
			if(is(EXITRUN))
			{
				
				sortData(SnR, 100);
				printf("n%dth Price level: %.5f", n, SnR[n]);
				print(TO_CSV, "nPrice: %.5f", SnR[n]);
				//I need to write something other than just the price
				//Excel has problems with interpreting the numbers / komma is separator in Germany
				//Fixing this with STRG + H (replace "Price: " with nothing) in Excel
			}
			plot("SnR", SnR[n], MAIN|SQUARE, RED); //plot only the recent level
			//plot(strf("SnR_%d", n), SnR[n], MAIN|SQUARE, RED); //plot all levels in the array; behaving strange
			
		}
	}	
}

Posted By: SnoopySniff

Re: Support and Resistance Zones/Cluster - 11/15/18 13:10

How is your experience so far with the support / resistance approach? Is it worth it to look into it?
Posted By: nerdkorea

Re: Support and Resistance Zones/Cluster - 08/16/22 18:58

Do you have a finalized version of this Support and Resistance? This stuff seems like a really good way to get SR
© 2024 lite-C Forums