---
title: "How to Create On Off Columns in Pine Script - CloudBlast"
description: "How to Create On Off Columns in Pine Script"
url: "https://cloudblast.io/zh/article/How-to-Create-On-Off-Columns-in-Pine-Script"
language: "zh-CN"
---

博客

# How to Create On Off Columns in Pine Script

注册即享 5€ 免费余额

注册 CloudBlast，即可获得 5€ 云端积分用于部署您的 VPS

[领取 5€ 免费额度](https://console.cloudblast.io/auth/login?ref=2)

-   [返回](https://cloudblast.io/zh)
-   [所有文章](https://cloudblast.io/zh/blog)

2024-09-25

### How to Create On Off Columns in Pine Script

tutorials

Pine Script, the scripting language used by TradingView, allows traders to create custom indicators and strategies. One useful feature is the ability to create on/off columns, which can help visualize binary states or conditions directly on your chart. This article will guide you through the process of implementing on/off columns in Pine Script.

**Understanding On/Off Columns**

On/off columns are essentially visual indicators that toggle between two states, often represented by different colors or symbols. These can be used to indicate conditions such as buy/sell signals, active/inactive states, or any binary condition relevant to your trading strategy.

**Implementing On/Off Columns in Pine Script**

To create on/off columns in Pine Script, you can use the `plotshape()` function, which allows you to plot shapes on the chart based on certain conditions. Here’s a basic example:

> indicator("On/Off Columns Example", overlay=true) // Define a condition for the on/off state onCondition = close > open // Plot a shape when the condition is true (on state) plotshape(series=onCondition, location=location.abovebar, color=color.green, style=shape.triangledown, size=size.small) // Plot a shape when the condition is false (off state) plotshape(series=not onCondition, location=location.belowbar, color=color.red, style=shape.triangleup, size=size.small)

In this example, the script checks if the closing price is greater than the opening price. If true, it plots a green triangle above the bar, indicating the "on" state. If false, it plots a red triangle below the bar, indicating the "off" state.

**Customizing Your Columns**

You can customize the appearance of your on/off columns by adjusting the parameters of the `plotshape()` function. Options include changing the shape style, size, and color to better fit your chart's design and your personal preferences.

**Conclusion**

Creating on/off columns in Pine Script is a straightforward process that enhances the visual representation of binary conditions on your TradingView charts. By using the `plotshape()` function, you can effectively communicate important signals and states, aiding in better decision-making for your trading strategies.

分享

## 继续阅读

[2026-07-25 How to Install and Set Up Mailcow on Ubuntu and Debian VPS tutorials](https://cloudblast.io/article/how-to-install-and-setup-mailcow-on-ubuntu-and-debian-vps)

[2026-07-25 How to Install Chatwoot on the Latest Ubuntu and Debian Server tutorials](https://cloudblast.io/article/how-to-install-chatwoot-on-ubuntu-and-debian-server)

[2026-07-25 How to Install Mattermost on the Latest Ubuntu and Debian Server tutorials](https://cloudblast.io/article/how-to-install-mattermost-on-ubuntu-and-debian-server)

[2026-07-25 How to Install RustDesk on the Latest Ubuntu and Debian Server tutorials](https://cloudblast.io/article/how-to-install-rustdesk-on-ubuntu-and-debian-server)
