May be you need to empty the watchlists first :
example:
CategoryRemoveSymbol("", categoryWatchlist, 0);
if ( LastValue(ROC(C,1)>0))
CategoryAddSymbol("", categoryWatchlist, 0);
--- In [email protected], "murthysuresh" <[EMAIL PROTECTED]> wrote:
>
> Hello
> I ahve a few watchlists. My strategy is to
> -scan daily meeting 20 day high criteria
> - check if they are not in a watchlist
> - add them to the watchlist if they are new symbols that are not in
> the watchlist
>
> However this peice of code that i wrote seems to scan fine but keeps
> adding into the watchlist all the symbols that meets 20 day high or
> low irrespective if they exist in a watchlist or not. how do i fix
> it. Is there a bug in if(LastValue( Buy)==1) or am i not using it
> properly.
>
>
>
> InWatchListAlready=(InWatchListName( "WoodiesCCI_Step1_20DayLow" )
> OR InWatchListName( "WoodiesCCI_Step1_20DayHigh" ) OR InWatchListName
> ( "WoodiesCCI_Step2_Look4Retracement" ) OR InWatchListName
> ( "WoodiesCCI_Step3_SetBuy" ) OR InWatchListName
> ( "WoodiesCCI_Step4_Holding" ) OR InWatchListName( "BreakoutTrade" ));
>
>
>
>
>
>
>
> // step 1 find stocks moving lower
> twentyDayLow=Close<Ref(LLV(L,20),-1);
> twentyDayHigh=Close>Ref(HHV(H,20),-1);
> Short=twentyDayLow AND Ref(twentyDayLow,-1) /* AND
> Ref(twentyDayLow,-2) AND ADX(14)>20 */ AND Close >20 AND MA(V,20)
> >200000 AND !InWatchListAlready ;
> Buy=twentyDayHigh AND Ref(twentyDayHigh,-1) /* AND
> Ref(twentyDayHigh,-2) AND ADX(14)>20 */ AND Close <50 AND MA
> (V,20)>200000 AND !InWatchListAlready ;
> if(LastValue( Short)==1) {
> wlnumber = CategoryFind("Watchlist A",
> categoryWatchlist );
> mysymbols = CategoryGetSymbols
> (categoryWatchlist, wlnumber );
> CategoryAddSymbol( "",
> categoryWatchlist,wlnumber );
> _TRACE("ABTrace adding short " + Name());
> }
>
>
>
> if(LastValue( Buy)==1) {
> wlnumber = CategoryFind("Watchlist A",
> categoryWatchlist );
> mysymbols = CategoryGetSymbols
> (categoryWatchlist, wlnumber );
> CategoryAddSymbol( "",
> categoryWatchlist,wlnumber );
> _TRACE("ABTrace adding long " + Name());
>
> }
>