Sinan Samet
Sinan Samet

Reputation: 6752

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.

Upvotes: 1

Views: 4974

Answers (2)

Samuel Moore
Samuel Moore

Reputation: 1

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,

newShortEntryAlertMessage(_message) =>
string(_message)

newLongEntryAlertMessage( _message) =>   
string(_message)

alertcondition(na(pivothighCondition) and trend == 0 and ta.crossunder(low, short_62_fib_level),"Watch For Short(Sell) Entry", newLongAlert("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)))

alertcondition(na(pivotLowCondition) and trend == 1 and ta.crossunder(high, long_62_fib_level), "Watch For Long(Buy) Entry", newShortAlert("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)))

Upvotes: 0

vitruvius
vitruvius

Reputation: 21332

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.

Upvotes: 1

Related Questions