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

Get these arows (< >) in the input settings menu?

Hey!

How do I write code so that I can have these < > to choose from in the input settings menu. It is so hard to write fixed decided code and there are so many different variants to analyze the best choice.

Sincerely, Lars Miore, Sweden



BUY =

ENT == srcsm1 and TIME and extrak1 and extrak2 and extrak3 and extrak4 and extrak5 and extrak6 and extrak7 ? sm1 > sm2 :
ENT == srcsm2 and TIME and extrak1 and extrak2 and extrak3 and extrak4 and extrak5 and extrak6 and extrak7 ? pris > sm2 :
ENT == srcsm3 and TIME and extrak1 and extrak2 and extrak3 and extrak4 and extrak5 and extrak6 and extrak7 ? pris > sm3 :
ENT == srcto1 and TIME and extrak1 and extrak2 and extrak3 and extrak4 and extrak5 and extrak6 and extrak7 ? pris > to1 :
ENT == srcto2 and TIME and extrak1 and extrak2 and extrak3 and extrak4 and extrak5 and extrak6 and extrak7 ? pris > to2 :
ENT == srcto3 and TIME and extrak1 and extrak2 and extrak3 and extrak4 and extrak5 and extrak6 and extrak7 ? pris > to3 :
ENT == srcth1 and TIME and extrak1 and extrak2 and extrak3 and extrak4 and extrak5 and extrak6 and extrak7 ? pris > th1 :
ENT == srcth2 and TIME and extrak1 and extrak2 and extrak3 and extrak4 and extrak5 and extrak6 and extrak7 ? pris > th2 :
ENT == srcth3 and TIME and extrak1 and extrak2 and extrak3 and extrak4 and extrak5 and extrak6 and extrak7 ? pris > th3 :
ENT == srctl1 and TIME and extrak1 and extrak2 and extrak3 and extrak4 and extrak5 and extrak6 and extrak7 ? pris > tl1 :
ENT == srctl2 and TIME and extrak1 and extrak2 and extrak3 and extrak4 and extrak5 and extrak6 and extrak7 ? pris > tl2 :
ENT == srctl3 and TIME and extrak1 and extrak2 and extrak3 and extrak4 and extrak5 and extrak6 and extrak7 ? pris > tl3 :

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

Re: Get these arows (< >) in the input settings menu?

I think you would have to set up a work around for this since you can't create an options list for a logical operator that won't translate this input as a string and a string won't be able to perform a comparison.

I would suggest creating another level to this with a boolean input so that false translates to > and true translates to < in the code.

Then you could use the boolean in an if statement, which could look something like this.

if logicalOperatorBoolean == true
ENT == srcsm1 and TIME and extrak1 and extrak2 and extrak3 and extrak4 and extrak5 and extrak6 and extrak7 ? sm1 > sm2 :

else
ENT == srcsm1 and TIME and extrak1 and extrak2 and extrak3 and extrak4 and extrak5 and extrak6 and extrak7 ? sm1 < sm2 :

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

Re: Get these arows (< >) in the input settings menu?

Hey,

You can use the options input as > or < , than use logical check on this considering them as strings.

e.g.

Code: Select all

whichWay = input.string(defval = ">", options = [">", "<"])
BUY = 
(ENT == srcsm1 and TIME and extrak1 and extrak2 and extrak3 and extrak4 and extrak5 and extrak6 and extrak7) ? (whichWay==">" ? sm1 > sm2 : sm1 < sm2) : 
...................


Return to “Pine Script Q&A”