20% Price Move Within Last Year


Category:
0
0

Re-posted as requested and without formatting.

Trying to implement the following in a Scan: price action has to have moved 20%, up or down, within the past year

Formula in TC2000 is: (MAXH252 – MINL252) / C > 0.20

I’m new to ThinkOrSwim and after some searching here and going through the ThinkOrSwim Help Text, I think this is what it should be. Can someone confirm?

input periods =252;
def hi52 = Highest(high[1],periods);
def lo52 = Lowest(low[1],periods);
plot scan = ((hi52 – lo52)/ close) > 0.2;

NOTE: In my previous post, I had selected the code and chose Preformatted from the drop-down. You asked me to re-submit.

Marked as spam
Posted by (Questions: 1, Answers: 0)
Asked on June 17, 2020 8:48 am
86 views
0
FYI. I worked out a way to enable the "preformatted" option for code without destroying the contents of the code. Also, be sure to include spaces between your operators within your equations and comparisons. Makes the code more readable and would have prevented the problem with preformatted text in the first place.
( at June 17, 2020 1:07 pm)
1
Private answer

Thank you for reposting and many more thanks for explaining how that previous code got jumbled up:

I had selected the code and chose Preformatted from the drop-down

If possible, I will see if there is away to disable that option from the text formatter.

Your code appears to be correct with only one minor detail. You should remove the index values from after the high and low. Using the [1] after a variable or data object causes the code to examine the previous bar instead of the current bar. So the following two lines from your code:

def hi52 = Highest(high[1],periods);
def lo52 = Lowest(low[1],periods);

Should be changed to this:

def hi52 = Highest(high, periods);
def lo52 = Lowest(low, periods);

Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on June 17, 2020 10:42 am