Built-in Functions
Structures
Ticker
Depth
OrderBook
Trade
Record
Market
Order
Condition
Account
Asset
Position
Funding
Other Structures
Built-in Variables and Constants
Conventions
Exchanges
badge
Shows small labels with a dot inline, so they can follow a line of text.
Examples
Shows the run mode and state after a line of text.
javascript
function main() {
LogStatus("MA strategy", {type: "badge", items: [
{text: IsVirtual() ? "Backtest" : "Live", color: "muted"},
{text: "Running", color: "up"}
]})
}
python
def main():
LogStatus("MA strategy", {"type": "badge", "items": [
{"text": "Backtest" if IsVirtual() else "Live", "color": "muted"},
{"text": "Running", "color": "up"}
]})
rust
fn main() {
let mode = if IsVirtual() { "Backtest" } else { "Live" };
let item = |text: &str, color: &str| format!(r#"{{"text": "{}", "color": "{}"}}"#, text, color);
let badge = format!(
r#"{{"type": "badge", "items": [{}, {}]}}"#,
item(mode, "muted"), item("Running", "up")
);
// Text and a component on one line: the component goes last, as one-line JSON
LogStatus!("MA strategy", badge);
}Attributes
| Name | Type | Description |
type | string | Required. Always |
items | object array | Required. At least one badge with |
items[].text | string | Required. Badge text. |
items[].color | string | Color, default |
id | string | Stable identifier. Set it when the number or order of components changes, so refreshes do not rebuild the component. |
span | number | Number of columns it spans in the enclosing |
See Also