Adding script to watchlist

#1
Hello All,
Could you please let me know what is wrong in the below sample code? I want to add only the scripts which satisfies condition when new bar arrives and remove the old scripts. But it adds all the scripts to the watchlist.
Code:
_SECTION_BEGIN("Export Analysis");
    prevDTLast = Nz( StaticVarGet ( "prevDTLast"+Name() ) );
    DT=DateTime();
    DTLast = DT[BarCount-1];
    if ( DTLast  != prevDTLast )   
    {
        Buy = C > MA(C,21);
        Sell = C < MA(C,21);
        Filter = Ref(Buy,-1) OR Ref(Sell,-1);

        if ( LastValue(  Filter)  ){
            CategoryAddSymbol( Name(), categoryWatchlist, 0 );
        }
        else
        {
            CategoryRemoveSymbol(  Name() , categoryWatchlist, 0 ); 
        }
        StaticVarSet( "prevDTLast"+Name(), DTLast );
    }
   
_SECTION_END();
thanks much for the help in advance
Bala
 
Last edited:
#2
Hello All,
Could you please let me know what is wrong in the below sample code? I want to add only the scripts which satisfies condition when new bar arrives and remove the old scripts. But it adds all the scripts to the watchlist.
Code:
_SECTION_BEGIN("Export Analysis");
    prevDTLast = Nz( StaticVarGet ( "prevDTLast"+Name() ) );
    DT=DateTime();
    DTLast = DT[BarCount-1];
    if ( DTLast  != prevDTLast )  
    {
        Buy = C > MA(C,21);
        Sell = C < MA(C,21);
        Filter = Ref(Buy,-1) OR Ref(Sell,-1);

        if ( LastValue(  Filter)  ){
            CategoryAddSymbol( Name(), categoryWatchlist, 0 );
        }
        else
        {
            CategoryRemoveSymbol(  Name() , categoryWatchlist, 0 );
        }
        StaticVarSet( "prevDTLast"+Name(), DTLast );
    }
  
_SECTION_END();
thanks much for the help in advance
Bala
Anyone could you please help on this? Thank you
 

Similar threads

Zerodha – Open Paperless Account

Open online account with Zerodha. Free delivery trading and Max Rs 20 for Intraday, F&O, Currency and Commodity Trading. Intraday High leverage with MIS, CO and BO.

Name:Phone:
Email:City:
State:
Are you a day trader?