|  | Amritendu Maji 2017-08-03 01:34:05
 
 
 
 |  | 
	 Using your help and the examples from other functions, I tried to write the Zweig Indicator. It returns 0, 1, -1 and one can take their trading decisions based on that.
 Before I upload the formula, can you please check and see that it works as intended? Input is the series (close is the default), PerOffLow and PerOffHigh
 
 double p = Series[0];
 double tL = PerOffLow[0]; //t in percent
 double tH = PerOffHigh[0];
 int trend = 0;
 
 double LC = Series[0];
 double HC = Series[0];
 
 for(int i = 0;i<Series.Length;i++)
 {
 if (trend == 0)
 {
 if (((Series[i] - LC) / LC) >= (tL / 100))
 {
 trend = 1;
 }
 if (((HC - Series[i] ) / HC) >= (tL / 100))
 {
 trend = -1;
 }
 }
 else if ((trend == 1) && (((HC - Series[i]) / HC) >= (tH / 100)))
 {
 trend = -1;
 LC = Series[i];
 }
 else if (trend == -1 && ((Series[i] - LC) / LC) >= (tL / 100))
 {
 trend = 1;
 HC = Series[i];
 }
 
 if ( Series[i] < LC) LC = Series[i];
 if ( Series[i] > HC) HC = Series[i];
 result[i] = trend;
 }
 
 
 
 
 
 |  |