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

Re: Best alternative to TradeStation 2000i?



PureBytes Links

Trading Reference Links

I don't mess much with indicators, and virtually all of my 3000+ lines of
ESPL is proprietary, however this is my generic XMA function which runs XMA
on virtually any value associated with a price bar.

Function ufAverageExponential(lLastBar : LongInt; lLength : LongInt;
lValueConstant : LongInt; rPrevXA : Real) : Real;
/***************************************************************************
***
   Author   : Earl Adamy
   Copyright: Copyright 1999 by Earl Adamy, all rights reserved
   History  : 01/26/99 Create function
   Purpose  : Calc Exponential MA of specifed bar value in current chart
              lLastBar is last bar on which Average is to be calculated
                0 specifies that BarEnd is to be used
              lLength is number of bars over which Avg is to be calculated
              lValueConstant is one of following:
                eOpen, eHigh, eLow, eClose, eLast (Close) values on bar
                eRange (High - Low)
                eTrueRange (> High or yesterday Low - < Low or yesterday
High
                eMidpoint (H+L/2), eMid3 (H+L+C/3, eMid4 (O+H+L+C/4)
                eNet (Close - Yesterday Close)
              rPrevXA is for recursing the previous XA providing more
efficient calcs
  Formula   : XFactorToday = 2 / (lLength + 1)
              XMA = (Price(today) * XFactorToday) + XMA(yesterday) * (1 -
XFactorToday)

****************************************************************************
**/
var
  lBarX:          LongInt;
  lBarBeg:        LongInt;
  lBarEnd:        LongInt;
  rAverage:       Real;
  rXFactorToday:  Real;

Begin
  If lLastBar = 0 Then
    {default to EndBar}
    lBarEnd := BarEnd
  Else
    {use requested bar}
    lBarEnd := lLastBar;
  rXFactorToday := (2.0 / (lLength + 1));

  rAverage := rPrevXA;
  If rAverage = 0.0 then Begin
    /* Initializes calc with simple average for bar (lLastBar - Length),
        then runs exponential calculation for length bars to bring
        exponential average up to speed
    */
    lBarBeg   := (lBarEnd - lLength);
    if lBarBeg < 1 then lBarBeg := 1;
    rAverage := Average(lValueConstant, lBarBeg, lLength);
    lBarBeg   := lBarBeg + 1;
  End
  Else
    {Calculate average for one period}
    lBarBeg := lBarEnd;
  For lBarX := lBarBeg to lBarEnd do
    rAverage := (rXFactorToday * Bar(lValueConstant, lBarX)) + ((1.0 -
rXFactorToday) * rAverage);
  Result := rAverage;
End;  {ufAverageExponential}

Suggest you visit www.ensignsoftware.com and have a look at the user group
Ensign List archives or download EW and have a look at \macro\samples.spt.

Earl

-----Original Message-----
From: Cab Vinton <cvinton@xxxxxxxxxxx>
To: L_Omega <omega-list@xxxxxxxxxx>
Date: Tuesday, April 27, 1999 12:07 PM
Subject: Re: Best alternative to TradeStation 2000i?


>Earl (or some other Ensign user):
>
>Would you mind posting ESPL code for a simple moving average system so
>we can see for ourselves what the beast looks like?
>
>Is there anything TS4 can do that Ensign can't? (backtesting,
>optimization, performance results, etc.)
>
>And vice versa? (I'm thinking especially of portfolios, custom
>optimization criteria, etc.)
>
>Thanks,
>
>Cab Vinton                      ,,,
>cvinton@xxxxxxxxxxx            (o o)
>---------------------------oOO--(_)--OOo---------------------
>