本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
// ============================================================================
// Contract Notional v1.0
// Table on the chart: notional value of 1 futures contract (last close x USD
// per 1.0 price move) and the tick value. Cents-quoted (USX) contracts use the
// fixed list below; everything else uses syminfo.pointvalue.
// ============================================================================
indicator("Contract Notional", overlay = true)
posInput = input.string("Top Right", "Position", options = ["Top Right", "Top Center", "Bottom Right"])
showTick = input.bool(true, "Show tick value")
textSize = input.string("normal", "Text size", options = ["tiny", "small", "normal", "large"])
pvOverride = input.float(0.0, "USD per 1.0 price move (0 = auto)", minval = 0)
pos = switch posInput
"Top Center" => position.top_center
"Bottom Right" => position.bottom_right
=> position.top_right
// Contracts quoted in cents (USX) or with a fixed size: USD value of a 1.0 move in the quoted price.
// Cents-quoted: contract size / 100. Falls back to syminfo.pointvalue for everything else.
fixedPV(string root) =>
switch root
"ZC" => 50.0 // Corn, 5,000 bu, ¢/bu
"ZW" => 50.0 // Chicago wheat, 5,000 bu, ¢/bu
"KE" => 50.0 // KC HRW wheat, 5,000 bu, ¢/bu
"ZS" => 50.0 // Soybeans, 5,000 bu, ¢/bu
"ZO" => 50.0 // Oats, 5,000 bu, ¢/bu
"XC" => 10.0 // Mini corn, 1,000 bu
"XW" => 10.0 // Mini wheat, 1,000 bu
"XK" => 10.0 // Mini soybeans, 1,000 bu
"ZL" => 600.0 // Soybean oil, 60,000 lb, ¢/lb
"ZM" => 100.0 // Soybean meal, 100 short tons, $/ton
"LE" => 400.0 // Live cattle, 40,000 lb, ¢/lb
"GF" => 500.0 // Feeder cattle, 50,000 lb, ¢/lb
"HE" => 400.0 // Lean hogs, 40,000 lb, ¢/lb
"KC" => 375.0 // Coffee, 37,500 lb, ¢/lb
"CT" => 500.0 // Cotton, 50,000 lb, ¢/lb
"SB" => 1120.0 // Sugar #11, 112,000 lb, ¢/lb
"OJ" => 150.0 // Orange juice, 15,000 lb, ¢/lb
=> na
knownPV = fixedPV(syminfo.root)
usdPV = pvOverride > 0 ? pvOverride : not na(knownPV) ? knownPV : syminfo.pointvalue
ccy = pvOverride > 0 or not na(knownPV) ? "USD" : syminfo.currency
var table t = table.new(pos, 2, 2, bgcolor = color.new(color.black, 20), border_width = 1)
if barstate.islast
notional = close * usdPV
tickVal = syminfo.mintick * usdPV
table.cell(t, 0, 0, "1 contract", text_color = color.silver, text_size = textSize)
table.cell(t, 1, 0, str.tostring(notional, "#,##0") + " " + ccy, text_color = color.white, text_size = textSize)
if showTick
table.cell(t, 0, 1, "Tick value", text_color = color.silver, text_size = textSize)
table.cell(t, 1, 1, str.tostring(tickVal, "#,##0.00") + " " + ccy, text_color = color.white, text_size = textSize)