Worked YAML Examples

This page is where the manual comes together.

Written By AxiomCharts

Last updated About 1 hour ago

Worked YAML Examples

This page is where the manual comes together. Use it when you want to see how:

  • YAML layout

  • default tokens

  • expression writing

  • setup, entry, take-profit, and stop-loss sections

all fit together inside one strategy workflow. These are teaching examples, not product promises. Their job is to help you see what the builder can express and how to read that expression clearly on the chart. These examples are not written to produce real world results and are not "strategies" just examples to show what you can build.

How To Use This Page

The easiest way to learn from this page is:

  1. choose one difficulty level only

  2. copy the blocks into the matching long-side YAML boxes

  3. keep the strategy in `Long Only` while you learn the pattern

  4. verify the behavior on-chart before you start editing

  5. once the pattern makes sense, borrow pieces into your own workflow

If a block feels too heavy, step back one level. These examples are meant to stretch understanding, not rush it.

The Difficulty Ladder

Level

What it teaches

Beginner

basic setup -> entry -> exit structure with easy-to-read expressions

Intermediate

multiline expressions, lookbacks, targeted exits, and authored expiry

Advanced

multi-leg exits, nested ternaries, more expressive price logic, and denser condition building

Extreme

heavy multiline expressions, layered state thinking, deep function use, and the outer edge of what this builder can realistically express

Beginner Example

What this one teaches

  • one named setup

  • one market entry

  • one take profit

  • one stop loss

  • confirmed-bar logic

  • simple default-token usage

Long Setups

- setup_name: BG_TREND_UP
  setup_gate_condition: BARSTATE_ISCONFIRMED
  setup_active_when: PRICE_CLOSE > PRICE_HLC3 && RISING(PRICE_HLC3, 2)
  setup_cancel_when: PRICE_CLOSE < PRICE_HL2
  setup_confirm_type: BAR_COUNT
  setup_confirm_count: 1

Long Entries

- entry_name: BG_MARKET_ENTRY
  entry_belongs_to_setup: BG_TREND_UP
  entry_gate_condition: BG_TREND_UP_CONFIRMED
  entry_trigger_when: CROSSOVER(PRICE_CLOSE, PRICE_HLC3)
  entry_order_type: MARKET
  entry_allocation_percent: 100
  entry_one_shot: true

Long Take Profits

- take_profit_name: BG_TP
  take_profit_belongs_to_setup: BG_TREND_UP
  take_profit_gate_condition: BG_MARKET_ENTRY_ACTIVE
  take_profit_order_type: LIMIT
  take_profit_limit_price: ROUND_TO_MINTICK(POSITION_AVG_PRICE * 1.01)
  take_profit_allocation_percent: 100

Long Stop Losses

- stop_loss_name: BG_SL
  stop_loss_belongs_to_setup: BG_TREND_UP
  stop_loss_gate_condition: BG_MARKET_ENTRY_ACTIVE
  stop_loss_order_type: STOP
  stop_loss_stop_price: ROUND_TO_MINTICK(POSITION_AVG_PRICE * 0.99)
  stop_loss_allocation_percent: 100

What to verify

  • the setup confirms only after a confirmed bar closes above `PRICE_HLC3`

  • the entry waits for the cross instead of firing on every bar

  • the take profit sits 1% above average entry price

  • the stop sits 1% below average entry price

Intermediate Example

What this one teaches

  • multiline expressions

  • setup cooldown

  • limit-entry workflow

  • authored entry expiry

  • `from_entry_id` targeting

  • lookback tools like `BARSSINCE`, `LOWEST`, and `BETWEEN`

Long Setups

- setup_name: INT_PULLBACK_STACK
  setup_gate_condition:
    BARSTATE_ISCONFIRMED &&
    TF_ISINTRADAY &&
    PRICE_CLOSE > PRICE_HLC3
  setup_active_when:
    RISING(PRICE_HLC3, 3) &&
    PRICE_CLOSE > PRICE_HLC3 &&
    BARSSINCE(CROSSOVER(PRICE_CLOSE, PRICE_HLC3)) <= 5
  setup_cancel_when:
    PRICE_CLOSE < LOWEST(PRICE_LOW, 5)
  setup_confirm_type: BAR_COUNT
  setup_confirm_count: 2
  setup_cooldown_bars: 3

