开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Charting App using TWS price feed


mickjenks
 

I was wondering if anyone knowledgeable about VB programming could
give some input concerning how to go about developing a real time
intraday charting app to be used for charting prices received through
the TWS. Looking for advice on what the general structure of such a
program should be, etc. Thanks for any help.

Mick


marinindextrader
 

First realize this before you proceed...

The price change event does not occur on each trade, but rather like
its namesake implies, a price change event. That is to say that it
only updates if it is different. Several trades can occur at the same
price and your TWS tickPrice event does not fire.

Further, you will need to create a suitable sized array to store OHLC
for each period you are tracking. If you want to retain say 30
minutes of of one minute bars, you will need a 2 dimensional array
that is 4 columns wide, and 30 rows deep.

The implications of this when concerning oneself with charting
applications is that you must produce the time stamps via a client
timer control on the form, or through a monitoring process of the
system clock using DateAdd functions.

For instance...if you want a 1 minute chart, you would define your
start time as any instance of concurrent period closure, either
future or past. That is to say, you define the 1 minute incrament
start time as the last 1 minute period to close. As the minute
elapses, you update your storage array's last row as defined by the
price events you are receiving. A small single row array will be
needed to rewrite the master array when the period closes, as you in
essence discard the first entry, shift all of the data up one slot,
and begin recording again the price events of the current period, in
the last array slot. You can manage your array in the reverse order,
with the most recent slot the foremost slot. That is matter of
prefrence.

The array can be displayed in either a PictureBox Control, or an
Image Control. I prefer the former to the latter because the Picture
Box acts as a true container, and is not a lightweght control. It
also affords properties not available in the image control.

You can draw lines, candelsticks and shapes as you see fit using the
data to produce the chart in Picture Box. Lightweight controls such
as shapes and lines coordinate themselves to the pane of the Picture
Box...so positioning is fairly easy and intuitive.

You can spend a tremendous amount of time learning to program a
charting display using picture box...tweaking the display and
scaleability take time to program....but in the end, all of your
programming skills will have improved greatly.

Your question is a broad and sweeping topic...take a look at Picture
Box, and build your capture array. When you have some specific
questions, then perhaps I could be of more help.

Scott
Owner








--- In twsapi@y..., mickjenks <no_reply@y...> wrote:
I was wondering if anyone knowledgeable about VB programming could
give some input concerning how to go about developing a real time
intraday charting app to be used for charting prices received
through
the TWS. Looking for advice on what the general structure of such a
program should be, etc. Thanks for any help.

Mick