0
votes

I want to show the options as string as in photo1 photo1

I want it to be "very sensitive" "sensitive" and "normal" in the options. For example, if you choose very sensitive, the length should be 20.0. When choosing normal, the length should be 53.0. How do I do this?

I have no idea about PineScript. I wrote something to explain what I want to do

length = input(title="Settings",options=["VerySensitve", "Sensitive","Normal"])

if (length == "VerySensitive")
length = 20.0

else if (length == "Sensitive")
length = 33.0

else if (length == "Normal")
length = 53.0
1
Post code with your question pls so we start from there. - PineCoders-LucF
I added the code but my code is totally ridiculous. In short, what I want to do is I don't want the user to see the "length" . User should only see the sensitivity setting. Please help - Mert Toprak

1 Answers

0
votes

It's better to put literals you refer to more than once in variables, so if you change a menu string, in your case, you only need to change it in once place.

//@version=4
study("", "", true)
SV1 = "VerySensitive"
SV2 = "Sensitive"
SV3 = "Normal"
sensitivity = input(SV3, "Sensitivity", options=[SV1, SV2, SV3])

int length = na
if sensitivity == SV1
    length := 20
else if sensitivity == SV2
    length := 33
else if sensitivity == SV3
    length := 53
ma = sma(close, length)
plot(ma)