Your 2nd plot() line is incomplete. You are missing the style parameter
  ----- Original Message ----- 
  From: justjuice200 
  To: [email protected] 
  Sent: Tuesday, January 29, 2008 7:23 PM
  Subject: [amibroker] Calling your own functions


  I am evaluating AmiBroker at the moment, but can't figure out whether the 
following is possible. I want to create a new function that can be called from 
within a formula and used for backtesting. Just as if you were to call, say, 
the inbuilt MACD or Chaikin functions.

  Just to test if it were possible, I grabbed a function from the manual and 
saved it as a new formula:

  function IIR2( input, f0, f1, f2 )
  {
  result[ 0 ] = input[ 0 ];
  result[ 1 ] = input[ 1 ];
  for( i = 2; i < BarCount; i++ )
  {
  result[ i ] = f0 * input[ i ] +
  f1 * result[ i - 1 ] +
  f2 * result[ i - 2 ];
  }
  return result;
  }

  Then I created a new formula to call this function from, again just copying 
straight from the manual:

  Plot( Close, "Price", colorBlack, styleCandle );
  Plot( IIR2( Close, 0.2, 1.4, -0.6 ), "function example", colorRed );

  Amibroker complains about the second line: 
  Ln: 2, Col: 11: Error 31. Syntax error, expecting ')' or ','

  Any idea what's going on? Do I have to compile the function or something like 
that? (If so, how do I?).

  My second question is whether we can get access to the source of the inbuilt 
functions so that I can learn how to create my own that can be called from 
backtesting.  I'd like to be able to do the following:
  Buy=Cross(myfunction(xyz), 5);
  But I'm not sure how to write the function so it can be used like this.  If 
we can't get the source, then does anyone have any hints on how to convert a 
custom indicator to a function?

  Many thanks in advance!

   

Reply via email to