在 Tradingview Pinescript 编辑器中插入交易品种时出现编译错误?

时间:2021-02-27 17:35:39

标签: pine-script trading indicator metatrader4 tradingview-api

当我尝试向我编写的脚本添加符号时,出现编译错误。我的目标是向脚本添加警报。脚本中有 17 个指标。我该如何解决这个问题?

f_trigger(_ticker)=>
_long = (a > b) and (a > c) and (macd > 0) and (macd > signal)...
_short = (a < b) and (a < c) and (macd < 0) and (macd < signal)...

[_co, _cu] = security(_ticker, timeframe.period, [_long, _short])
_msg = _ticker + ", " + timeframe.period + ": "
if _co
_msg := _msg + "Combo Script Long"
alert(_msg, alert.freq_once_per_bar_close)
else if _cu
_msg := _msg + "Combo Script Short"
alert(_msg, alert.freq_once_per_bar_close)

f_trigger(syminfo.tickerid)
f_trigger("BINANCE:BTCUSDT")
f_trigger("BINANCE:CTSIBUSD")
f_trigger("BINANCE:CRVBNB")
f_trigger("BINANCE:ASHBTC")
f_trigger("BINANCE:AAVEBUSD")
f_trigger("BINANCE:ADABUSD")
f_trigger("BINANCE:ALGOBUSD")
f_trigger("BINANCE:ALPHABUSD")
f_trigger("BINANCE:ANTBUSD")
f_trigger("BINANCE:ATOMBUSD")
f_trigger("BINANCE:AUDIOBUSD")
f_trigger("BINANCE:AVABUSD")
<块引用>

错误:编译的脚本代码太长:114322。限制为60000。

1 个答案:

答案 0 :(得分:0)

我解决了这个问题。我注意到我收到了一个编译错误,因为里面有很多指标。它最多可以编译 6 个符号。

f_trigger(_ticker,L_msg,S_msg)=>
    _l = (a > b) and (a > c) and (macd > 0) and (macd > signal) ...
    _s = (a < b) and (a < c) and (macd < 0) and (macd < signal) ...

    [long, short] = security(_ticker, timeframe.period, [_l, _s], lookahead = barmerge.lookahead_on)
    
    // To create an alarm once
    isLong = false
    isLong := nz(isLong[1], false)
    
    isShort = false
    isShort := nz(isShort[1], false)
    
    long_val = 0
    short_val = 0
    
    // Şartlar kontrol ediliyor
    LongSignal = not isLong and (long)
    ShortSignal= not isShort and (short)
    
    // Sinyalden sonra İşlem Sıfırlanıyor
    if (LongSignal)
        isLong := true
        isShort := false
        long_val := 1
        short_val := 0
    if (ShortSignal)
        isLong := false
        isShort := true
        long_val := 0
        short_val := 1
    
    if ((long_val) and (L_msg != ""))
        alert(L_msg,  alert.freq_once_per_bar_close)
    else if ((short_val) and (S_msg != ""))
        alert(S_msg,  alert.freq_once_per_bar_close)

// semboller tanımlanıyor
s01 = input('BINANCE:BTCUSDT', type=input.symbol)
L_msg01 = input('Long BINANCE:BTCUSDT', type=input.string)
S_msg01 = input('Short BINANCE:BTCUSDT', type=input.string)

s02 = input('BINANCE:ADAUSDT', type=input.symbol)
L_msg02 = input('Long BINANCE:ADAUSDT', type=input.string)
S_msg02 = input('Short BINANCE:ADAUSDT', type=input.string)

s03 = input('BINANCE:AAVEBUSD', type=input.symbol)
L_msg03 = input('Long BINANCE:AAVEBUSD', type=input.string)
S_msg03 = input('Short BINANCE:AAVEBUSD', type=input.string)

s04 = input('BINANCE:ADABUSD', type=input.symbol)
L_msg04 = input('Long BINANCE:ADABUSD', type=input.string)
S_msg04 = input('Short BINANCE:ADABUSD', type=input.string)

s05 = input('BINANCE:AAVEBNB', type=input.symbol)
L_msg05 = input('Long BINANCE:AAVEBNB', type=input.string)
S_msg05 = input('Short BINANCE:AAVEBNB', type=input.string)

s06 = input('BINANCE:ADABNB', type=input.symbol)
L_msg06 = input('Long BINANCE:ADABNB', type=input.string)
S_msg06 = input('Short BINANCE:ADABNB', type=input.string)


// Fonksiyon çalıştırılıyor
f_trigger(syminfo.tickerid,"","")
f_trigger(s01,L_msg01,S_msg01)
f_trigger(s02,L_msg02,S_msg02)
f_trigger(s03,L_msg03,S_msg03)
f_trigger(s04,L_msg04,S_msg04)
f_trigger(s05,L_msg05,S_msg05)
f_trigger(s06,L_msg06,S_msg06)

同时修复了安全功能导致的重绘问题