Herman: Thanks. That works perfectly in my application. Ken _____
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Herman Sent: Saturday, November 08, 2008 9:19 AM To: Ken Close Subject: Re[2]: [amibroker] Vbscript in AFL worked in 2002, not now or "Reading in variables" followup Ken, I am not familiar with VB scripts and can't help you there, however you can use a similar structure directly in afl. A Title was added to verify the code. Best regards, herman Stock = Name(); switch( Stock ) { case "DIA": BuyLevel = 194; SellLevel = 130; break; case "SPY": BuyLevel = 190; SellLevel = 130; break; case "IWM": BuyLevel = 176; SellLevel = 73; break; case "QQQQ": BuyLevel = 192; SellLevel = 146; break; case "XLE": BuyLevel = 189; SellLevel = 117; break; default: BuyLevel = 174; SellLevel = 80; } Title = "\n"+ " BuyLevel = "+BuyLevel +"\n"+ "SellLevel = "+SellLevel; Saturday, November 8, 2008, 9:00:29 AM, you wrote: > I realize that Herman and others suggested include files and static variables as ways to assign differing constant values depending on the symbol being processed. I am about to turn there, but can I ask again if anyone has a comment or suggestion about the simple vbscript code below and my problem in getting it to perform as intended. These few lines seem, to me, to be FAR more simple than any loop construction with naming conventions to assign several simple values to constant variables dependent on the symbol name. Please take a look and offer a comment. I understand that not many may know the vbscript syntax and thus cannot comment, but some of you out there know it. thanks. _____ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Ken Close Sent: Friday, November 07, 2008 2:12 PM To: [email protected] Subject: [amibroker] Vbscript in AFL worked in 2002, not now I used this code in 2002 successfully (on whatever version of AB was running then). Today I stuck it in some code and while it did not produce an error, it seems not to recognize the change in symbols. An explore after these lines shows that all symbols have the same BuyLevel = 174 and SellLevel = 80 saying that the Select command "fell through" to the "else" part even thou the watchlist contained only the five ETF symbols listed in the case statements. Can anyone spot what might be wrong or missing? What is the modern day way of doing this? I tried IF statements (not IIF) and only the last IF statement was operative, ie, only the last IF corresponding to the last symbol in the watchlist was operative. The modern way will be more complex loops, yes? The Case statements below seem pretty simple if I could get them to work. Thanks. EnableScript("vbscript"); <% 'BSSC Codes: 1 = Buy/Sell 2 = Short/Cover 3 = Both / SL = Stop Loss percentage Stock = AFL("ticker") : BuyLevel = 0 : SellLevel = 0 Select case Stock case "DIA" BuyLevel = 194 : SellLevel = 130 case "SPY" BuyLevel = 190 : SellLevel = 130 case "IWM" BuyLevel = 176 : SellLevel = 73 case "QQQQ" BuyLevel = 192 : SellLevel = 146 case "XLE" BuyLevel = 189 : SellLevel = 117 case else BuyLevel = 174: SellLevel = 80 End Select AFL("BuyLevel") = BuyLevel AFL("SellLevel") = SellLevel %>
