bullman1083
New member
Hi guys, trying to find a simpler way to code that the 200 day Moving average has been in an uptrend for at least 20 days and also add that the stock has not declined more than 50% in the past 5 yrs. here's what i have so far for the 200DMA...
#200D sma 1month uptrend indicator
def smaup = simplemovingAvg(close,200) > simplemovingAvg(close,200)[1] and simplemovingAvg(close,200)[1] > simplemovingAvg(close,200)[2] and simplemovingAvg(close,200)[2] > simplemovingAvg(close,200)[3] and simplemovingAvg(close,200)[3] > simplemovingAvg(close,200)[4] and simplemovingAvg(close,200)[4] > simplemovingAvg(close,200)[5] and simplemovingAvg(close,200)[5] > simplemovingAvg(close,200)[6] and simplemovingAvg(close,200)[6] > simplemovingAvg(close,200)[7] and simplemovingAvg(close,200)[7] > simplemovingAvg(close,200)[8] and simplemovingAvg(close,200)[8] > simplemovingAvg(close,200)[9] and simplemovingAvg(close,200)[9] > simplemovingAvg(close,200)[10] and simplemovingAvg(close,200)[10] > simplemovingAvg(close,200)[11] and simplemovingAvg(close,200)[11] > simplemovingAvg(close,200)[12] and simplemovingAvg(close,200)[12] > simplemovingAvg(close,200)[13] and simplemovingAvg(close,200)[13] > simplemovingAvg(close,200)[14] and simplemovingAvg(close,200)[14] > simplemovingAvg(close,200)[15] and simplemovingAvg(close,200)[15] > simplemovingAvg(close,200)[16] and simplemovingAvg(close,200)[16] > simplemovingAvg(close,200)[17] and simplemovingAvg(close,200)[17] > simplemovingAvg(close,200)[18] and simplemovingAvg(close,200)[18] > simplemovingAvg(close,200)[19] and simplemovingAvg(close,200)[19] > simplemovingAvg(close,200)[20] ;
#200D sma 1month uptrend indicator
def smaup = simplemovingAvg(close,200) > simplemovingAvg(close,200)[1] and simplemovingAvg(close,200)[1] > simplemovingAvg(close,200)[2] and simplemovingAvg(close,200)[2] > simplemovingAvg(close,200)[3] and simplemovingAvg(close,200)[3] > simplemovingAvg(close,200)[4] and simplemovingAvg(close,200)[4] > simplemovingAvg(close,200)[5] and simplemovingAvg(close,200)[5] > simplemovingAvg(close,200)[6] and simplemovingAvg(close,200)[6] > simplemovingAvg(close,200)[7] and simplemovingAvg(close,200)[7] > simplemovingAvg(close,200)[8] and simplemovingAvg(close,200)[8] > simplemovingAvg(close,200)[9] and simplemovingAvg(close,200)[9] > simplemovingAvg(close,200)[10] and simplemovingAvg(close,200)[10] > simplemovingAvg(close,200)[11] and simplemovingAvg(close,200)[11] > simplemovingAvg(close,200)[12] and simplemovingAvg(close,200)[12] > simplemovingAvg(close,200)[13] and simplemovingAvg(close,200)[13] > simplemovingAvg(close,200)[14] and simplemovingAvg(close,200)[14] > simplemovingAvg(close,200)[15] and simplemovingAvg(close,200)[15] > simplemovingAvg(close,200)[16] and simplemovingAvg(close,200)[16] > simplemovingAvg(close,200)[17] and simplemovingAvg(close,200)[17] > simplemovingAvg(close,200)[18] and simplemovingAvg(close,200)[18] > simplemovingAvg(close,200)[19] and simplemovingAvg(close,200)[19] > simplemovingAvg(close,200)[20] ;
Last edited: