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

Re: DLL Programming in PowerBasic - Simple Example Request - such as SMA



PureBytes Links

Trading Reference Links

Below is an excerpt from a TS4 indicator that receives values to variables
for bar open, high low and close. Note, TS variables (declared via "Vars:"
must be used when passing by reference and changing the referred value or
you get a crash.
{------------------------}
Vars: lng(0), bH(0), bL(0), bO(0), bC(0), sSym(""), BN(0);
DefineDllFunc:"C:\Data\TS\PMWFASTQ.DLL",Long,
 "GetQuotes",Long, {Bar Number}
 LPFLOAT, {Last}
 LPFLOAT, {Open}
 LPFLOAT, {High}
 LPFLOAT; {Low}

 lng = GetQuotes(BN, &bC, &bO, &bH, &bL);
{------------------------}

Here is a snippet from the Powerbasic dll that is referenced above:

'---------------------------------
' From the global module declarations
Global gLast as Single
Global gOpen as Single
Global gHigh as single
Global gLow as Single

 Function GetQuotes(Byval lBarNum as Long, Byval dLast as Single PTR, Byval
dOpen as Single PTR, Byval dHigh as Single PTR, Byval dLow as Single PTR)
Export as Long
  @dLast = gLast
   @dOpen = gOpen
   @dHigh = gHigh
   @dLow = gLow
   Function = 1
End Function
'---------------------------------

Patrick White
----- Original Message -----
From: "Saul" <saul@xxxxxxxxxxxxxxxxxxxxx>
To: "Omega-List" <omega-list@xxxxxxxxxx>
Sent: Sunday, July 07, 2002 12:20 PM
Subject: DLL Programming in PowerBasic - Simple Example Request - such as
SMA


Hi all,

I have spent a lot of frustrated time trying to get functions written in
PowerBasic to work with Tradestation - the problem lies for me in
passing price series to a function - I realise its done thru pointers
etc - however I have become quite proficient at crashing tradestation
and thought it was time to ask for some help.

I have gone thru the email archive and any other tradestation dll
programming examples I could find on the net - still got problems.

The few examples I have found rely on two datastreams one which passes
the price series to the dll stored in globals, with another function
being called on a separate data series which passes back the complete
calculated dataseries for plotting etc.

I would like some help with a function that is evaluated on a bar by
basis such as EL does, whereby data is sent to function as required and
evaluated to be returned.

The type of prototype I would like to see is something such as a Simple
Moving Average.

Whereby a price dataseries is passed bar by bar, with a length
parameter, returning a single value for each bar.



Thanks in advance
Saul