[amibroker] StaticVarGenerateRanks [1 Attachment]

 
[Attachment(s) from orionsturtle@gmail.com [amibroker] included below]

Hi

I am generating ranks on 4 ETFs using the afl example amibroker supplies in their help files.

I have the code below (also attached) and the buys and sells work great showing the new 1 ranked ETF always being bought. BUT, if I insert the SetOption("HoldMinBars",7) ; code the new buys are not coming through consistently after the hold time is satisfied. 


Has anyone ranked a list of issues using these functions and  had success using the SetOption("HoldMinBars",7) function with it?  If you have an example code snippet that would be great. 

I don't want to use the rotational backtester for this project.


Thanks for any help!


SetOption("HoldMinBars",7) ; // This line stops the flow of new buys when a new ETF is ranked 1 after the 7 day hold is met. 


List140 =  "IDU,SPY,XLE,TLT"; //CategoryGetSymbols( categoryWatchlist, 142 ) ; //

if ( Status("stocknum") == 0 ) 

{

// delete static variables 

StaticVarRemove( "OAAS1*" ); 


// fill input static arrays 

for ( i = 0; ( sym = StrExtract( List140 , i ) ) != ""; i++ ) 

SetForeign( sym ); 

Value = ROC( C, 10 ); 

RestorePriceArrays(); 

StaticVarSet( "OAAS1" + sym, Value ); 

// perform ranking 

StaticVarGenerateRanks( "rank", "OAAS1", 0, 1224 ); // normal rank mode 

}

 symbol = Name(); 

 OAAS1 = StaticVarGet ( "OAAS1" +  symbol );

 rank1 = StaticVarGet ( "rankOAAS1" +  symbol ); 


// Signals

 XLESIG4 = IIf(rank1 == 1 AND symbol == "XLE",1,0); 

 TLTSIG4 = IIf(rank1 == 1 AND symbol == "TLT",1,0);

 IDUSIG4 = IIf(rank1 == 1 AND symbol == "IDU",1,0);

 SPYSIG4 = IIf(rank1 == 1 AND symbol == "SPY",1,0);


 PositionSize = -98 ;

 //PositionScore = rank1;


 Buy   =  XLESIG4 OR TLTSIG4 OR IDUSIG4 OR SPYSIG4 ;

 Sell  =    IIf(Ref(XLESIG4 ,-1) == 1 AND !XLESIG4 ,1, 

IIf(Ref(TLTSIG4 ,-1) == 1 AND !TLTSIG4 ,1,

IIf(Ref(IDUSIG4 ,-1) == 1 AND !IDUSIG4 ,1,

IIf(Ref(SPYSIG4 ,-1) == 1 AND !SPYSIG4 ,1,0))));


 Buy   = ExRem(Buy,Sell );

 Sell  = ExRem(Sell,Buy);


__._,_.___

Attachment(s) from orionsturtle@gmail.com [amibroker] | View attachments on the web

1 of 1 File(s)


Posted by: orionsturtle@gmail.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

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


.

__,_._,___


EmoticonEmoticon