Revising the Price Change Study Filter


Category:
0
0

Hello,

Currently, I am using the Price Change Study Filter (pic attached) for a Scan that is showing when the current bar’s “Close” is at least a .2% greater than the “Close” 2 bars ago. It works fine…..but I wanted to edit it to show when the Current Bar’s “High” is at least .2% greater than the “Close” 2 bars ago.

Unfortunately you cannot use the Price Performance studies in the condition wizard so I had to attempt to edit the code directly. I think I successfully hacked it.

This code below seems to work but I also want to use it the opposite way for a Bearish scan. (Current Low .2% lower than the Close 2 bars ago). And I’m confused on  the whole “choice, greater than and less than”. I don’t know how to properly change it to just be bearish. I know its only working right now because the “greater” is the default. Thanks in advance.

<pre>input price = close;
input percent = .2;
input Choice = {default greater, less};
input length = 2;
input price2= High;
def x = 100*(price2 / price[length]-1);
plot scan;
switch (Choice){
case greater:
scan = x >= percent;
case less:
scan = x <= -percent;
}</pre>

Attachments:
RESOLVED
Marked as spam
Posted by (Questions: 2, Answers: 0)
Asked on May 26, 2020 6:58 pm
102 views
1
Private answer

The choice of direction is provided by the following input statement:

input Choice = {default greater, less};

The word "default" is located in front of the option that is currently applied unless changed in the edit studies view. Which is disabled for custom study filter. I really feel that Thinkorswim should include user interface elements for custom study filters just like it does for built-in study filters. But it does not. So we have to modify the code to select one of the other available options in this type of input statement

We simply move the word "default" to change this setting. Specifically, we move the word "default" to be in front of the second option. Like this:

input Choice = { greater, default less};

That's it. All the rest of the lines of code remain the same.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on May 27, 2020 7:40 am