我只是想让我的桌子变得更好,但我做不到

问题描述 投票:0回答:1

我创建了一个动态表,其中包括 OHLC 和 SMA(50) 和 SMA(200) ,SMA 也是动态的。

但是当涉及到我的表格单元格的着色时,表格已经翻转,我无法做到这一点。我只想要“如果我的 symbol.open*>symbol.open[1] color.green 和 else color.red”

*显然需要解释。当我这样使用时,我收到错误。

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © omersabriklc

//@version=5
indicator("Tablo - 16-10-2023",overlay = true)
// input_for_rows=input.int(7,title="Rows Value",group="INPUT FOR ROWS")

symbol1=input.symbol("",title="Symbol 1",group="SYMBOLS")
symbol2=input.symbol("",title="Symbol 2",group="SYMBOLS")
symbol3=input.symbol("",title="Symbol 3",group = "SYMBOLS")
symbol4=input.symbol("",title="Symbol 4",group="SYMBOLS")
symbol5=input.symbol("",title="Symbol 5",group = "SYMBOLS")
symbol6=input.symbol("",title="Symbol 6",group="SYMBOLS")

src=input.source(close,title="Source",group="SOURCE")
value1=input.int(50,title="Value 1",group="VALUES")
value2=input.int(200,title="Value 2",group="VALUES")

input_timeframe=input.timeframe("15",title="Timeframe",group="TIMEFRAME")

sma_short_term=ta.sma(src,value1)
sma_long_term=ta.sma(src,value2)


smayaziDegisimi(variablee)=>
    yazi="Symbol"
    yazi := "SMA" + "(" + str.tostring(variablee,format.volume) + ")" 
    yazi

sembolyazidegisim(symbolss)=>
    secimsembol=input.symbol("")
    if symbolss==symbol1
        secimsembol:=symbol1
    if symbolss==symbol2
        secimsembol:=symbol2
    if symbolss==symbol3
        secimsembol:=symbol3
    if symbolss==symbol4
        secimsembol:=symbol4
    if symbolss==symbol5
        secimsembol:=symbol5
    if symbolss==symbol6
        secimsembol:=symbol6
    secimsembol

getrequestSecurity(symboll,timeframee,expr)=>
    a=request.security("","","")
    a:=str.tostring(request.security(symboll,timeframee,expr),format.mintick)
    a



var table1=table.new(position = position.top_right,columns=7 , rows=7, bgcolor=color.silver, border_width=3 , frame_color=color.silver , frame_width=3 , border_color= color.black)

table.cell(table1,column = 0,row=0 , text="follow omersabriklc",text_color = color.black)
table.cell(table1,column=1 ,row=0 , text="OPEN",text_color = color.black,bgcolor = color.silver)
table.cell(table1,column=2 ,row=0 , text="HIGH",text_color = color.black,bgcolor = color.silver)
table.cell(table1,column=3 ,row=0 , text="LOW",text_color = color.black,bgcolor = color.silver)
table.cell(table1,column=4 ,row=0 , text="CLOSE",text_color = color.black,bgcolor = color.silver)

table.cell(table1,column=5 ,row=0 , text=smayaziDegisimi(value1),text_color = color.black,bgcolor = color.silver)
table.cell(table1,column=6 ,row=0 , text=smayaziDegisimi(value2),text_color = color.black,bgcolor = color.silver)

table.cell(table1,column = 0 , row=1 , text=sembolyazidegisim(symbol1),text_color = color.black,bgcolor = color.silver)
table.cell(table1,column = 0 , row=2 , text=sembolyazidegisim(symbol2),text_color = color.black,bgcolor = color.silver)
table.cell(table1,column = 0 , row=3 , text=sembolyazidegisim(symbol3),text_color = color.black,bgcolor = color.silver)
table.cell(table1,column = 0 , row=4 , text=sembolyazidegisim(symbol4),text_color = color.black,bgcolor = color.silver)
table.cell(table1,column = 0 , row=5 , text=sembolyazidegisim(symbol5),text_color = color.black,bgcolor = color.silver)
table.cell(table1,column = 0 , row=6 , text=sembolyazidegisim(symbol6),text_color = color.black,bgcolor = color.silver)

