Indicator · Pine Script v6 · On the chart

DCP Daily Contract Position

by dwightspitz

Shows a position-sizing table on the price chart for an options-style account where each contract covers 100 units.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code65
Settings5inputs
LicenceMIT
Last update8 weeks ago31 Aug 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

65 lines of Pine Script v6 from DCP.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

DCP.pine
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Dwight_Spitz

//@version=6
indicator("DCP - Daily Contract Position", overlay=true)

// ===== INPUT PARAMETERS =====
portfolio_value = input.float(100000, "Portfolio Value", minval=0, step=1000, group="Portfolio Settings")
target_premium = input.float(1.20, "Target Premium", minval=0, step=0.01, group="Portfolio Settings")
total_contracts_allowed = input.int(3, "Total Contracts Allowed", minval=1, group="Portfolio Settings")

// Active Trades
active_contracts = input.int(0, "Active Contracts", minval=0, group="Active Trades")
average_cost = input.float(0, "Average Cost", minval=0, step=0.01, group="Active Trades")

// ===== CALCULATIONS =====

// Risk per Trade calculation
// Formula: (portfolio_value * 0.01) / 0.2
risk_per_trade = (portfolio_value * 0.01) / 0.2

// Stop Loss Price calculation
// Formula: average_cost - (risk_per_trade / (active_contracts * 100))
// Each contract represents 100 shares/units
stop_loss_price = active_contracts > 0 ? average_cost - (risk_per_trade / (active_contracts * 100)) : na

// ===== DISPLAY TABLE =====

// Create table in top right corner
var table info_table = table.new(position.top_right, 2, 8, bgcolor=color.new(color.black, 10), border_width=1, border_color=color.gray)

// Only update table on the last bar
if barstate.islast
    // Header
    table.cell(info_table, 0, 0, "Metric", text_color=color.white, bgcolor=color.new(color.gray, 30), text_size=size.normal)
    table.cell(info_table, 1, 0, "Value", text_color=color.white, bgcolor=color.new(color.gray, 30), text_size=size.normal)

    // Portfolio Value
    table.cell(info_table, 0, 1, "Portfolio Value", text_color=color.white, text_size=size.normal)
    table.cell(info_table, 1, 1, "$" + str.tostring(portfolio_value, "#,###"), text_color=color.aqua, text_size=size.normal)

    // Risk per Trade
    table.cell(info_table, 0, 2, "Risk per Trade", text_color=color.white, text_size=size.normal)
    table.cell(info_table, 1, 2, "$" + str.tostring(risk_per_trade, "#,###.##"), text_color=color.yellow, text_size=size.normal)

    // Target Premium
    table.cell(info_table, 0, 3, "Target Premium", text_color=color.white, text_size=size.normal)
    table.cell(info_table, 1, 3, "$" + str.tostring(target_premium, "#.##"), text_color=color.lime, text_size=size.normal)

    // Total Contracts Allowed
    table.cell(info_table, 0, 4, "Contracts Allowed", text_color=color.white, text_size=size.normal)
    table.cell(info_table, 1, 4, str.tostring(total_contracts_allowed, "#"), text_color=color.orange, text_size=size.normal)

    // Active Contracts
    table.cell(info_table, 0, 5, "Active Contracts", text_color=color.white, text_size=size.normal)
    table.cell(info_table, 1, 5, str.tostring(active_contracts, "#"), text_color=color.purple, text_size=size.normal)

    // Average Cost
    table.cell(info_table, 0, 6, "Average Cost", text_color=color.white, text_size=size.normal)
    table.cell(info_table, 1, 6, "$" + str.tostring(average_cost, "#.##"), text_color=color.white, text_size=size.normal)

    // Stop Loss Price
    table.cell(info_table, 0, 7, "Stop Loss Price", text_color=color.white, text_size=size.normal)
    stop_loss_display = na(stop_loss_price) ? "N/A" : "$" + str.tostring(stop_loss_price, "#.##")
    table.cell(info_table, 1, 7, stop_loss_display, text_color=color.red, text_size=size.normal)

Overview

Inputs are portfolio value, target premium, contracts allowed, active contracts and average cost. It reports a risk amount per trade, taken as one percent of the portfolio divided by 0.2, and a stop loss price worked back from the average cost. It draws no signals and is a manual calculator.

Details

Published by

dwightspitz on GitHub

Draws

On the price chart

Markets

Stocks

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Portfolio Valuefloat100000portfolio_value
Target Premiumfloat1.20target_premium
Total Contracts Allowedint3total_contracts_allowed
Active Contractsint0active_contracts
Average Costfloat0average_cost
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

Symbol Info Helper

by everget
947 stars

Symbol Info Helper is an informational utility script that displays metadata about the currently selected instrument directly on the main price chart. It gathers built-in symbol properties including ticker identifier, description, instrument type, point value,

Indicator v4 Screeners & dashboards
Updated 11 days ago · GPL-3.0 GitHub repository of Symbol Info Helper
575 stars

The indicator plots ICT displacement candles on the price chart and can switch to retracement scanning. Displacement requires a move larger than a set share of the 14-bar average high-low range, lasting at least a chosen number of bars, with optional close, pr

Indicator v6 SMC / ICT / price actionCandlestick patterns
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Displacement Candles Indicator
330 stars

This indicator monitors multiple cryptocurrency symbols for trading signals. It calculates and plots entry prices, take profit, and stop loss levels for each symbol including BTCUSDT, ETHUSDT, BNBUSDT and others. Price crossovers trigger buy, sell or close ale

Indicator v5 Support & resistanceScreeners & dashboards
Updated 2 months ago · None stated GitHub repository of Multi Alert Long/Short [Alorse]

Pricing Table

by namuan
318 stars

This indicator calculates theoretical options contract values and in-the-money probabilities using historical realized volatility across multiple standard deviations. It displays these metrics in a table overlay directly on the price chart. Users can adjust th

Indicator v4 Volatility & bandsScreeners & dashboards
Updated 2 months ago · MIT GitHub repository of Pricing Table

3938 Tracker

by Allen1212
303 stars

3938 Tracker visualizes historical buying and selling activity from ARK Invest funds directly on the main price chart. It plots labels at specific timestamps corresponding to trade dates, indicating buy or sell actions along with the count of participating ETF

Indicator v4 Screeners & dashboards
Updated 2 years ago · None stated GitHub repository of 3938 Tracker

More Screeners & dashboards scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers