Good afternoon ADL Community….

I wanted to get you all an example of how to build a VWAP
Technical Indicator type logic. This following example is ONLY A SAMPLE and
possible way to create this logic. You
will see below that you need to have an Instrument Block to pull in the Time N
Sales Data, and a Time Window variable.
In the sample you can see it does not quite match up exactly with the
VWAP calculations in the Chart. This is due to the fact that the ADL algo does
not start calculating the VWAP values until you click LAUNCH or START for the algo
itself. I have also made the below algo
example to have the ability to EXPORT the VWAP calculation….. you can see this when running on the ADL
Design Canvas as well in the Autotrader Widget. **Here is a description of the various parts of the internal logic construction: ****PART A**. Value Bucket Blocks have been added to capture not
only Data Points' timestamp, but also their Trade Price and Quantity.

PART B1. As each new data point is created, add that point's
PxQ to the running SUM(PxQ) ... this is handled by the Accumulator labeled,
"Sum Of PxQ For All Data Points In Queue."

Also add the data point's Q to the running SUM(Q) ... this
is handled by the Accumulator labeled, "Sum Of Q For All Data Points In
Queue."

PART B2. We also keep a running SUM(PxQ) and SUM(Q) for Data
Points REMOVED From Queue because:

SUM(P x Q) = [SUM(P x Q) for ALL Data Points] - [SUM(P x Q)
for Data Points that fell out of queue]

SUM(Q) = [SUM(Q) for ALL Data Points] - [SUM(Q) for Data
Points that fell out of queue]

And this method is faster than recalculating the sums at
each and every new trade (as described in the question stem).

PART B3. Note the order of things:

The Branch Block detects that the First Data Point just fell outside the queue

We add this point's PxQ and Q to the Accumulators

The Iterator increases its value by 1, and the next data point in queue is newly designated as the First Data Point.

Loop back to Step 1.

The loop continues until First Data Point is inside the
queue.

PART C**.** Once you have the correct SUM(P x Q) and SUM(Q),
divide the two to get the VWAP.**You will see in the following screen shots the overall
algo logic construction and the descriptions of the internal block formulas.... **

thub.nodes.view.add-new-comment

Correct me if I'm wrong, what if we just use two movingavg blocks to record P*Q and Q and vwap = MA(P*Q)/MA(Q)?

Hmmmm try building it in that same example and run it. See what the output values are for each and compare....:) Thats the great thing about the Design Canvas,...... you can test all this on there and watch it update

Could you please help me compare the two? It is little bit harder for me to build yours from the scratch... :/ Thanks! :)

Ask questions and share ideas about the TT^{®} and X_TRADER^{®} platforms.

First time here? See our Getting Started Guide and FAQs.

Follow
### Follow this article

Ease of Testing Exchanges and Contract Market States with ADL

Execution Algos are available on the TT Platform

Basic TT Time Sliced entry example for ADL

Importing X_TRADER Pro ADL algos to web-based TT platform....

Easy way to test OMA algo logic from the design canvas..

Types of Orders to select in an Order Block

Easy way to test OMA algo logic from the design canvas (updated)

The new MsgInfo Extractor block in TT ADL

ASE Order Block and Quote / Hedge/ Fill messages and using Alert Blocks for recording

© 2017 Trading Technologies International, Inc. All rights reserved.

Powered by AnswerHub