Price and Volume over 15 min


Category:
0
0

can’t seem to wrap around a simple logic.

volume(“period” = AggregationPeriod.FIFTEEN_MIN) is * 3 greater than volume(“period” = AggregationPeriod.FIFTEEN_MIN) from -1 bars ago and close(“period” = AggregationPeriod.FIFTEEN_MIN) is 5 % greater than close(“period” = AggregationPeriod.FIFTEEN_MIN) from -1 bars ago

plot scan =

alert (1) =

 

 

looking for 15 min bar

ohlc4 (Close) price must be 5 % than previous 15 min bar Close price

Volume must be 3 Times more than previous 15 min bar Volume

get email alert on condition meet

 

any help will be greatly appreciated.  Thanks

Marked as spam
Posted by (Questions: 3, Answers: 3)
Asked on December 11, 2019 2:50 pm
124 views
0
Private answer

Thanks for posting your code. I can use that to provide a bit of instruction while we provide you a workable solution.

Secondary Aggregations Not Supported in Scans:

The only place you can set the time frame for any scan is at the Study Filter. You cannot do so within the code. So if you need to compare one 15 min bar to another, you write the code without secondary aggregations and set the time frame for the Study Filter to 15 min.

What is a Secondary Aggregation Reference:

volume(“period” = AggregationPeriod.FIFTEEN_MIN)

So for any scan, you simply write the following:

volume

Referencing Previous Bars:

When you want to reference a previous bar you must use a positive integer. I know this is counter intuitive. However it will make sense to understand how the bar indexes works for Thinkorswim.

Volume of current bar: volume[0] (hint: when index == 0 you can omit the [0] altogether.

Volume of previous bar: volume[1]

In your example you used a negative value:

from -1 bars ago

This actually has the effect of reading one bar into the future. So if you wanted to read from the previous bar you actually need to use this:

from 1 bars ago

Multiplying Volume by 3:

Now let's take a look at how you tried to apply your "volume... 3 times more than previous"

volume(“period” = AggregationPeriod.FIFTEEN_MIN) is * 3 greater than volume(“period” = AggregationPeriod.FIFTEEN_MIN) from -1 bars ago

So we take out the secondary aggregation, because we must. Then we need to move your multiplier to the correct place in this section of code:

volume is greater than volume * 3 from 1 bars ago

We need to correct a similar error in the section you use to compare current close to previous close. But before we get too much further into patching up your code we need to examine your specifications.

What you Have Requested:

ohlc4 (Close) price must be 5 % than previous 15 min bar Close price

Volume must be 3 Times more than previous 15 min bar Volume

So did you really mean that you want to compare the current bar's ohlc4 to the previous bar's close? Because there is nothing in your code that references ohlc4. That is a completely different data point. I should also mention that you are asking for a stock that has a 5% move within a single 15 minute span of time. I can't even imagine when or where this might actually happen. But that's what you have requested so that is the solution we will deliver.

The Solution:

plot scan = volume > volume[1] * 3 and close > ohlc4[1] * 1.05;

This is your scan, all in one line, in its most clear and concise terms. Translated into English it reads like this: volume of current bar is greater than volume of previous bar times 3 AND close of current bar is greater than ((open + high + low + close) divided by 4) of the previous bar times 1.05.

If you want this to send you sms/email notifications, there is nothing in the code that can accomplish that. You must save the scan and then generate a dynamic alert from that saved scan. I covered this in the following video:

https://www.hahn-tech.com/thinkorswim-overnight-range-scan-alert/

Coverage on the dynamic scan begins at the 29:50 mark of that video.

 

Marked as spam
Posted by (Questions: 37, Answers: 4084)
Answered on December 11, 2019 4:41 pm