Close to a new high question…


Category:
0
0

This should be easy. However, it is driving  me crazy trying to figure this out!

I am trying to develop a ThinkOrSwim scan that:

Looks for stocks that are within 5% of a BRAND NEW 52 week high.

AND the previous high needs to be at least 1 month old.

I will gladly donate for help with this  :0)

Thanks in advance!

RESOLVED
Marked as spam
Posted by (Questions: 1, Answers: 4)
Asked on May 8, 2017 6:02 pm
580 views
0

Let’s make sure I understand this. Current high is less than 52 week high but greater than 52 week high times 0.95. You said previous high needs to be at least 1 month old but I need to know if the previous high and 52 week high can be one and the same. Or are you saying that the current high must be greater than the highest high in more than a month? A screenshot showing this pattern would be a great help.

( at May 8, 2017 8:11 pm)
0
Private answer

This sort of works. It does not look back at least a month and I am unsure how to get that to happen. And the last candle once in a while is the new high.

Looking back at least one month is just a matter of placing the high 22 in the right place.

Does this look like I am on the right path or barking up a wrong tree?…

<pre>scan = high +(high*.05)>= highest(high,252) and highest(high,252)> high;</pre>

Marked as spam
Posted by (Questions: 1, Answers: 4)
Answered on May 10, 2017 5:38 pm
0

Ok, thanks for providing that. I can see right away some things that need adjusting. But it’s past quitting time for me so I’ll dig into this in the morning. Thanks.

( at May 10, 2017 7:50 pm)
0
Private answer

Ok, give this a try and see if it does the trick. I see from your original code you are trying to do the entire scan signal on one line of code. That is one way to drive yourself crazy. I find it best to break down each piece into it’s own line of code.

I also use variable names that describe each element clearly. I don’t just do this for instruction purposes. I actually apply this everywhere I write code. Readability makes a world of difference. Especially when you have to go back to something you wrote years ago.

One very important note before I post the code. When using the function named Highest(). It is sometimes required that you reference the previous value. In your example: Highest(high, 252) is going to cause problems. Because it’s including the current high in the test for Highest. In your case you actually want to use Highest(high[1], 252). This will not include the current high in the test for highest high in 252.

Here is the code. I have not tested it so let me know what you get.
def fiftyTwoWeekHigh = Highest(high[1], 252);
def highestInOneMonth = Highest(high[1], 21);
def fivePercentFromHigh = fiftyTwoWeekHigh * 0.95;
def signal = high < fiftyTwoWeekHigh and high > highestInOneMonth and high >= fivePercentFromHigh;
plot scan = signal;

 

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on May 11, 2017 10:27 am
0
Private answer

Test results ran after market closed today:

Symbol
Work?

ABEV
No

HSBC
No

INCR
Yes

MGA
Yes

MPC
Yes

MRK
Yes

NWL
Yes

RDS/B
Yes

TXT
Yes

The code accurately found 7 of 9 that meet the goal. Impressive especially considering you did not test this before sharing it!

The first two failed because today was a new 52 week high. The rest of the code works sweet!

Is there a way to correct this?

Marked as spam
Posted by (Questions: 1, Answers: 4)
Answered on May 11, 2017 1:21 pm
0

Please review your results again. ABEV has a 52 week high of 6.34 and today’s high is only 6.19. I also find that HSBC has a 52 week high of 44.18 and today’s high was only 43.64. Those two are good signals, as best I understand your specifications.

( at May 11, 2017 2:36 pm)
0
Private answer

Pete, My apologies! There is a bug or wrong data in the Stock Prophet chart that TOS is using. This is the chart I have been using all along! After locating the dates of the 52 week high prices for both these stocks from three other sources I am all done using that Stock Prophet charting tool in TOS. The TOS Chart has reliable information.

I am thankful for your time spent with this. A donation is heading your way real soon! :0)

 

Marked as spam
Posted by (Questions: 1, Answers: 4)
Answered on May 11, 2017 4:28 pm
0
Private answer

A contribution is on its way to dryheat_3 at your email server

I live on a disability income and wish I could send more. Hope this is sufficient.

Marked as spam
Posted by (Questions: 1, Answers: 4)
Answered on May 11, 2017 4:46 pm
0

Thank you so much for the contribution. Even the smallest amount is greatly appreciated. The most important contribution you made is posting this great question in our Q&A forum which will benefit many future visitors to this post. Thank you for that. Please don’t hesitate to post more questions in the future and please don’t feel obligated to make any contributions for the solutions I provide. Take care.

( at May 11, 2017 8:21 pm)