Skip to main content
v1.2.0

Creating charts

Technical Analysis Charts must always be created in code. For this, you must provide your valid license key.

from lightningchart_trader import TAChart

# Your license key
license_key = 'my-license-key'

It is recommended to save the chart to a variable, so you can modify its properties later.

# Initialize TAChart
trader = TAChart(license_key)

Chart options

When a chart is created in code, you can set various settings regarding chart's behavior and visual appearance. All settings are optional except of license_key.

license_key

You should put your license key here.

load_from_storage

Sets whether chart settings should be saved to and loaded from the local storage. By default, Technical Analysis Chart saves all the same information that is saved to a template to local storage, when the chart is closed due to for example page reload or window closing. Whenever a chart instance is opened again, the chart checks the local storage for settings from previous sessions and loads them. Set this option false to disable this. Note that this cannot be changed after the chart has been created.

axis_on_right

Determines on which side the price axis (Y-axis) is located. Default side is right (true). Note that loading from local storage overrides this setting. Therefore, this option works only if loadFromStorage is set false.

theme

Selects the overall color theme of the chart from five pre-defined options ('cyberSpace', 'darkGold', 'light', 'lightNature', 'turquoiseHexagon'.). Note that loading from local storage overrides this setting. Therefore, this option works only if loadFromStorage is set false.

html_text_rendering

This setting allows users to switch between Html texts and WebGl texts. generally, Html texts are visually more appealing but can cause a small decrease in performance especially in demanding applications with 10000+ points. Html texts are enabled by default.

trader = TAChart(
license_key,
html_text_rendering = True,
load_from_storage = False,
theme = 'turquoiseHexagon',
axis_on_right = True
)

Using the library

That's it! You can start creating charts with LightningChart Python Trader, like so:

from lightningchart_trader import TAChart

# Initialize the TAChart with a license key
license_key = 'your-license-key'
trader = TAChart(license_key)

# Configure the chart
trader.set_price_chart_type('CandleStick') # Set the chart type
trader.set_chart_title('Trading Chart with Sample Data') # Set the chart title

# Adding sample OHLC (Open, High, Low, Close) data programmatically
ohlc_data = [
{'open': 1.1, 'high': 1.2, 'low': 1.0, 'close': 1.15, 'dateTime': 'Jan 1, 1970'},
{'open': 1.1,'high': 1.2,'low': 1.0,'close': 1.15,'dateTime': 'Thu, 01 Jan 1970 00:00:00 GMT+0000',},
{'open': 2, 'high': 2, 'low': 1.8, 'close': 1.95, 'dateTime': '04 Dec 1995'},
{'open': 2.1,'high': 2.1,'low': 1.9,'close': 2.05,'dateTime': '04 December 1995',},
{'open': 1.3, 'high': 1.4, 'low': 1.2, 'close': 1.35, 'dateTime': '2019-01-01'},
{'open': 1.4,'high': 1.5,'low': 1.3,'close': 1.45,'dateTime': '2019-01-01T00:00:00',},
{'open': 1.8,'high': 1.8,'low': 1.6,'close': 1.75,'dateTime': '2019-01-01T00:00:00.000+00:00',},
{'open': 1.5, 'high': 1.6, 'low': 1.4, 'close': 1.55, 'dateTime': 'March 15, 2020'},
{'open': 1.2, 'high': 1.3, 'low': 1.1, 'close': 1.25, 'dateTime': '01/02/2022'},
{'open': 1.6, 'high': 1.7, 'low': 1.5, 'close': 1.65, 'dateTime': '2022/12/31'},
]

# Sending the data to the chart
trader.set_data(ohlc_data)

# Open the chart
trader.open()

Chart example