Appearance

Personalize your experience

Mode
Accent Color
Direction
Analysis Marketplace
QuaScript

Risk Ladder Trail

Admin's Choice NewFree

Trailing stop with live 1R / 2R / 3R ladders, risk and reward zones

WebGPU StudioPrice overlay WebGPU CanvasHybridDashboardSignalsAlerts
quascriptgpuwebgpuriskr-multipletargets

Favourites and Admin's Choice analyses are listed in the terminal's indicators window under Analysis Marketplace.

Language
QuaScript
Engine
Native C++, incremental on live ticks
Rendering
WebGPU + Canvas
Placement
Price overlay
Settings
5
Plots
8
Lines of code
88
Source
presets/analysis/gpu/risk_ladder_trail.qs
Risk Ladder Trailengine result
Loading the engine result…
quatick-charts · QuaScript engine on synthetic 1-minute bars · drag to pan · scroll to zoom · Run executes the script on the engine (⌘/Ctrl+Enter while editing)

About

A complete trade plan on the chart. An ATR supertrend decides the side and trails the stop; every flip opens a new leg whose risk (entry to the initial stop) defines R. From there the ladder draws the 1R, 2R and 3R targets, fills the risk zone (entry to stop) and the reward zone (entry to 3R), and tags each target the first time it is reached. The dashboard reports the live leg: side, entry, stop, the size of R and the open R multiple, so position size and expectancy are always one glance away.

8
Plotted series
2
Signal marks
4
Drawings
1
Alert rules
5
Settings
76
Lines of code

What it draws

Price overlay · counted from the engine's plot table and the script's draw calls

Series

  • Line5 visible · 3 helper
    Trailing stopEntryTarget 1Target 2Target 3
  • Band fills (render.band calls)4
Legend
Trailing stop Entry Target 1 Target 2 Target 3

Signal marks

Long legShort leg

Drawings and chart effects

  • Dashboard tables1 created
  • Tags3 created

How it runs

From source to the live chart, for this script

  1. 1
    Compile

    The QuaScript compiler checks the 88-line script (76 lines of code) and lowers it for the native C++ engine. Compile errors point at the exact line and column.

  2. 2
    Place

    The header sets overlay = true, so everything is drawn on the price chart, on the same scale as the candles.

  3. 3
    Compute

    The script runs once per bar, oldest to newest. 8 persist variables keep state (objects, counters) across bars.

  4. 4
    Stay live

    On the terminal the script keeps one live engine session: a tick rolls the forming bar back to its checkpoint and re-executes only that bar, and new bars are appended, so history is never rerun while the market moves. The live result is identical to a full run.

  5. 5
    Render

    The results are handed to the chart: series on WebGPU, drawings on the Canvas 2D QuaScript layer.

  6. 6
    Tune

    5 settings in 2 groups appear in the chart's settings dialog. Changing one reruns the engine with the new value.

Rendering

Hybrid: this script draws on 2 surfaces at once

WebGPUSeries renderer

The browser's modern GPU API. The chart uploads every line, band and mark of the script as GPU buffers and draws them in one pass, so dense heatmaps and dozens of series stay smooth while you pan and zoom. Without WebGPU support the chart's GPU layer falls back to WebGL 2, then Canvas 2D.

In this script
  • • 8 plotted series
  • • 4 band fill calls
  • • 2 signal mark types

Chosen by render = webgpu in the header.

WebGLNot used

GPU drawing through WebGL 2, available in every current browser. Used for chart-native profiles and for series that ask for it with backend = "webgl". Fast for large numbers of bars and wide fills.

CanvasUsed

The browser's 2D drawing API. Text-heavy and object-style output (dashboard tables, zones, tags, segments), candle colors and backgrounds are painted by the QuaScript layer, a Canvas 2D surface over the chart. Series use Canvas when the script's header does not ask for a GPU.

In this script
  • • 1 dashboard tables (QuaScript layer)
  • • 3 tags (QuaScript layer)

Alerts

1 alert rule declared with alert.rule

New leg

The trail flipped; a new leg_risk ladder starts at this close

Settings

5 settings, grouped as in the chart's settings dialog

Trail
SettingTypeDefaultRange / optionsId
ATR multipleNumber30.5 – 10, step 0.1atr_multiple
ATR lengthInteger102 – 200atr_length
Targets
SettingTypeDefaultRange / optionsId
Target 1 (R)Number10.25 – 10, step 0.25target_1_r
Target 2 (R)Number20.25 – 10, step 0.25target_2_r
Target 3 (R)Number30.25 – 20, step 0.25target_3_r

Script

packages/quascript/presets/analysis/gpu/risk_ladder_trail.qs

Header

analysis "Risk Ladder Trail" {
    overlay = true
    render = webgpu
    max_objects = 300
}
Total lines
88
Code lines
76
Comment lines
7
Helper functions
0
Loops
0
Persistent variables
8
Higher-interval feeds
0
Engine plots
8

Built with

Technical analysis (ta.*)
ta.supertrend
Math (math.*)
math.absmath.is_namath.max

Discussion

Sign in to join the discussion. Your posts and replies show up on your profile.