line 102: Cannot call ‘operator ==’ with ‘expr1’=input integer. The argument should be of type: const string;

Total
1
Shares

i am having the above error message for the below code and i don’t get why, help please.
It is for mtf indicator. the argument is a string as the quote marks are there. It is really confusing.

Can someone help,please?

    res(Resolution) =>
        if Resolution == "00 Current"
            timeframe.period
        else
            if Resolution == "01 1m"
                "1"
            else
                if Resolution == "02 3m"
                    "3"
                else
                    if Resolution == "03 5m"
                        "5"
                    else
                        if Resolution == "04 15m"
                            "15"
                        else
                            if Resolution == "05 30m"
                                "30"
                            else
                                if Resolution == "06 45m"
                                    "45"
                                else
                                    if Resolution == "07 1h"
                                        "60"
                                    else
                                        if Resolution == "08 2h"
                                            "120"
                                        else
                                            if Resolution == "09 3h"
                                                "180"
                                            else
                                                if Resolution == "10 4h"
                                                    "240"
                                                else
                                                    if Resolution == "11 1D"
                                                        "1D"
                                                    else
                                                        if Resolution == "12 1W"
                                                            "1W"
                                                        else
                                                            if Resolution == "13 1M"
                                                                "1M"

Solution

https://www.tradingview.com/pine-script-reference/v4/#op_==

Seems that you passing input integer type in your function. You can’t compare integers with a string. Parse your data with tosting() or str.format() function
in your res() call.

x = input(01)
m = "1m"
res(tosting(x) + m)
Leave a Reply

Your email address will not be published. Required fields are marked *