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

*****SPAM***** Re: Power Basic programming-metastock



PureBytes Links

Trading Reference Links

SPAM: -------------------- Start SpamAssassin results ----------------------
SPAM: This mail is probably spam.  The original message has been altered
SPAM: so you can recognise or block similar unwanted mail in future.
SPAM: See http://spamassassin.org/tag/ for more details.
SPAM: 
SPAM: Content analysis details:   (5.50 hits, 5 required)
SPAM: REFERENCES         (-0.5 points) Has a valid-looking References header
SPAM: X_AUTH_WARNING     (-0.2 points) Found a X-Authentication-Warning header
SPAM: FORGED_RCVD_FOUND  (0.8 points)  Possibly-forged 'Received:' header found
SPAM: USER_AGENT_OE      (0.2 points)  X-Mailer header indicates a non-spam MUA (Outlook Express)
SPAM: SPAM_PHRASE_02_03  (0.8 points)  BODY: Spam phrases score is 02 to 03 (medium)
SPAM:                    [score: 2]
SPAM: FORGED_RCVD_TRAIL  (2.0 points)  trail of Received: headers seems to be forged
SPAM: SUBJ_HAS_UNIQ_ID   (1.1 points)  Subject contains a unique ID
SPAM: UPPERCASE_25_50    (1.3 points)  message body is 25-50% uppercase
SPAM: 
SPAM: -------------------- End of SpamAssassin results ---------------------

This is a multi-part message in MIME format.

------=_NextPart_000_0174_01C1BC99.A6353E90
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

William,

I have taken the liberty of copying my reply to the list as it might just
help others.

Power Basic has a user manual that is downloadable or at least I think it
is. They also have a number of examples on their web site. There is also a
book available  for free - PC Magazine's BASIC Techniques and Utilities.
Can't remember if this is downloaded separately or comes when you purchase
Power Basic 32 bit DLL. Can't say I've really needed either - It's truly
that straight forward.

I'd also have a look at Kaufman's book Trading systems and methods  - this
will give you a good source of formulae etc. They are often laid out for
TradeStation so they will translate fairly easily into PowerBasic.  For
mathematical methods, I'd heartily recommend Numerical Recipes from
Cambridge University Press http://www.nr.com/. Mathematical purists often
quibble over some of the implementations, but for the sums I do it's fine.
Years ago, there used to be a version of it for basic. You might find one on
e-Bay or similar and it would be worth purchasing if you are thinking of
serious computation.

I have attached a copy of the code for the  32 bit version of the T3 moving
average as a straightforward example. I use the code as as a template for my
own work  as some of the bits are standard e.g. Libmain and Wep

You'll notice, that there are two calls to the DLL  - the first is the
initialisation, and the second does the calculation on each bar.

Shout if I can help further.

------=_NextPart_000_0174_01C1BC99.A6353E90
Content-Type: text/plain;
	name="T3.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="T3.txt"

' ============================
'   DLL Compiler Directives  =
' ============================

$DEBUG ERROR ON                         ' No compile time symbolic debug.
$COMPILE DLL                           ' Compile to DLL rather than EXE.
' $HUGE                                ' Let arrays be > 64K.
$DIM ALL                               ' Declare variables before use.
$OPTION VERSION4                       ' Compatible with Windows NT, 2000.


' =============================
'   Declare Global Variables  =
' =============================

GLOBAL INDAT    AS SINGLE              ' Price.
GLOBAL T3PER    AS SINGLE              ' T3 period.
GLOBAL T3SMO    AS SINGLE              ' T3 smoothing coefficient.

