[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] lastvalue(Buy) not working for me



PureBytes Links

Trading Reference Links

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());

		}
	     



Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/