table.cell(table1,column = 1 , row=1 , text=getrequestSecurity((sembolyazidegisim(symbol1)),input_timeframe,open) ,text_color =color.black,bgcolor = open>open[1] ? color.green : color.red)
table.cell(table1,column = 2 , row=1 , text=getrequestSecurity((sembolyazidegisim(symbol1)),input_timeframe,high),text_color = color.black,bgcolor = high>high[1] ? color.green : color.red)
table.cell(table1,column = 3 , row=1 , text=getrequestSecurity((sembolyazidegisim(symbol1)),input_timeframe,low),text_color = color.black,bgcolor =low>low[1] ? color.green : color.red)
table.cell(table1,column = 4 , row=1 , text=getrequestSecurity((sembolyazidegisim(symbol1)),input_timeframe,close),text_color = color.black,bgcolor = close>close[1] ? color.green : color.red)
table.cell(table1,column = 5 , row=1 , text=getrequestSecurity((sembolyazidegisim(symbol1)),input_timeframe,sma_short_term),text_color = color.black,bgcolor = color.silver)
table.cell(table1,column = 6 , row=1 , text=getrequestSecurity((sembolyazidegisim(symbol1)),input_timeframe,sma_long_term),text_color = color.black,bgcolor = color.silver)

table.cell(table1,column = 1 , row=2 , text=getrequestSecurity((sembolyazidegisim(symbol2)),input_timeframe,open),text_color = color.black,bgcolor =open>open[1] ? color.green : color.red)
table.cell(table1,column = 2 , row=2 , text=getrequestSecurity((sembolyazidegisim(symbol2)),input_timeframe,high),text_color = color.black,bgcolor = high>high[1] ? color.green : color.red)
table.cell(table1,column = 3 , row=2 , text=getrequestSecurity((sembolyazidegisim(symbol2)),input_timeframe,low),text_color = color.black,bgcolor = low>low[1] ? color.green : color.red)
table.cell(table1,column = 4 , row=2 , text=getrequestSecurity((sembolyazidegisim(symbol2)),input_timeframe,close),text_color = color.black,bgcolor = close>close[1] ? color.green : color.red)
table.cell(table1,column = 5 , row=2 , text=getrequestSecurity((sembolyazidegisim(symbol2)),input_timeframe,sma_short_term),text_color = color.black,bgcolor = color.silver)
table.cell(table1,column = 6 , row=2 , text=getrequestSecurity((sembolyazidegisim(symbol2)),input_timeframe,sma_long_term),text_color = color.black,bgcolor = color.silver)

table.cell(table1,column = 1 , row=3 , text=getrequestSecurity((sembolyazidegisim(symbol3)),input_timeframe,open),text_color = color.black,bgcolor =open>open[1] ? color.green : color.red)
table.cell(table1,column = 2 , row=3 , text=getrequestSecurity((sembolyazidegisim(symbol3)),input_timeframe,high),text_color =color.black,bgcolor =high>high[1] ? color.green : color.red)
table.cell(table1,column = 3 , row=3 , text=getrequestSecurity((sembolyazidegisim(symbol3)),input_timeframe,low),text_color =color.black,bgcolor =low>low[1] ? color.green : color.red)
table.cell(table1,column = 4 , row=3 , text=getrequestSecurity((sembolyazidegisim(symbol3)),input_timeframe,close),text_color =color.black,bgcolor =close>close[1] ? color.green : color.red)
table.cell(table1,column = 5 , row=3 , text=getrequestSecurity((sembolyazidegisim(symbol3)),input_timeframe,sma_short_term),text_color = color.black,bgcolor = color.silver)
table.cell(table1,column = 6 , row=3 , text=getrequestSecurity((sembolyazidegisim(symbol3)),input_timeframe,sma_long_term),text_color = color.black,bgcolor = color.silver)

table.cell(table1,column = 1 , row=4 , text=getrequestSecurity((sembolyazidegisim(symbol4)),input_timeframe,open),text_color =color.black,bgcolor = open>open[1] ? color.green : color.red)
table.cell(table1,column = 2 , row=4 , text=getrequestSecurity((sembolyazidegisim(symbol4)),input_timeframe,high),text_color =color.black,bgcolor = high>high[1] ? color.green : color.red)
table.cell(table1,column = 3 , row=4 , text=getrequestSecurity((sembolyazidegisim(symbol4)),input_timeframe,low),text_color =color.black,bgcolor = low>low[1] ? color.green : color.red)
table.cell(table1,column = 4 , row=4 , text=getrequestSecurity((sembolyazidegisim(symbol4)),input_timeframe,close),text_color =color.black,bgcolor =close>close[1] ? color.green : color.red)
table.cell(table1,column = 5 , row=4 , text=getrequestSecurity((sembolyazidegisim(symbol4)),input_timeframe,sma_short_term),text_color = color.black,bgcolor = color.silver)
table.cell(table1,column = 6 , row=4 , text=getrequestSecurity((sembolyazidegisim(symbol4)),input_timeframe,sma_long_term),text_color = color.black,bgcolor = color.silver)

