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

RE: Re[2]: [amibroker] Vbscript in AFL worked in 2002, not now or "Reading in variables" followup



PureBytes Links

Trading Reference Links

Title: Re[2]: [amibroker] Vbscript in AFL worked in 2002, not now or "Reading in variables" followup
Herman:
 
Thanks. That works perfectly in my application.
 
Ken


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] 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 _vbscript_s 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: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Ken Close

Sent: Friday, November 07, 2008 2:12 PM

To: amibroker@xxxxxxxxxxxxxxx

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 

 

%> 

   

__._,_.___

**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

*********************
TO GET TECHNICAL 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

*********************************




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___