♥ 0 |
I was looking to see if we could scan for stocks which are crossing over the Previous day Close after 10:30AM. I attached a screenshot of as an example. The blue line is the previous day close price.
Marked as spam
|
Private answer
Most of what is needed for this is already accomplished by code I previously published. The name of the video is “Thinkorswim Overnight Range Scan Alert”. Here is the link: https://www.hahn-tech.com/thinkorswim-overnight-range-scan-alert/ This gives us the “alert period”. Which is a user adjustable time span, during which alerts can be triggered. For scan’s you must always use Eastern Timezone for all times. I will strip out the other components and set the alert line to the previous day’s close. Very important note here. Your screenshot shows extended hour trading session on the chart. For this solution we are keeping things super simple. So you will need to turn off extended hours for your scan. Otherwise you won’t get the specified results. From your screenshot I also noticed your example showed that prices had remained below the previous close until the cross finally occurred after 10:30. So I added some logic to ensure we handle it this way. This is a very crucial detail that was not part of your request. So by supplying your screenshot I was able to fill in the gaps. Here is the final code:
Marked as spam
|
Please log in to post questions.
Hi Pete I created a new scan last night using the code you provided and I used a 5 min timeframe so I could turn off extended hours as you stated. I have not seen one alert come through. Does the time frame need to be left as daily for code to work? I am planning on using this as a study so I can covert to a strategy. Can I back test the code tomorrow or later to see if I missed an alert? Thanks again
Yes, you can check for any valid signals occurring in previous 20 bars by changing the final line of code and adding a new one. Shown here:
def scan = alertPeriod and !hasCrossed[1] and hasCrossed;
plot test = Highest(scan, 20) > 0;
In the last line you can change the value of 20 to however many of bars you want to look back. I just ran it using the 15 min time frame and got a list of 6 stocks.
You stated: “have not seen one alert come through”. So did you actually save the scan and create a dynamic alert out of the scan? Or were you running the scan manually throughout the day?
Pete thank you for the quick reply, I did save the scan but I did two additional criteria in addition to the custom code. I used Last min .50 cents and max 10 dollars and I used volume Min 500,000 because I figured stocks with decent trading activity would have at least that much when scan would start. I have the scan open on the TOS mobile app since I cannot download the platform to my work computer. I will change the code when I get home to see list of stocks. Thank you again.
Pete, I changed the code in the evening to see what alerts would have come in and I see some odd results. I attached a few screenshots to illustrate what I see. I am seeing stocks which are above the previous close price the whole time. I believe the code should only be returning results where price is below previous close until after 10:30 time frame correct?
There were no screenshots attached to your “new answer” so I was not able to view anything that you have described. Everything is working perfectly here. Try using this scan that I created on my platform. At today’s close it is producing 11 results. And every single one of them is accurate. Here is the share link for my saved scan: http://tos.mx/dRkPIy
Remember, everything in the scan is set to Eastern Timezone. I did mention this in my answer but felt it was important to note given you are having issues getting things to match.
Hi Hann
your videos are very exhaustive and detailed. appreciate that. I am trying to write a Alert on my watch list ,we keep checking every minute and when the price crosses above yesterday’s close or yesterday’s high , i get a Audio and a onscreen alert. can you help me with that.
Alerts are not supported in a watchlist. You will have to use a custom scan.