// Downloaded From https://www.WiseStockTrader.com _SECTION_BEGIN("Mann-Kendall"); Length= Param( "Period", 21, 5, 200, 1 ); function Trend(Price,Length) { Price=C; Result = 0; for (k=Length;k= 0) { zScore=((S-1)/StdDev); }else { zScore=(S+1)/StdDev; } Result[k] = 0; //0- no trend, -1 - decreasing trend, 1 - increasing trend isTrend = False; if ((zScore>=1.65)||(zScore<=-1.65)) { isTrend=True; } if (isTrend) { if (S<0){ Result[k] = -1; }else { Result[k] = 1; } } } return Result; } Plot(C,"",colorRed,styleCandle); Plot(Trend(C,Length),"",colorRed,styleLine+styleThick|styleOwnScale); _SECTION_END();