Various coders have developed custom studies in ThinkorSwim to auto-draw "pivot S/R" or "swing highs/lows," which is what you appear to be doing.
Here's a random example of one. The studies are typically based on finding the highest high and lowest low of the past X bars, so you can vary that to change the granularity of the lines that are generated. This example happens to be set on a X = 5-bar period.
And then you could also code in various other refinements to combine those pivot line locations with parameters such candlestick type (e.g., doji bars), volume, MA location, etc., etc.
Feel free to PM me if you'd like to see some of the code examples. I'm not a coder, other than being able to do some basic Thinkscript, and don't even use these studies myself... so I won't be able to help you much with any code conversions to your particular platform, etc.
Here's a random example of one. The studies are typically based on finding the highest high and lowest low of the past X bars, so you can vary that to change the granularity of the lines that are generated. This example happens to be set on a X = 5-bar period.
And then you could also code in various other refinements to combine those pivot line locations with parameters such candlestick type (e.g., doji bars), volume, MA location, etc., etc.
Feel free to PM me if you'd like to see some of the code examples. I'm not a coder, other than being able to do some basic Thinkscript, and don't even use these studies myself... so I won't be able to help you much with any code conversions to your particular platform, etc.

