Stocks crossing above previous day close after 10:30


Category:
0
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.

Attachments:
Marked as spam
Posted by (Questions: 6, Answers: 17)
Asked on October 10, 2018 7:29 pm
1764 views
0

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

( at October 12, 2018 10:24 am)
0

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?

( at October 12, 2018 11:30 am)
0

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.

( at October 12, 2018 12:03 pm)
0

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?

( at October 12, 2018 4:33 pm)
0

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.

( at October 12, 2018 6:31 pm)
0

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.

( at October 22, 2018 11:21 am)
0

Alerts are not supported in a watchlist. You will have to use a custom scan.

( at October 22, 2018 3:06 pm)
0
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:

input alertPeriodStart = 1030;
input alertPeriodEnd = 1600;
input numberOfDays = 0;
input numberOfYears = 0;
def startCounter = SecondsFromTime(alertPeriodStart);
def endCounter = SecondsTillTime(alertPeriodEnd);
def alertPeriod = if startCounter >= 0 and endCounter >= 0 then 1 else 0;
rec previousDayClose = if GetDay() <> GetDay()[1] then close[1] else previousDayClose[1];
def crossAbovePrevClose = close[1] < previousDayClose[1] and close > previousDayClose;
rec hasCrossed = if GetDay() <> GetDay()[1] and high < previousDayClose then no else if crossAbovePrevClose then yes else hasCrossed[1];
plot scan = alertPeriod and !hasCrossed[1] and hasCrossed;

Marked as spam
Posted by (Questions: 37, Answers: 4079)
Answered on October 11, 2018 10:49 am
0

Thank you so much Pete, I can’t wait to test this out tomorrow morning.

( at October 11, 2018 3:37 pm)