English 中文(简体)
An argument of series string type was used but a simple string is expected when comparing close and vwap
原标题:

When trying this code:

strategy.risk.allow_entry_in(close > ta.vwap(hlc3) ? strategy.direction.long : strategy.direction.short)

I get this error:

An argument of series string type was used but a simple string is expected

It happens from this:

close > ta.vwap(hlc3)

I am just trying to say that it should return true if the close is above vwap. What am I doing wrong here?

Sorry I m new to pine and this is my first script.

问题回答

simple string means the variable s value should never change during the execution of the script.

You are passing your parameter with the ternary operator so its return value can change.

These things have always been achievable by using your own self created functions. For example alertconditon() can t use Series Strings (such as str.tostring(dynamic_float)) for the message parameter.

This is how this can be circumvented,

newShortEntryAlert(_condition, _title, _message) =>

    if na(pivothighCondition) and trend == 0 and ta.crossunder(low, short_62_fib_level)
        alertcondition(condition = _condition, title = _title, message = _message)

newLongEntryAlert(_condition, _title, _message) =>

    if na(pivothighCondition) and trend == 0 and ta.crossunder(low, short_62_fib_level)
        alertcondition(condition = _condition, title = _title, message = _message)

newShortAlert(na(pivothighCondition) and trend == 0 and ta.crossunder(low, short_62_fib_level),"Watch For Short(Sell) Entry", "Look For Short(Sell) Entry, Entry Price: " + str.tostring(short_62_fib_level) + ", Shares: " + str.tostring(short_position_shares) + "(" + str.tostring(short_position_size_in_lots) + "), T/P: " + str.tostring(short_position_tp) + ", S/L: " + str.tostring(short_position_sl))

newShortAlert(na(pivotLowCondition) and trend == 1 and ta.crossunder(high, long_62_fib_level), "Watch For Long(Buy) Entry",  "Look For Short(Sell) Entry, Entry Price: " + str.tostring(long_62_fib_level) + ", Shares: " + str.tostring(position_shares) + "(" + str.tostring(position_size_in_lots) + "), T/P: " + str.tostring(long_position_tp) + ", S/L: " + str.tostring(long_position_tp))




相关问题
I m trying to write pinescript to locate side by side candles

Brother candles as per image so the candles open and close values are about the same one bullish, one bearish eg. close of candle 1 = open candle 2 open candles 2 = close candle 1 hope someone may ...

Using if statement when input is selected in pinescript

I have a drop down menu via inputs that should control the backgroundcolor when changed. As a simple example, when I select the 200/200 from the drop down list, I want the background color to use the ...

为什么用文字计算错误?

我写了一个文字,比较了两种符号之间百分比差异的演变,但我可以说明为什么计算错误。

热门标签