When I tested the Barry's code it worked fine and the origenal code with his corrections also worked fine.
Thanks Dick H and Barry. It is very nice piece of work. Murlidhar Pawar. --- In [email protected], "Barry Scarborough" <[EMAIL PROTECTED]> wrote: > > There are a few things wrong with your calculations. > CV is a logic statement and will be 0 or 1, true or false. > CV5 gives the value of C 5 bars ago. > To get the % difference you need to use the formula below and note > the () around the C - CV5. If you don't do this the math is C - > CV5/CV5 which equals C - 1. > > pctdiff = iif(CV, (C - CV5) / CV5 * 100, 0); > then > AddColumn(pctdiff,"% Dif", 3.2, colorYellow,colorGreen); > or you could put the formula in the AddColumn. > > I changed the formula to this > Low52week = LLV(C,252); // 52 week low > CV = IIf(C <= Low52week, Low52week, 0); // if 52 week low return the > low value > CV5 = Ref(Close,-5); // return C 5 bars ago > pctdiff = (C - CV5) / CV5 * 100; // calculate the > Filter = CV; // if CV is not zero > AddTextColumn( FullName(), "FullName" ); > AddTextColumn(IndustryID(1) ," Industry Sector ", 25.0, > colorWhite, colorBlue); > AddColumn(CV,"52 weekLow",1.2,colorBrown); > AddColumn(CV5,"C 5 days ago",1.2,colorOrange); > AddColumn(C,"Close"); > AddColumn(pctdiff,"% Dif", 3.2, colorYellow,colorGreen); > > When I ran this, today's low was the 52 week low for every stock. > That is hard to believe but I can't see and error in the formula. > > Hope that helps, > Barry > > --- In [email protected], "areehoi" <areehoi@> wrote: > > > > I'm trying to implement an Exploration that will find those stocks > > reaching a 52 week lows and at the same time show the difference > from > > 5 days ago (or any other period one may decide upon). When I run > the > > Exploration I get the 52 week lows Okay but the % difference for the > > 5days show up as "-99.00 for all? And, under the 52 week column it > > doesn't show the close price. Any help will be appreciated. > Thanks > > > > Dick H > > > > //Stocks at 52 WeekLows Bounce-back last 5 days > > > > CV = (C <= LLV(C,252)); > > CV5 =(Ref(Close,-5)); > > Filter = CV; > > AddTextColumn( FullName(), "FullName" ); > > AddTextColumn(IndustryID(1) ," Industry Sector ", 25.0, > > colorWhite, colorBlue); > > AddColumn(CV,"52 weekLow",1.2,colorBrown); > > AddColumn(CV5,"52 WkLo-5",1.2,colorOrange); > > AddColumn(C,"Close"); > > AddColumn(CV-CV5/CV5*100,"% Dif", 3.2, colorYellow,colorGreen); > > >