Long Entries

- entry_name: INT_PULLBACK_LIMIT
  entry_belongs_to_setup: INT_PULLBACK_STACK
  entry_gate_condition:
    INT_PULLBACK_STACK_CONFIRMED &&
    BETWEEN(PCT_FROM(PRICE_HLC3, PRICE_CLOSE), -1.5, 0.25)
  entry_trigger_when:
    PRICE_CLOSE > PRICE_LOW[1] &&
    BARSSINCE(CROSSUNDER(PRICE_CLOSE, PRICE_HLC3)) <= 3
  entry_order_type: LIMIT
  entry_allocation_percent: 100
  entry_limit_price: ROUND_TO_MINTICK(AVG(PRICE_LOW, PRICE_HL2))
  entry_lock_prices: true
  entry_expire_after_bars: 4
  entry_id: INT_CORE

Long Take Profits

- take_profit_name: INT_CORE_TP
  take_profit_belongs_to_setup: INT_PULLBACK_STACK
  take_profit_gate_condition: INT_PULLBACK_LIMIT_ACTIVE
  take_profit_trigger_when: POSITION_ACTIVE
  take_profit_order_type: LIMIT
  take_profit_allocation_percent: 100
  take_profit_limit_price: ROUND_TO_MINTICK(POSITION_AVG_PRICE * 1.015)
  take_profit_from_entry_id: INT_CORE

Long Stop Losses

- stop_loss_name: INT_CORE_SL
  stop_loss_belongs_to_setup: INT_PULLBACK_STACK
  stop_loss_gate_condition: INT_PULLBACK_LIMIT_ACTIVE
  stop_loss_trigger_when: POSITION_ACTIVE
  stop_loss_order_type: STOP
  stop_loss_allocation_percent: 100
  stop_loss_stop_price: ROUND_TO_MINTICK(LOWEST(PRICE_LOW, 3))
  stop_loss_from_entry_id: INT_CORE

What to verify

  • the setup needs two confirmations, so it should feel slower and more selective than the beginner example

  • the entry should post as a working limit order rather than filling immediately

  • the entry should expire if it sits too long

  • both exits should stay scoped to `INT_CORE`

Advanced Example

What this one teaches

  • deeper multiline expressions

  • one setup with one entry but multiple exit legs

  • split take-profit coverage

  • split stop-loss coverage

  • nested ternaries in price expressions

  • more deliberate use of `SAFE_DIV`, `PCT_CHANGE`, `CLAMP`, and `ROUND_TO_MINTICK`

Long Setups

- setup_name: ADV_REGIME_STACK
  setup_gate_condition:
    BARSTATE_ISCONFIRMED &&
    TF_ISINTRADAY &&
    SESSION_ISMARKET
  setup_active_when:
    (
      RISING(PRICE_HLC3, 4) &&
      PCT_CHANGE(PRICE_CLOSE, PRICE_CLOSE[4]) > 0.25 &&
      BETWEEN(
        SAFE_DIV(RANGE(PRICE_HIGH, 10), PRICE_HLC3, 0),
        0.002,
        0.03
      )
    ) ||
    (
      CROSSOVER(PRICE_CLOSE, HIGHEST(PRICE_HIGH[1], 5)) &&
      PRICE_CLOSE > PRICE_HLC3
    )
  setup_cancel_when:
    PRICE_CLOSE < LOWEST(PRICE_LOW, 4)
  setup_confirm_type: BAR_COUNT
  setup_confirm_count: 2
  setup_cooldown_bars: 4

Long Entries