table.cell(table1,column = 1 , row=5 , text=getrequestSecurity((sembolyazidegisim(symbol5)),input_timeframe,open),text_color =color.black,bgcolor = open>open[1] ? color.green : color.red)
table.cell(table1,column = 2 , row=5 , text=getrequestSecurity((sembolyazidegisim(symbol5)),input_timeframe,high),text_color =color.black,bgcolor = high>high[1] ? color.green : color.red)
table.cell(table1,column = 3 , row=5 , text=getrequestSecurity((sembolyazidegisim(symbol5)),input_timeframe,low),text_color = color.black,bgcolor =low>low[1] ? color.green : color.red)
table.cell(table1,column = 4 , row=5 , text=getrequestSecurity((sembolyazidegisim(symbol5)),input_timeframe,close),text_color =color.black,bgcolor =close>close[1] ? color.green : color.red)
table.cell(table1,column = 5 , row=5 , text=getrequestSecurity((sembolyazidegisim(symbol5)),input_timeframe,sma_short_term),text_color = color.black,bgcolor = color.silver)
table.cell(table1,column = 6 , row=5 , text=getrequestSecurity((sembolyazidegisim(symbol5)),input_timeframe,sma_long_term),text_color = color.black,bgcolor = color.silver)

table.cell(table1,column = 1 , row=6 , text=getrequestSecurity((sembolyazidegisim(symbol6)),input_timeframe,open),text_color =color.black,bgcolor =open>open[1] ? color.green : color.red)
table.cell(table1,column = 2 , row=6 , text=getrequestSecurity((sembolyazidegisim(symbol6)),input_timeframe,high),text_color =color.black,bgcolor = high>high[1] ? color.green : color.red)
table.cell(table1,column = 3 , row=6 , text=getrequestSecurity((sembolyazidegisim(symbol6)),input_timeframe,low),text_color = color.black,bgcolor =low>low[1] ? color.green : color.red)
table.cell(table1,column = 4 , row=6 , text=getrequestSecurity((sembolyazidegisim(symbol6)),input_timeframe,close),text_color =color.black,bgcolor =close>close[1] ? color.green : color.red)
table.cell(table1,column = 5 , row=6 , text=getrequestSecurity((sembolyazidegisim(symbol6)),input_timeframe,sma_short_term),text_color = color.black,bgcolor = color.silver)
table.cell(table1,column = 6 , row=6 , text=getrequestSecurity((sembolyazidegisim(symbol6)),input_timeframe,sma_long_term),text_color = color.black,bgcolor = color.silver)


// bgcolor(open>open[1] ? color.green:color.red)
// grafiktenbagimsizyap()=>
    // chart.bg_color
// foropen()=>
    
//     arkarenkdinamik=color.silver
//     arkarenkdinamik:= if open>open[1]
//         dinamik=color.green
//     else if open[1] > open
//         dinamik=color.red
//     else
//         dinamik=arkarenkdinamik
//     arkarenkdinamik


// forclose()=>
//     arkarenkdinamik2=color.silver
//     arkarenkdinamik2:= if close>close[1]
//         dinamik2=color.green
//     else
//         dinamik2=color.red

// forhigh()=>
//     arkarenkdinamik3=color.silver
//     arkarenkdinamik3:= if high>high[1]
//         dinamik2=color.green
//     else
//         dinamik2=color.red

// forlow()=>
//     arkarenkdinamik4=color.silver
//     arkarenkdinamik4:= if low>low[1]
//         dinamik2=color.green
//     else
//         dinamik2=color.red

// getrequestSecurityColor(symboll,timeframee,expr)=>
//     b=request.security("","","")
//     b:=str.tostring(request.security(symboll,timeframee,expr),format.mintick)
//     b
//     col= if open>open[1]
//         dinamik=color.green
//     else
//         dinamik=color.red
//     col
//renk adımı kaldı son olarak
// 
pine-script pine-script-v5 tradingview-api trading algorithmic-trading
1个回答
0
投票

您正在更新每根蜡烛上的表格单元格,这是无用的。

尝试将整个 table.cell 更新块放在

if barstate.islast
块下,例如:

if barstate.islast
    table.cell(table1,column = 0,row=0 , text="follow omersabriklc",text_color = color.black)
    ...
    ...
    ...

这样它只会在最后一根蜡烛上运行一次,也许这有助于清除故障。

© www.soinside.com 2019 - 2024. All rights reserved.