Announcement

Collapse
No announcement yet.

TimeSeriesForcast

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • TimeSeriesForcast

    Can someone help me make the following Tradestation Function in esignal EFS?


    *************BEGIN CODE**************************

    {{ Single-return wrapper function calling
    multiple-output function; see MULTIPLE-OUTPUT
    FUNCTIONS note below }

    inputs: Length( numericsimple ), TgtBar( numericsimple
    ) ;
    variables: oLRSlope( 0 ), oLRAngle( 0 ), oLRIntercept(
    0 ), oLRValue( 0 ) ;

    Value1 = LinearReg( C, Length, TgtBar, oLRSlope,
    oLRAngle, oLRIntercept, oLRValue ) ;

    TimeSeriesForecast = oLRValue ;

    {
    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.
    }



    *******************END CODE **********************


    ++++++++++++++++BEGIN 2nd CODE++++++++++++++++


    Linear Regression is a concept also known as the
    "least squares method" or "best fit." Linear
    Regression attempts to fit a straight line between
    several data points in such a way that distance
    between each data point and the line is minimized.

    This function calculates the slope and angle of a
    linear regression line, and also determines the value
    of the line on the current bar or a specified number
    of bars ago or projected bars into the future.

    Function
    LinearReg(Price, Length, TgtBar, oLRSlope, oLRAngle,
    oLRIntercept, oLRValue)

    Parameters
    Price
    Specifies the value of interest is to be used.

    Length
    Specifies the number of bars to consider in the
    regression calculation.

    TgtBar
    Represents the number of bars into the future or back
    into the past, zero for the current bar.

    OLRSlope
    Variable that receives the slope of the linear
    regression line.

    oLRAngle
    Variable that receives the angle of the linear
    regression line in terms of degrees.

    oLRIntercept
    Variable that receives the regression value for x
    number of bars out into the future or x number of bars
    back in the past.

    oLRValue
    Variable that receives the regression value for x
    number of bars out into the future or x number of bars
    back in the past.


    Returns
    LinearReg always returns 1. It calculates the linear
    regression line and passes the slope, angle, intercept
    and associated value by reference back to the calling
    function or technique.

    Usage
    The equation of any line resembles the following:

    y = mx + b

    In the equation m refers to the slope of the
    regression line, b refers to the constant intercept of
    the y-axis, x is the independent variable, and y is
    the dependent variable. This function returns all
    values.

    The input Price can be hard coded with a bar attribute
    such as Close, Open, High, Low, and Volume or a
    numeric series type input. It can also be replaced
    with a valid EasyLanguage expression. For example:
    Close + Open, or Average(RSI(Close,14),14).

    The inputs Length and TgtBar can be hard coded
    replaced with numeric simple type inputs.


    ++++++++++++++++END 2nd CODE++++++++++++++++

    { Single-return wrapper function calling
    multiple-output function; see MULTIPLE-OUTPUT
    FUNCTIONS note below }

    inputs: Length( numericsimple ), TgtBar( numericsimple
    ) ;
    variables: oLRSlope( 0 ), oLRAngle( 0 ), oLRIntercept(
    0 ), oLRValue( 0 ) ;

    Value1 = LinearReg( C, Length, TgtBar, oLRSlope,
    oLRAngle, oLRIntercept, oLRValue ) ;

    TimeSeriesForecast = oLRValue ;

    {
    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.
    }
    Code:
    dd
    Last edited by redislk; 03-20-2005, 08:00 PM.

  • #2
    redislk,

    Here is a link to an efs that may meet your needs that was written by Chris Kryza and is in his fileshare group.

    Comment


    • #3
      Using that function

      Is there a way to use that Time Series Forcast and a weighted ma cross over system as in the following code.

      timeseriesforcast (Length, Barsplus) > Xaverage (Close,length1)

      The attached code almost does it but with a lsma. Can we replace the lsma stuff with the timeseries formula?
      Attached Files

      Comment

      Working...
      X