本文介绍了无法取消选中输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在研究一个指标,该指标显示多个BTC市场的合计交易量。
该指示器在很大程度上起作用,但出于某种原因,取消选中输入不起作用。即使一切都取消勾选,该指标仍会显示所有市场的总成交量。
这可能是一个简单的修复方法,但我没有编程背景。我通过查看其他指标和一些试错得出了这一点。
如果有人能帮助我,我将不胜感激。
我还在想,如果能够通过用多种颜色绘制直方图来查看每个市场的成交量,那将是非常有趣的,但我认为我无法做到这一点,甚至不可能做到这一点。
这是完整的代码:
//@version=4
study(title="Aggregated Bitcoin Volume", overlay=false)
sym1_title = "Binance (USDT)"
sym1_ticker = "BINANCE:BTCUSDT"
sym2_title = "Binance (BUSD)"
sym2_ticker = "BINANCE:BTCBUSD"
sym3_title = "Bitfinex (USD)"
sym3_ticker = "BITFINEX:BTCUSD"
sym4_title = "Coinbase (USD)"
sym4_ticker = "COINBASE:BTCUSD"
sym5_title = "Coinbase (USDC)"
sym5_ticker = "COINBASE:BTCUSDC"
sym6_title = "Bitstamp (USD)"
sym6_ticker = "BITSTAMP:BTCUSD"
sym7_title = "Kraken (USD)"
sym7_ticker = "KRAKEN:XBTUSD"
sym8_title = "Gemini (USD)"
sym8_ticker = "GEMINI:BTCUSD"
sym9_title = "OkEx (USDT)"
sym9_ticker = "OKEX:BTCUSDT"
sym10_title = "OkEx (USDK)"
sym10_ticker = "OKEX:BTCUSDK"
sym11_title = "Huobi (USDT)"
sym11_ticker = "HUOBI:BTCUSDT"
sym1 = input(title=sym1_title, type=input.bool, defval=true)
sym2 = input(title=sym2_title, type=input.bool, defval=true)
sym3 = input(title=sym3_title, type=input.bool, defval=true)
sym4 = input(title=sym4_title, type=input.bool, defval=true)
sym5 = input(title=sym5_title, type=input.bool, defval=true)
sym6 = input(title=sym6_title, type=input.bool, defval=true)
sym7 = input(title=sym7_title, type=input.bool, defval=true)
sym8 = input(title=sym8_title, type=input.bool, defval=true)
sym9 = input(title=sym9_title, type=input.bool, defval=true)
sym10 = input(title=sym10_title, type=input.bool, defval=true)
sym11 = input(title=sym11_title, type=input.bool, defval=true)
src = input(close)
price_1 = security(sym1_ticker, timeframe.period, src)
price_2 = security(sym2_ticker, timeframe.period, src)
price_3 = security(sym3_ticker, timeframe.period, src)
price_4 = security(sym4_ticker, timeframe.period, src)
price_5 = security(sym5_ticker, timeframe.period, src)
price_6 = security(sym6_ticker, timeframe.period, src)
price_7 = security(sym7_ticker, timeframe.period, src)
price_8 = security(sym8_ticker, timeframe.period, src)
price_9 = security(sym9_ticker, timeframe.period, src)
price_10 = security(sym10_ticker, timeframe.period, src)
price_11 = security(sym11_ticker, timeframe.period, src)
security_1 = security(sym1_ticker, timeframe.period, volume)
security_2 = security(sym2_ticker, timeframe.period, volume)
security_3 = security(sym3_ticker, timeframe.period, volume)
security_4 = security(sym4_ticker, timeframe.period, volume)
security_5 = security(sym5_ticker, timeframe.period, volume)
security_6 = security(sym6_ticker, timeframe.period, volume)
security_7 = security(sym7_ticker, timeframe.period, volume)
security_8 = security(sym8_ticker, timeframe.period, volume)
security_9 = security(sym9_ticker, timeframe.period, volume)
security_10 = security(sym10_ticker, timeframe.period, volume)
security_11 = security(sym11_ticker, timeframe.period, volume)
plot(series=(security_1+security_2+security_3+security_4+security_5+security_6+security_7+security_8+security_9+security_10+security_11), style=plot.style_histogram, color = #787b86, linewidth=1)
推荐答案
我猜您正在寻找类似以下内容的内容:
//@version=4
study(title="Aggregated Bitcoin Volume", overlay=false)
sym1 = input(true, "", input.bool, inline="1")
sym2 = input(true, "", input.bool, inline="2")
sym3 = input(true, "", input.bool, inline="3")
sym1_ticker = input("BINANCE:BTCUSDT", "", input.symbol, inline="1")
sym2_ticker = input("BINANCE:BTCBUSD", "", input.symbol, inline="2")
sym3_ticker = input("BITFINEX:BTCUSD", "", input.symbol, inline="3")
f_volume(_ticker) => security(_ticker, timeframe.period, volume)
volume_1 = sym1 ? f_volume(sym1_ticker) : 0
volume_2 = sym2 ? f_volume(sym2_ticker) : 0
volume_3 = sym3 ? f_volume(sym3_ticker) : 0
volume_agg = volume_1 + volume_2 + volume_3
plot(volume_agg, style=plot.style_columns, color = #787b86)
在Pine中无法以多种堆叠颜色绘制直方图。
编辑%1
似乎毕竟有一种方法可以用多种堆叠的颜色绘制直方图。
//@version=4
study(title="Aggregated Volume", precision=0, overlay=false)
// Plot style selections
var string PS1 = "Columns"
var string PS2 = "Histogram"
// Inputs
i_sym1 = input(true, "", input.bool, inline="1")
i_sym2 = input(true, "", input.bool, inline="2")
i_sym3 = input(true, "", input.bool, inline="3")
i_sym4 = input(true, "", input.bool, inline="4")
i_sym5 = input(true, "", input.bool, inline="5")
i_sym6 = input(true, "", input.bool, inline="6")
i_sym7 = input(true, "", input.bool, inline="7")
i_sym8 = input(true, "", input.bool, inline="8")
i_sym9 = input(true, "", input.bool, inline="9")
i_sym10 = input(true, "", input.bool, inline="10")
i_sym1_color = input(color.red, "", input.color, inline="1")
i_sym2_color = input(color.orange, "", input.color, inline="2")
i_sym3_color = input(color.yellow, "", input.color, inline="3")
i_sym4_color = input(color.green, "", input.color, inline="4")
i_sym5_color = input(color.blue, "", input.color, inline="5")
i_sym6_color = input(color.purple, "", input.color, inline="6")
i_sym7_color = input(color.teal, "", input.color, inline="7")
i_sym8_color = input(color.gray, "", input.color, inline="8")
i_sym9_color = input(color.lime, "", input.color, inline="9")
i_sym10_color = input(color.fuchsia, "", input.color, inline="10")
i_sym1_ticker = input("BINANCE:BTCUSDT", "", input.symbol, inline="1")
i_sym2_ticker = input("BINANCE:BTCBUSD", "", input.symbol, inline="2")
i_sym3_ticker = input("BITFINEX:BTCUSD", "", input.symbol, inline="3")
i_sym4_ticker = input("COINBASE:BTCUSD", "", input.symbol, inline="4")
i_sym5_ticker = input("BINGBON:BTCUSDT", "", input.symbol, inline="5")
i_sym6_ticker = input("BITSTAMP:BTCUSD", "", input.symbol, inline="6")
i_sym7_ticker = input("KRAKEN:XBTUSD", "", input.symbol, inline="7")
i_sym8_ticker = input("GEMINI:BTCUSD", "", input.symbol, inline="8")
i_sym9_ticker = input("OKEX:BTCUSDT", "", input.symbol, inline="9")
i_sym10_ticker = input("HUOBI:BTCUSDT", "", input.symbol, inline="10")
i_plot_style = input(PS1, "Plot style", input.string, options=[PS1,PS2])
i_single_color = input(false, "Use single color", input.bool, inline="0")
i_default_color = input(color.gray, "", input.color, inline="0")
// Variables
var int plot_style = i_plot_style == PS1 ? plot.style_columns : plot.style_histogram
var color sym1_color = i_single_color ? i_default_color : i_sym1_color
var color sym2_color = i_single_color ? i_default_color : i_sym2_color
var color sym3_color = i_single_color ? i_default_color : i_sym3_color
var color sym4_color = i_single_color ? i_default_color : i_sym4_color
var color sym5_color = i_single_color ? i_default_color : i_sym5_color
var color sym6_color = i_single_color ? i_default_color : i_sym6_color
var color sym7_color = i_single_color ? i_default_color : i_sym7_color
var color sym8_color = i_single_color ? i_default_color : i_sym8_color
var color sym9_color = i_single_color ? i_default_color : i_sym9_color
var color sym10_color = i_single_color ? i_default_color : i_sym10_color
// Functions
f_volume(_ticker) => security(_ticker, timeframe.period, volume)
// Calculations
v1 = i_sym1 ? f_volume(i_sym1_ticker) : 0
v2 = v1 + (i_sym2 ? f_volume(i_sym2_ticker) : 0)
v3 = v2 + (i_sym3 ? f_volume(i_sym3_ticker) : 0)
v4 = v3 + (i_sym4 ? f_volume(i_sym4_ticker) : 0)
v5 = v4 + (i_sym5 ? f_volume(i_sym5_ticker) : 0)
v6 = v5 + (i_sym6 ? f_volume(i_sym6_ticker) : 0)
v7 = v6 + (i_sym7 ? f_volume(i_sym7_ticker) : 0)
v8 = v7 + (i_sym8 ? f_volume(i_sym8_ticker) : 0)
v9 = v8 + (i_sym9 ? f_volume(i_sym9_ticker) : 0)
v10 = v9 + (i_sym10 ? f_volume(i_sym10_ticker) : 0)
if i_single_color
v1 := na, v2 := na, v3 := na, v4 := na, v5 := na, v6 := na, v7 := na, v8 := na, v9 := na
// Plots
plot(v10, style=plot_style, color=sym10_color, linewidth=1)
plot(v9 , style=plot_style, color=sym9_color, linewidth=1)
plot(v8 , style=plot_style, color=sym8_color, linewidth=1)
plot(v7 , style=plot_style, color=sym7_color, linewidth=1)
plot(v6 , style=plot_style, color=sym6_color, linewidth=1)
plot(v5 , style=plot_style, color=sym5_color, linewidth=1)
plot(v4 , style=plot_style, color=sym4_color, linewidth=1)
plot(v3 , style=plot_style, color=sym3_color, linewidth=1)
plot(v2 , style=plot_style, color=sym2_color, linewidth=1)
plot(v1 , style=plot_style, color=sym1_color, linewidth=1)
哪个选项会产生
我还添加了一个选择绘图样式的选项和一个用一种颜色显示所有内容的选项。
这篇关于无法取消选中输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!