Scan bars crossing above highest bar in a given span


Category:
0
0

Hi Pete,

Is it possible to create a scan that returns results where a selected variable of the current bar crosses above a selected variable of any bar within a predetermined range of past bars?

Example 1: scan for the close of the current bar crossing above the highest high of the past 20 bars.
Example 2: scan for the close of the current bar crossing above the highest close of the past 20 bars.

Thanks
Justin

 

Marked as spam
Posted by (Questions: 8, Answers: 10)
Asked on September 16, 2021 4:09 pm
124 views
0
Private answer

You can build this scan using the Condition Wizard. The method requires you to explore all available options and when you see this solution you will open up an entirely new level of understanding about how to use the Condition Wizard.

Here is a link to our free tutorial showing how to use the Condition Wizard:

https://www.hahn-tech.com/thinkorswim-condition-wizard/

Screenshot below show how this is setup in the Condition Wizard and here is the text of the code generated by the Condition Wizard according to what you see in the screenshot below:

close crosses above Highest("data" = HIGH, "length" = 19) from 1 bars ago

That the solution for the close crossing the highest high in 20 bars. You can study this solution and work out the other elements on your own.

I will mention some important details:

The right side of the condition is using a built-in function named "Highest()". The offset is adjusted to a value of 1 otherwise it will include the current bar in that measurement and since the close can never be higher than the high of the same bar it this condition would fail unless that offset was adjusted as shown. The length parameter is set to 19 because we are already offsetting the Highest() function one bar to the right, given us a total of 20 bars to work with in the entire computation. Adjust the length parameter as needed to fit your particular preferences.

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on September 16, 2021 4:41 pm
0
This works perfectly. Thank you very much Pete!
( at September 16, 2021 6:09 pm)