Guest User | Sign In

Knowledge Base

Switch Function

Overview


The SWITCH() function uses two Boolean (true/false) conditions, with the first signal being true until the second condition is met. It will then remain off until the first condition is met again.

The primary use of this function would be any situation where you may wish to set an upper-value target and a different lower-value target as true/false signals.

In this example, a Show View tool has been applied using the following script formula to display the green shaded zones:

H1 = HIGH()>HIGHESTHIGH(BARS=66);
L1 = LOW()SWITCH(H1,L1)




H1 is true when there's a higher 66 day high
L1 is true when there's a lower 66 day low

The formula shows true (ie switches on) when there's a new 66 day high after a lower 66 day low. It switches off when a lower 66 day low is made, and so on.

In another example, the chart of gold is displayed with a Show View tool applied based on RSI. The script has been set to:

SWITCH(RSI()>70, RSI()<30)

The green areas of the Show View tool begin where the RSI is greater than 70, and remains until the value is less than 30. It doesn't switch on again until the RSI crosses 70:


Note that it's possible to click and drag the Show View over the price chart or indicator panel:


 Last updated Thu, Jan 17 2019 11:10pm

Please Wait!

Please wait... it will take a second!