Inboxmover
Pine Script Rookie
Pine Script Rookie
Posts: 4
Joined: September 15th, 2021
Contact: TradingView Profile

Please respond! Logical and or not programming

Hallo!

As you can see in the graph, I have lines for open price based on 30 min, 1H, 4H, 1D, week. When price crosses these lines, I get buy signals that I trade on today. I want to program it more advanced with logical operators (and, or not) Especially or, because then I could set up a whole bunch of conditions.

Small green = 30 Min
Black = 1H
Brown = 4 H
Silver = 1D
Gold = 1 week

I can't manage to get a drop down box with input option and, or, not.

input option must be input string.

Anyone have suggestions for code to create a multi filter with and, or and not?

I am trying to build a logical programming with a lot of combinations.

Sincerely, Lars Miore, Sweden




Image

purplemint22
Pine Script Rookie
Pine Script Rookie
Posts: 17
Joined: October 14th, 2022

Re: Please respond! Logical and or not programming

Interesting idea. This is how I would go about setting up a drop down for your input string with or as the default value since it has the highest priority.

logicalOperatorInput = input.string("or", title = "Logical Operator Options", options = ["or", "and", "not"])

processingclouds
Pine Script Master
Pine Script Master
Posts: 115
Joined: January 30th, 2022

Re: Please respond! Logical and or not programming

Hey,

Even if the input is string, like "or" , "and" or any other, you can use this in the code with
IF to check if logicInput == "or" than do OR operation and so on

Return to “Pine Script Q&A”