Exciting Update: Version 1.0.0 is now available, introducing high-performance technical indicators and custom drawing tools. Read more
Version: 1.0.0

Android Wrapper Documentation

The Backtestx Charts Android wrapper enables developers to integrate high-performance charting interfaces into Android-based Kotlin or Java projects. It handles WebView settings and exposes clean, native layouts.

Overview

Instead of manually configuring WebViews and resource paths, you can import our Android library dependency. The library wraps Android's native WebView container and compiles the asset folder cleanly into your APK.

Installation

1. Add JitPack Repository

Add JitPack to your project-level repository configurations (typically in settings.gradle):

dependencyResolutionManagement {
  repositories {
    google()
    mavenCentral()
    maven { url 'https://jitpack.io' }
  }
}

2. Add Gradle Dependency

Add the dependency coordinates to your app-level build.gradle file:

dependencies {
  implementation 'com.github.backtestx-official:BacktestxChartsAndroid:1.0.0'
}

Usage

1. Declare View in XML Layout

Place the custom chart view inside your layout resource XML file:

<com.backtestx.charts.BacktestxChartView
  android:id="@+id/backtestxChartView"
  android:layout_width="match_parent"
  android:layout_height="match_parent" />

2. Bind Data (Kotlin)

Reference the view inside your Activity/Fragment and feed standard OHLC data formatted in a JSON string:

val chartView = findViewById<BacktestxChartView>(R.id.backtestxChartView)

val data = \"\"\"
[
  {"time": "2026-06-10", "open": 100.0, "high": 105.0, "low": 98.0, "close": 102.5},
  {"time": "2026-06-11", "open": 102.5, "high": 108.0, "low": 101.0, "close": 107.2}
]
\"\"\".trimIndent()

chartView.updateData(data)

3. Switch Asset Symbol

chartView.changeSymbol("BTCUSD", "1D")

Advanced API Controls

If you need to evaluate custom JS functions on your engine directly, you can fetch the raw WebView container:

val rawWebView = chartView.getWebView()
rawWebView.post {
  rawWebView.evaluateJavascript("javascript:window.chart.addIndicator('rsi', { period: 14 });", null)
}