Docs / Introduction

Introduction

TDSL (Trading Domain Specific Language) is CoreXTrader's native scripting language for building chart indicators and automated trading strategies. It uses a clean C++-style syntax and compiles directly to high-performance Rust for maximum execution speed.

Every script runs inside the CoreXTrader execution engine — with direct access to live price feeds, position data, account information, and a full library of built-in technical indicators.


Module Kinds

Indicator
Triggered by calculate()
  • Runs on every historical bar, then on each new bar
  • Returns typed struct buffers rendered on the chart
  • Cannot execute trade orders
  • Supports Init() and Exit() hooks
Strategy
Triggered by Tick()
  • Executes on every live price tick
  • Full access to Trade, Position, Order, and Deal APIs
  • Can embed sub-indicators via Load()
  • Supports Init() and Exit() hooks

The about Block

Script metadataTDSL
about {
  author:  "Your Name";
  version: "1.0.0";
  about:   "A short description of what this script does.";
  link:    "https://corextrader.com";
}

Lifecycle Functions

Init()Once on loadSet up state, call Load() and Native/Custom.Source() here.
calculate()Every bar (Indicators)Full bar history available. Returns a typed struct with buffer arrays.
Tick()Every tick (Strategies)Real-time. Access live prices and trade execution functions.
Exit()On shutdown / unloadCleanup, final logging, close any open resources.
Note
calculate() is called with the full price history first. The built-in Chart.resume_index tells you which bar to start from on incremental updates.

Your First Script

SimpleMA.tbcTDSL
about {
  author:  "CoreXTrader";
  version: "1.0.0";
}

parameters { int period = 20; }

struct MAResult { double value; }

display {
  separate_window: false;
  outputs: 1
  MAResult.value { type: "line"; color: "#dc2626ff"; name: "SMA"; width: 2; };
}

series double result[];

calculate() {
  double closes[] = close();
  int len   = length(closes);
  int start = Chart.resume_index > 0 ? Chart.resume_index - 1 : period - 1;
  result[]  = create_array(len);

  for (int i = start; i < len; i = i + 1) {
    double sum = 0.0;
    for (int j = 0; j < period; j = j + 1) { sum = sum + closes[i - j]; }
    result[i] = sum / period;
  }

  return MAResult { value: result };
}