- entry_name: ADV_STOPLIMIT_ENTRY
  entry_belongs_to_setup: ADV_REGIME_STACK
  entry_gate_condition:
    ADV_REGIME_STACK_CONFIRMED &&
    BARSTATE_ISCONFIRMED &&
    !POSITION_ACTIVE
  entry_trigger_when:
    CROSSOVER(PRICE_CLOSE, PRICE_HLC3) ||
    (PRICE_CLOSE > PRICE_HIGH[1] && RISING(PRICE_HLC3, 2))
  entry_order_type: STOPLIMIT
  entry_allocation_percent: 100
  entry_lock_prices: false
  entry_stop_price:
    ROUND_TO_MINTICK(
      MAX(
        PRICE_HIGH,
        AVG(PRICE_HIGH, PRICE_CLOSE)
      )
    )
  entry_limit_price:
    ROUND_TO_MINTICK(
      PRICE_CLOSE > PRICE_HLC3
      ? AVG(PRICE_HLC3, PRICE_HIGH)
      : AVG(PRICE_HL2, PRICE_CLOSE)
    )
  entry_id: ADV_CORE
  entry_expire_after_bars: 3

Long Take Profits

- take_profit_name: ADV_TP_1
  take_profit_belongs_to_setup: ADV_REGIME_STACK
  take_profit_gate_condition: ADV_STOPLIMIT_ENTRY_ACTIVE
  take_profit_trigger_when: POSITION_ACTIVE
  take_profit_order_type: LIMIT
  take_profit_allocation_percent: 40
  take_profit_limit_price:
    ROUND_TO_MINTICK(
      POSITION_ACTIVE
      ? POSITION_AVG_PRICE * 1.01
      : PRICE_CLOSE * 1.01
    )
  take_profit_from_entry_id: ADV_CORE

- take_profit_name: ADV_TP_2
  take_profit_belongs_to_setup: ADV_REGIME_STACK
  take_profit_gate_condition: ADV_STOPLIMIT_ENTRY_ACTIVE
  take_profit_trigger_when: POSITION_ACTIVE
  take_profit_order_type: LIMIT
  take_profit_allocation_percent: 60
  take_profit_limit_price:
    ROUND_TO_MINTICK(
      POSITION_ACTIVE
      ? (
          PRICE_CLOSE > POSITION_AVG_PRICE
          ? POSITION_AVG_PRICE * 1.02
          : POSITION_AVG_PRICE * 1.015
        )
      : PRICE_CLOSE * 1.02
    )
  take_profit_from_entry_id: ADV_CORE

Long Stop Losses

- stop_loss_name: ADV_SL_1
  stop_loss_belongs_to_setup: ADV_REGIME_STACK
  stop_loss_gate_condition: ADV_STOPLIMIT_ENTRY_ACTIVE
  stop_loss_trigger_when: POSITION_ACTIVE
  stop_loss_order_type: STOP
  stop_loss_allocation_percent: 50
  stop_loss_stop_price:
    ROUND_TO_MINTICK(
      CLAMP(POSITION_AVG_PRICE * 0.99, POSITION_AVG_PRICE * 0.95, POSITION_AVG_PRICE)
    )
  stop_loss_from_entry_id: ADV_CORE

- stop_loss_name: ADV_SL_2
  stop_loss_belongs_to_setup: ADV_REGIME_STACK
  stop_loss_gate_condition: ADV_STOPLIMIT_ENTRY_ACTIVE
  stop_loss_trigger_when:
    POSITION_ACTIVE &&
    PRICE_CLOSE < POSITION_AVG_PRICE &&
    FALLING(PRICE_HLC3, 2)
  stop_loss_order_type: MARKET
  stop_loss_allocation_percent: 50
  stop_loss_from_entry_id: ADV_CORE

What to verify

  • the setup should feel noticeably more selective than the earlier two examples

  • the entry should behave like a real stop-limit path, not like a market order

  • the first take profit should be easier to reach than the second

  • the first stop is price-based, while the second acts like a condition-driven market bailout

  • take-profit coverage totals 100 and stop-loss coverage totals 100 for the `ADV_CORE` scope

