High RelativeVolumeStDev During Specific Time Of Day


Category:
0
1

Is there a way to create a scan in Thinkorswim that can identify 3X relative volume for only the first/last 15 minute period of the trading day?  The scans would compare the first/last 15 minute trading day volume to the previous 780 periods (26 fifteen periods/trading day x 30 days = 780).  Also, is there a way for tos to complete the first 15 minute trading day scan, show the search results, and then stop the scan from updating so that the scan be checked later in the day?

Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on September 1, 2018 8:24 am
3076 views
0

What is “relative volume”? You will need to explain what this is before we can consider any potential solution.

The scan engine in Thinkorswim can only access 10-11 days of historical data at the 15 min time frame: http://toslc.thinkorswim.com/center/howToTos/thinkManual/Scan/Stock-Hacker/studyfilters.html

I don’t understand your math here so you need to explain this: ” The scans would compare the first/last 15 minute trading day volume to the previous 780 periods (26 fifteen periods/trading day x 30 days = 780)” On a 15 min time frame, you would be measuring 2 candles of data per day, the first and the last. So it would be 2 times number of days. As explained above, this would be 10-11 days. If we could access 30 days as you have requested, this would be 2 times 30 days.

( at September 1, 2018 10:19 am)
0

Hello Mr. Hahn,

Thanks for the quick reply!  I meant to reference the RelativeVolumeStDev indicator using the maximum data limit possible for a 15 minute period.  I was looking to run two separate scans during the trading day.  One scan to analyze only the first fifteen minutes of the trading day, and the other scan to analyze only the last 15 minutes of the trading day.

At a later date, I was going to create two additional scans using an “Unusual Volume” Study to see how the results compare.

Thanks for any help you can provide.

( at September 2, 2018 5:29 pm)
0

Ok, thanks for the clarification. I have updated the title of the question to include the exact name of the chart study. I also removed redundant words.

From your request, I believe you want to compute the average of previous first bars (assuming a 15 min chart). Then you want to compare the current first bar value to that average. Returning stocks where the current first bar volume is 3 times the average of previous first bars. Same for last bars. Is that correct?

I have an update on the amount of historical data available for the scan. The documentation from Thinkorswim is incorrect, or out of date. There are only 5 days worth of historical data available to a scan using the 15 min time frame. Let me know if this changes your specifications for this request.

( at September 3, 2018 8:16 am)
0

Thanks for your reply.

Yes, you are correct with your assumption: “I believe you want to compute the average of previous first bars (assuming a 15 min chart). Then you want to compare the current first bar value to that average. Returning stocks where the current first bar volume is 3 times the average of previous first bars. Same for last bars.”

Will it be possible for me to edit these studies to evaluate/compare different time frames such as fist/last 30 min or 1 hour, and RelativeVolumeStDev values ?

Thanks for your help.

( at September 3, 2018 3:20 pm)
1
Private answer

After explaining the limitations and getting clarification on some of the details I have a solution.

Before presenting the code I need to explain some details.

  • The Scan engine in Thinkorswim only has access to 5 days of 15 min data. The original request was to compute the average over a 30 day period. However we can only do this over a 5 day period.
  • The code is time frame agnostic. Meaning the code is not stuck on a 15 min time frame. The request was for a computation involving the first 15 minutes and last 15 minutes. The code merely selects the first bar and the last bar for these computations. So if you want the code to work on the first and last 15 min, you must apply this code to a 15 min time frame. If you were to change the time frame to 30 min, then the code automatically computes the first and last 30 min bars.
  • This code is only valid for intraday time frames.
  • The code can NOT be used with extended trading hours.
  • The scan includes two separate signals. One for the first bar and the other for the last bar.
    • In the case of the first bar signal: The scan can begin running during the first 15 minutes of the trading day. Any signals presented during this time will be held by the code through the reminder of the trading day.
    • In the case of the last bar signal: The scan can begin running at any time during the trading day. At any time before the last 15 min bar, the code will be looking at the previous day’s last 15 min bar signal. During the last 15 bar, those results are replaced by the current day’s last 15 min bar.

I think that covers everything. Here is the code for the scan:

input threshold = 3.0;
input length = 60;
input numDev = 2.0;
input allowNegativeValues = no;
def rawRelVol = (volume - Average(volume, length)) / StDev(volume, length);
def relVol = if allowNegativeValues then rawRelVol else Max(0, rawRelVol);
def newDay = GetDay() <> GetDay()[1];
def firstBarRelVol = if newDay then relVol else 0;
def lastBarRelVol = if newDay[-1] then relVol else 0;
def sumOfFirstBar = TotalSum(firstBarRelVol);
def sumOfLastBar = TotalSum(lastBarRelVol);
def firstBarAverage = sumOfFirstBar / 5;
def lastBarAverage = sumOfLastBar / 5;
rec conditionFirstBar = if newDay[-1] then no else if newDay then relVol > firstBarAverage * threshold else conditionFirstBar[1];
rec conditionLastBar = if newDay[-2] then no else if newDay[-1] then relVol > lastBarAverage * threshold else conditionLastBar[1];
# scan for first bar x times average of last 5
plot scan = conditionFirstBar;
# scan for last bar x time average of last 5
#plot scan = conditionLastBar;

 

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on September 4, 2018 9:22 am