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

Re: [amibroker] passing variables



PureBytes Links

Trading Reference Links



OK,
between Tomasz and Ken I getting closer.  Here is what I have. 
Getting a syntax error at the 
SR = StoRSI  
point in the code.
The include path is set in Preferences 

/*
Stochastic - RSI , and ADX 
Try it on SMH
*/

#include
StoRSI; 
RSIPer=
13;//Optimize("RSIPer",
8, 3, 15,
1);

EMAPer=
11;//Optimize("EMAPer",
8, 5, 20,
1);

SR =
StoRSI(Close,RSIPer,EMAPer);                                     
Error on this line
Buy =
Cross(17,SR)
AND
ADX(14)>20; 
Sell= Cross(SR,83) ; 
Short = Sell; 
Cover = Buy; 
//Plot(Equity(),"Equity",1,1); 
Plot(SR,"StoRSI",1,1); 

// include file  ***** located at C:\program files\amibroker\include 
/* StoRSI, input array (normally Close), RSI period, EMA period */ 
/*    typical settings: IA = Close,  Per = 14,  EMAPer = 8    */ 
/*    written by Sid Kaiser, 24 Dec 03    */ 

function StoRSI( IA, RSIPer, EMAPer ) 
{ 
local IA; 
local Per; 
local EMAPer; 

     result = EMA((RSIa(IA, RSIPer) - LLV(RSIa(IA, RSIPer), EMAPer)) / (HHV 
     (RSIa(IA, RSIPer), EMAPer) - LLV(RSIa(IA, RSIPer), EMAPer)),3)*100; 
     return result; 
}     

At 11:57 PM 12/24/2003 +0100, you wrote:
Sid,
 
No, param1 statement in only in the main file. Include file contains ONLY your function that takes an argument:
 
// BEGIN.. contents of the file_with_your_function.afl ...
 
function MyFunction( periods )
{
   return AMA( C, 2/(periods+1));
}
 
/// END
 
-------------------
---------------------
Contents of the main file:
 
// BEGIN
#include <file_with_your_function.afl>
 
param1 = Optimize("param1", 5, 1, 10, 1 );
 
buy = C > MyFunction( param1 );
// END
 
 
At run time param1 from MAIN file is passed BY VALUE to 'periods' argument in the function.
That way your function is written ONCE and can be used like ANY OTHER built-in function in AFL
(like MA, ADX, etc )
 
 
 
Best regards,
Tomasz Janeczko
amibroker.com


----- Original Message ----- 

From: Sidney Kaiser 

To: amibroker@xxxxxxxxxxxxxxx 

Sent: Wednesday, December 24, 2003 10:22 PM

Subject: Re: [amibroker] passing variables

Great...but I am programmatically challenged.  Is the param1 statement in the included file, it looks like it would have to be there.  Could you provide a more elaborate example please?

Cheers

Sid

At 10:11 PM 12/24/2003 +0100, you wrote:

Sid,

 

There is absolutely NO problem with that.

You can use optimize and pass arguments to ANY function defined in external file.

 

#include <file_with_your_function.afl>

 

param1 = Optimize("param1", 5, 1, 10, 1 );

 

buy = C > MyFunction( param1 );

 

Best regards,

Tomasz Janeczko

amibroker.com
----- Original Message ----- 
From: Sidney Kaiser 
To: amibroker@xxxxxxxxxxxxxxx 
Sent: Wednesday, December 24, 2003 10:07 PM
Subject: RE: [amibroker] passing variables

Clarification:
What I am talking about is the ability to run optimize on the code that is in the include file.  This means the variables are defined in the main program and the current value is passed to the include program for the range of the optimization.

Upon further reading of the help files I am beginning to think this is NOT possible in AB.  Someone correct me if I am wrong on this.

Ken, thanks for your routine,  BTW, I think what you posted is STOCH + RSI rather than StochRSI which is the stochastic of RSI.
Cheers and Merry Christmas to all
Sid

At 03:28 PM 12/24/2003 -0500, you wrote:

Hi Sid:
I added this to my function file:
function StoRSI(RSIPer,EMAPer)

{
Low1=LLV(C,7);

High1=HHV(C,7);

return (EMA(100*(C - Low1)/(High1 - Low1),EMAPer)/2) + (RSI(RSIPer)/2);

}
Note the naming and the variable positions in the declaration of the StoRSI function.
I plotted this in my IB window:
X=StoRSI(14,13);

Plot(50,"",7,1);

Plot(X,"StoRSI",5,1);

The C/O/H/L/V arrays are always available, so I only "passed" two variables, the EMA period and the RSI Period.  It gets "passed" when you write the function within your regular AFL code.  In my case, following what a lot of others do, I #include a regular (and growing) MyFunctions.AFL file.
Hope this helps.
Ken

-----Original Message-----
From: Sidney Kaiser [mailto:s9kaiser@xxxxxxxxxxx]
Sent: Wednesday, December 24, 2003 12:02 PM
To: AmiBroker@xxxxxxxxxxxxxxx
Subject: [amibroker] passing variables
I use StochRSI fairly often and rather than re-write it all the time I 
decided to make a dedicated AFL file that I can include in the other files 
where I want to use the function.  Of course to be of any use, the 
variables need to be passed from the calling program to the included 
program.  I know how to do that in TS, but I don't see how to do it in AFL.
For my StochRSI fn I would want to pass the Array (usually Close), the RSI 
period and the smoothing MA to the include file.  Three variables in all.
How is this done?
TIA
Sid
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links
To visit your group on the web, go to:
 http://groups.yahoo.com/group/amibroker/
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/ 

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 



Yahoo! Groups Links 

To visit your group on the web, go to: 
http://groups.yahoo.com/group/amibroker/ 
To unsubscribe from this group, send an email to: 
amibroker-unsubscribe@xxxxxxxxxxxxxxx 
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.551 / Virus Database: 343 - Release Date: 12/11/2003
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 


Yahoo! Groups Links 
To visit your group on the web, go to: 
http://groups.yahoo.com/group/amibroker/ 
To unsubscribe from this group, send an email to: 
amibroker-unsubscribe@xxxxxxxxxxxxxxx 
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.551 / Virus Database: 343 - Release Date: 12/11/2003

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 


Yahoo! Groups Links 
To visit your group on the web, go to: 
http://groups.yahoo.com/group/amibroker/ 
To unsubscribe from this group, send an email to: 
amibroker-unsubscribe@xxxxxxxxxxxxxxx 
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.551 / Virus Database: 343 - Release Date: 12/11/2003 




Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 


Yahoo! Groups Links
To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
  
To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
  
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.551 / Virus Database: 343 - Release Date: 12/11/2003

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 


Yahoo! Groups Links
To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
  
To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
  
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.551 / Virus Database: 343 - Release Date: 12/11/2003


Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html








Yahoo! Groups Sponsor


  ADVERTISEMENT 









Yahoo! Groups Links
To visit your group on the web, go to:http://groups.yahoo.com/group/amibroker/ 
To unsubscribe from this group, send an email to:amibroker-unsubscribe@xxxxxxxxxxxxxxx 
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.







---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.551 / Virus Database: 343 - Release Date: 12/11/2003