Extreme Example

What this one teaches

  • dense multiline expressions

  • nested ternaries inside price formulas

  • multiple function families in one workflow

  • deeper state thinking

  • the outer edge of what this builder can reasonably express before readability becomes part of the challenge

This example is here to show possibility, not to tell you that more complexity is automatically better.

Long Setups

- setup_name: X_REGIME_MACHINE
  setup_gate_condition:
    BARSTATE_ISCONFIRMED &&
    TF_ISINTRADAY &&
    SESSION_ISMARKET &&
    !POSITION_ACTIVE
  setup_active_when:
    (
      RISING(PRICE_HLC3, 4) &&
      PCT_CHANGE(PRICE_CLOSE, PRICE_CLOSE[5]) > 0.35 &&
      BETWEEN(
        SAFE_DIV(RANGE(PRICE_HIGH, 12), PRICE_HLC3, 0),
        0.002,
        0.03
      )
    ) ||
    (
      CROSSOVER(PRICE_CLOSE, HIGHEST(PRICE_HIGH[1], 8)) &&
      BARSSINCE(CROSSUNDER(PRICE_CLOSE, PRICE_HLC3)) <= 6
    )
  setup_cancel_when:
    POSITION_ACTIVE ||
    PRICE_CLOSE < LOWEST(PRICE_LOW, 6) ||
    FALLING(PRICE_HLC3, 3)
  setup_reset_when:
    BARSSINCE(CROSSUNDER(PRICE_CLOSE, PRICE_HLC3)) > 8 &&
    PRICE_CLOSE > PRICE_HLC3
  setup_confirm_type: BAR_COUNT
  setup_confirm_count: 2
  setup_cancel_confirm_type: BAR_COUNT
  setup_cancel_confirm_count: 1
  setup_cooldown_bars: 5
  setup_max_entries_per_activation: 1

Long Entries

- entry_name: X_STOPLIMIT_ENGINE
  entry_belongs_to_setup: X_REGIME_MACHINE
  entry_gate_condition:
    X_REGIME_MACHINE_CONFIRMED &&
    BARSTATE_ISCONFIRMED &&
    PRICE_CLOSE > PRICE_HLC3 &&
    BARSSINCE(CROSSOVER(PRICE_CLOSE, PRICE_HLC3)) <= 4
  entry_trigger_when:
    CROSSOVER(PRICE_CLOSE, HIGHEST(PRICE_HIGH[1], 4)) ||
    (
      PRICE_CLOSE > PRICE_HIGH[1] &&
      RISING(PRICE_HLC3, 2)
    )
  entry_confirm_type: NUM_TICKS
  entry_confirm_count: 2
  entry_order_type: STOPLIMIT
  entry_allocation_percent: 100
  entry_lock_prices: true
  entry_stop_price:
    ROUND_TO_MINTICK(
      POSITION_ACTIVE
      ? POSITION_AVG_PRICE
      : MAX(
          PRICE_HIGH,
          PRICE_HLC3,
          AVG(PRICE_HIGH, PRICE_CLOSE)
        )
    )
  entry_limit_price:
    ROUND_TO_MINTICK(
      POSITION_ACTIVE
      ? POSITION_AVG_PRICE
      : (
          PRICE_CLOSE > PRICE_HLC3
          ? AVG(PRICE_HLC3, PRICE_HIGH)
          : AVG(PRICE_HL2, PRICE_CLOSE)
        )
    )
  entry_id: X_CORE
  entry_expire_after_bars: 3
  entry_cancel_when:
    PRICE_CLOSE < PRICE_HLC3 ||
    BARSSINCE(CROSSUNDER(PRICE_CLOSE, PRICE_HLC3)) <= 2
  entry_one_shot: true

Long Take Profits

