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

[amibroker] Re: how bad was Tokyo today?



PureBytes Links

Trading Reference Links




<FONT face=Arial color=#0000ff 
size=2>Graham, global variables are displayed like so:
<FONT face=Arial color=#0000ff 
size=2> 
1) You 
can declare variables as global:
<FONT 
color=#000000>Global var1, var2, var3; 
This 
is usually done at the top of your code and (optional) inside your 
functions for clarity. G<FONT 
face=Arial color=#0000ff size=2>lobal variables will be visible thoughout your 
code.
<FONT face=Arial color=#0000ff 
size=2> 
2) You 
can return many single numbers in an array: 
Result[0] = 
Var1;
Result[1] = 
Var2;
Result[2] = 
var3;
Return 
Result;
<FONT face=Arial color=#0000ff 
size=2> 
You 
extract the the other way around: Var1 = Result[0];
<FONT face=Arial color=#0000ff 
size=2> 
3) you 
can encode just about anything in a string, this will allow you to return any 
number of tickers with their Rank and Scores:
<FONT face=Arial color=#0000ff 
size=2> 
function 
Test() { R="";TickerCount=0;
 
 // The 
following would be calculated for each ticker Ticker = "AAPL"; Rank = 
1; Score = 1.534; // I For each ticker I add the dadat to a data 
string R = 
Ticker+","+NumToStr(Rank,1.0,False)+","+NumToStr(Score,1.3,False)+",";
 
 TickerCount++; 
// an increment a ticker counter // when done I prefix the 
Tickercount Result = NumToStr(TickerCount,1.0)+","+R; return 
Result; }
 
t = Test(); // call 
function and extract parametersTickerCount= StrToNum(StrExtract(t,0)); 
Ticker = StrExtract(T,1);Rank = StrToNum(StrExtract(t,2));Score = 
StrToNum(StrExtract(t,3));
 
// Show 
resultTitle = 
"TickerCount="+NumToStr(TickerCount,1.0)+"\n"+"ticker="+Ticker+"\n"+"Rank="+NumToStr(Rank,1.0)+"\n"+"Score="+NumToStr(Score,1.3);
<FONT face=Arial color=#0000ff 
size=2> 
<FONT face=Arial color=#0000ff 
size=2> 

  <FONT face=Tahoma 
  size=2>-----Original Message-----From: Graham 
  [mailto:gkavanagh@xxxxxxxxxxxxx]Sent: Monday, May 10, 2004 7:08 
  PMTo: amibroker@xxxxxxxxxxxxxxxSubject: RE: [amibroker] 
  Functions and proceduresThanks Ara for your 
  explanationI am uncertain how you do this, can you provide as example 
  of this." or you can define all the parameters you want as global 
  variables and onceyou call the function all variables will have the 
  correct value "say I have 3 variables resulting from the 
  dataBased on 2 inputs of PerA = 3;PerB = 6;My 
  longwinded code calculation gives output variablesVar1 
  Var2Var3I want to compare the output variables, 
  exampleVar1(PerA) - Var1(PerB)Var2(PerA) - 
  Var2(PerB)Var3(PerA) - Var3(PerB)Cheers,Graham<A 
  href="">http://e-wire.net.au/~eb_kavan/-----Original 
  Message-----From: Ara Kaloustian [mailto:ara1@xxxxxxxxxx] Sent: 
  Tuesday, May 11, 2004 6:51 AMTo: amibroker@xxxxxxxxxxxxxxxSubject: Re: 
  [amibroker] Functions and proceduresGraham,for the time being 
  therwe is no difference between functions and proceduresin 
  AB.Typically Functions return one value, while Procedures return 
  none.... andTJ will probably implement it that way later.In order 
  to get multiple variable reurned, you can do it in 2 ways:1. Make 
  multiple calls to the function and select what to 
  return.Example:function Calculate(Input1, 
  Input2,....,returnvariable){// calculate 
  variablesreturnparamif (return variable == 1)  
  returnparameter = variable1;if (return variable == 2)  
  returnparameter = variable2;etc.return 
  returnparameter;}or you can define all the parameters you want 
  as global variables and onceyou call the function all variables will have 
  the correct valueAra----- Original Message ----- From: 
  "Graham" <gkavanagh@xxxxxxxxxxxxx>To: 
  <amibroker@xxxxxxxxxxxxxxx>Sent: Monday, May 10, 2004 3:32 
  PMSubject: [amibroker] Functions and procedures> The 
  difference between functions and procedures is something I 
  havetrouble> understanding even after reading the descriptions in 
  the help files.Hoping> someone can provide me with where procedures 
  could be used instead of a> function.>> Secondly I would 
  like to run explorations using a fairly complex code and> have multiple 
  outputs. An example is I want to run various P&F codes with> 
  different box sizes to find various signals. My attempts have found that 
  I> can only get one variable out of a function. Is this correct? So far 
  I> basically set up the base code in an #include file and declare the 
  input> variable before the include statements>> 
  Eg>> Reverse = 3  ;      // 
  reversal requirement> #pragma nocache> #include "C:\Program 
  Files\AmiBroker\AFL PF System\PnF System Base.afl">> Reverse = 
  6  ;      // reversal requirement> 
  #pragma nocache> #include "C:\Program Files\AmiBroker\AFL PF System\PnF 
  System Base.afl">> Unfortunately when I do this I must then 
  reassign local names to theoutputs> from the base file for each 
  output. My system has many outputs that I use,> eg Average column 
  length, average bars per column, average inactive bars> 
  etc.>> Hope this is clear what I am trying to do and any help 
  appreciated. A> multiple output function, or another method, could save 
  a lot of my typing>> Cheers,> Graham> <A 
  href="">http://e-wire.net.au/~eb_kavan/>>>>>> 
  Send BUG REPORTS to bugs@xxxxxxxxxxxxx> Send SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx> 
  -----------------------------------------> Post AmiQuote-related 
  messages ONLY to: amiquote@xxxxxxxxxxxxxxx> (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)> 
  --------------------------------------------> Check group FAQ at:<A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html> 
  Yahoo! Groups 
  Links>>>>>Send BUG 
  REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at:<A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  Yahoo! Groups LinksSend BUG 
  REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  


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.