' Working variables for the T3 MA.
GLOBAL B2        AS DOUBLE
GLOBAL B3        AS DOUBLE
GLOBAL E1        AS DOUBLE
GLOBAL E1P       AS DOUBLE             ' E1 on previous pass.
GLOBAL E2        AS DOUBLE
GLOBAL E2P       AS DOUBLE             ' E2 on previous pass.
GLOBAL E3        AS DOUBLE
GLOBAL E3P       AS DOUBLE             ' E3 on previous pass.
GLOBAL E4        AS DOUBLE
GLOBAL E4P       AS DOUBLE             ' E4 on previous pass.
GLOBAL E5        AS DOUBLE
GLOBAL E5P       AS DOUBLE             ' E5 on previous pass.
GLOBAL E6        AS DOUBLE
GLOBAL E6P       AS DOUBLE             ' E6 on previous pass.
GLOBAL C1        AS DOUBLE
GLOBAL C2        AS DOUBLE
GLOBAL C3        AS DOUBLE
GLOBAL C4        AS DOUBLE
GLOBAL F1        AS DOUBLE
GLOBAL F2        AS DOUBLE
GLOBAL T3AVE     AS DOUBLE             ' Final calculated T3 MA.

GLOBAL T3ADR     AS DWORD              ' Addr. of T3AVE in calling prog.
GLOBAL SINPTR    AS SINGLE PTR         ' Pointer for a 4 byte float.

' =====================
'   Function LibMain  =
' =====================

' Function LibMain is run once by Windows when it loads this DLL.
' This function definition is the same for any DLL.  Certain other
' run-once code can be put here as well, like initializing global
' objects.

FUNCTION LIBMAIN(BYVAL hInstance AS LONG, _
                 BYVAL Reason    AS LONG, _
                 BYVAL Reserved  AS LONG) _
                 EXPORT AS LONG


  LIBMAIN = 1                          ' 1 tells WIN that load
                                       ' was a success.
END FUNCTION


' ====================
'   Function T3INIT  =
' ====================

FUNCTION T3INIT (BYVAL T3PER AS SINGLE, BYVAL T3SMO AS SINGLE)_
                EXPORT AS INTEGER

  ' Init the MA variables.
  B2 = T3SMO * T3SMO
  B3 = T3SMO * T3SMO * T3SMO
  C1 = -B3
  C2 = 3 * B2 + 3 * B3
  C3 = -6 * B2 - 3 * T3SMO - 3 * B3
  C4 = 1 + 3 * T3SMO + B3 + 3 * B2
  F1 = 2 / (T3PER + 1)
  F2 = 1 - F1

  FUNCTION = 1 ' Return a dummy integer value.

END FUNCTION


' ====================
'   Function T3CALC  =
' ====================

FUNCTION T3CALC (BYVAL INDAT AS SINGLE, BYVAL T3PER AS SINGLE,_
                BYVAL T3SMO AS SINGLE, BYVAL T3ADR AS DWORD)_
                EXPORT AS INTEGER

  ' Do the MA calculation.
  E1 = F1 * INDAT + F2 * E1P
  E2 = F1 * E1 + F2 * E2P
  E3 = F1 * E2 + F2 * E3P
  E4 = F1 * E3 + F2 * E4P
  E5 = F1 * E4 + F2 * E5P
  E6 = F1 * E5 + F2 * E6P
  T3AVE = C1 * E6 + C2 * E5 + C3 * E4 + C4 * E3

  SINPTR = T3ADR      ' Copy EL float address to pointer variable.
  @SINPTR = T3AVE     ' Send the float to the EL calling program.

  ' This is previous bar values for next pass.
  E1P = E1
  E2P = E2
  E3P = E3
  E4P = E4
  E5P = E5
  E6P = E6

  FUNCTION = 1        ' Return a dummy integer value.

END FUNCTION


' =================
'   Function Wep  =
' =================

' Function WEP tells Windows to unload this DLL.  This function
' definition is the same for any DLL.  Certain other run-once
' code can be put here as well, like de-allocating objects.

FUNCTION Wep (BYVAL nParameter AS INTEGER) EXPORT AS WORD

  Wep = 1                              ' Tells WIN that unload
                                       ' was a success.
END FUNCTION


' ===============
'   End Of DLL  =
' ===============
------=_NextPart_000_0174_01C1BC99.A6353E90--