- take_profit_name: X_TP_1
  take_profit_belongs_to_setup: X_REGIME_MACHINE
  take_profit_gate_condition: X_STOPLIMIT_ENGINE_ACTIVE
  take_profit_trigger_when: POSITION_ACTIVE
  take_profit_order_type: LIMIT
  take_profit_allocation_percent: 25
  take_profit_limit_price:
    ROUND_TO_MINTICK(
      POSITION_ACTIVE
      ? POSITION_AVG_PRICE * 1.01
      : PRICE_CLOSE * 1.01
    )
  take_profit_from_entry_id: X_CORE

- take_profit_name: X_TP_2
  take_profit_belongs_to_setup: X_REGIME_MACHINE
  take_profit_gate_condition: X_STOPLIMIT_ENGINE_ACTIVE
  take_profit_trigger_when:
    POSITION_ACTIVE &&
    PRICE_CLOSE > POSITION_AVG_PRICE
  take_profit_order_type: LIMIT
  take_profit_allocation_percent: 35
  take_profit_limit_price:
    ROUND_TO_MINTICK(
      POSITION_ACTIVE
      ? (
          PRICE_CLOSE > POSITION_AVG_PRICE
          ? POSITION_AVG_PRICE * 1.02
          : POSITION_AVG_PRICE * 1.015
        )
      : PRICE_CLOSE * 1.02
    )
  take_profit_from_entry_id: X_CORE

- take_profit_name: X_TP_3
  take_profit_belongs_to_setup: X_REGIME_MACHINE
  take_profit_gate_condition: X_STOPLIMIT_ENGINE_ACTIVE
  take_profit_trigger_when:
    POSITION_ACTIVE &&
    RISING(PRICE_HLC3, 2)
  take_profit_order_type: LIMIT
  take_profit_allocation_percent: 40
  take_profit_limit_price:
    ROUND_TO_MINTICK(
      POSITION_ACTIVE
      ? MAX(
          POSITION_AVG_PRICE * 1.03,
          AVG(PRICE_HIGH, POSITION_AVG_PRICE)
        )
      : PRICE_CLOSE * 1.03
    )
  take_profit_from_entry_id: X_CORE

Long Stop Losses

- stop_loss_name: X_SL_1
  stop_loss_belongs_to_setup: X_REGIME_MACHINE
  stop_loss_gate_condition: X_STOPLIMIT_ENGINE_ACTIVE
  stop_loss_trigger_when: POSITION_ACTIVE
  stop_loss_order_type: STOP
  stop_loss_allocation_percent: 50
  stop_loss_stop_price:
    ROUND_TO_MINTICK(
      MIN(
        POSITION_AVG_PRICE * 0.99,
        AVG(PRICE_LOW, POSITION_AVG_PRICE)
      )
    )
  stop_loss_from_entry_id: X_CORE

- stop_loss_name: X_SL_2
  stop_loss_belongs_to_setup: X_REGIME_MACHINE
  stop_loss_gate_condition: X_STOPLIMIT_ENGINE_ACTIVE
  stop_loss_trigger_when:
    POSITION_ACTIVE &&
    (
      PRICE_CLOSE < POSITION_AVG_PRICE ||
      FALLING(PRICE_HLC3, 3)
    )
  stop_loss_order_type: MARKET
  stop_loss_allocation_percent: 50
  stop_loss_from_entry_id: X_CORE

What to verify

  • the setup should read like a regime filter, not a simple one-line trigger

  • the entry should show how far a stop-limit path can be pushed while staying valid

  • the take-profit ladder should demonstrate how split coverage can carry very different price logic across three legs

  • the stop-loss side should show the difference between a price-defined stop and a condition-defined market exit

  • readability becomes part of the design problem at this level, which is exactly why this example belongs at the end of the ladder

How To Learn From The Harder Examples Without Getting Lost

When an advanced or extreme block feels heavy, shrink it on purpose:

  1. keep the setup

  2. keep one entry only

  3. keep one take profit only

  4. keep one stop only

  5. verify the reduced version

  6. add the second layer back after the first one makes sense

That is usually the fastest way to turn "this looks crazy" into "I can actually read what this is doing."

Good Pages To Pair With This One