Welcome Guest, you are in: Login
CTS Futures
Home
Pricing
Market Data
FAQ
Videos

T4 Desktop
User Guide
Scripting Guide
Release Notes

Mobile and Web
T4 Mobile for Android
T4 Mobile for iOS
T4 Mobile for Browser
T4 WebTrader

Admins
T4 Admin Guide
MiFID II/MiFIR

Developers
API 4.7 Guide
FIX API


Walkthrough #1 - A Basic Example

RSS
This walkthrough is intended to demonstrate the very basics of scripting.

A chart script is composed of one or more script "statements". A statement can be either a mathematical function that produces a value, an assignment of a function to a variable to use later in the script, or a command instructing the scripting engine what or how to plot a value on chart.

Before we get started, you should have a chart open in front you. It does not matter contract you use, but the chart should be free of any other studies an uncluttered so that you can easily see the results of your script.



Example 1: A line-plot of the closing price.

CLOSE
Image

This statement is evaluated one time for every bar on the chart. Because this script contains no commands to the contrary, the script engine will go ahead and plot the output of this script as a simple line chart.



Example 2: A line-plot of the "typical" price.

(H + L + C) / 3
Image
The “typical” price of a bar chart is average of the high, low and close. H, L, and C are aliases for the HIGH, LOW, and CLOSE bar prices. Aliases can be used in place of, or interchanged with the full names of the data fields for great conciseness within you scripts.



Example 3: A line-plot of the 10-period Simple Moving Average of the typical price.

SUM((H + L + C) / 3, 10) / 10
Image
This example utilizes the built-in SUM function. The SUM function takes 2 comma-separated parameters as follows:

SUM(<number to be added>, <number of periods to sum over>)

In this example, we would like to add up the typical price (H+L+C)/3 over 10 periods. Lastly, we divide this sum by 10 to get the average value over the last 10 periods.
  Name Size
- wt_1_example_1.png 12.64 KB
- wt_1_example_2.png 11.95 KB
- wt_1_example_3.png 10.81 KB

Trade how you want, where you want

support@ctsfutures.com (312) 939 0164

2 Pierce Pl, Suite 200, Itasca, IL 60143

© 2009-2023 Cunningham Trading Systems LLC All rights reserved.