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

Re: extremesFC



PureBytes Links

Trading Reference Links

Ralf,

Here it is:

======================================================================
{ Extremes (fast calculation) multiple-output function; the ExtremeVal
output is
  identical to that of the Extremes function; the ExtremeBarRaw output is
not
  adjusted for ExecOffset here (series functions cannot be adjusted this
way); also
  see MULTIPLE-OUTPUT FUNCTIONS note below }

inputs:
 Price( numericseries ),
 Length( numericsimple ),  { this input is assumed to be constant }
 HiLo( numericsimple ), { this input is assumed to be constant; pass in 1
for
  Highest(Bar), -1 for Lowest(Bar) }
 oExtremeVal( numericref ),
 oExtremeBarRaw( numericref ) ;

variables:
 MyVal( 0 ),
 MyBar( Length - 1 ) ; { this triggers the initial evaluation at CurrentBar
= 1 }

{ IF STARTING OUT, OR IF NEW BAR IS WORSE, UPDATE OLD BAR OFFSET: }
if CurrentBar = 1
 or ( HiLo = 1 and Price < MyVal )
 or ( HiLo = -1 and Price > MyVal )
then
 begin
 MyBar = MyBar + 1 ;
 { IF UPDATED OFFSET OUTSIDE RANGE, GET NEW IN-RANGE EXTREME VAL AND ITS
OFFSET: }
 if MyBar >= Length then
  begin
  MyVal = Price ;
  MyBar = 0 ;
  for Value1 = 1 to Length - 1
   begin
   if ( HiLo = 1 and Price[Value1] > MyVal )
    or ( HiLo = -1 and Price[Value1] < MyVal )
   then
    begin
    MyVal = Price[Value1] ;
    MyBar = Value1 ;
    end ;
   end ;
  end ;
 end
else { NEW BAR IS EQUAL OR BETTER, SWITCH TO ITS PRICE & OFFSET }
 begin
 MyVal = Price ;
 MyBar = 0 ;
 end ;

oExtremeVal = MyVal ;
oExtremeBarRaw = MyBar ;

ExtremesFC = 1 ; { function return always 1, not used; only outputs used }

{ Force series function, since otherwise this function can verify as simple,
but
  needs to be called at every bar to return correct results }
if false then
 Value1 = ExtremesFC[1] ;

{
MULTIPLE-OUTPUT FUNCTIONS

A multiple-output function has two types of parameters or "inputs" - input
parameters
and input/output parameters.  The values of the input parameters are passed
into the
multiple-output function, but not modified by the function.  The values of
the input/
output parameters are passed into the multiple-output function, modified by
it, and
the modified values are then inherited by - or output to - the calling
routine.

The input/output parameters are often used for output purposes only, i.e.,
the
incoming values are ignored.  The outputs are in addition to the function
return.  In
multiple-output functions, the function return is generally used to return
an error
code, though sometimes the return may simply be a dummy value.

The input/output parameters are declared with a "ref" suffix (such as
"numericref") in
the multiple-output function's declaration statements.  For further clarity,
the names
of the input/output parameters are generally prefixed with an "o" in the
function as
well as in all the routines that call the function.

The built-in single-return WRAPPER FUNCTIONS that call the multiple-output
functions
are specialized calling routines designed to offer simplified, alternate
pathways to
the functionality of the underlying multiple-output functions.  In the
wrapper
functions, the input/output parameters are declared as local variables and
generally
initialized to zero.  They are passed through to the multiple-output
function without
further modification.  After the call, the wrapper function picks out the
single
output of interest and assigns it as the return of the wrapper function.
}

{ ** Copyright (c) 1991-2001 TradeStation Technologies, Inc. All rights
reserved. ** }


======================================================================
----- Original Message -----
From: "Ralf Bohnet" <ralf.bohnet@xxxxxxxx>
To: "Omegalist" <omega-list@xxxxxxxxxx>
Sent: Wednesday, August 28, 2002 12:30 PM
Subject: extremesFC


> Hello,
>
> can someone with a TS6 subscription provide me the code of the extremesFX
> function
> because I need a replacement for an Indicator-Code to work in TS 2000i
>
> Thx
>
> Ralf
>