Scan For Stocks Like This One.

Oleron

New member
SH5ug7vr_o.png
[/URL]


I'm trying to set up a scan to sift out stocks like this one: stocks that are absolutely dead-flat for months, and have very recently begun to exhibit activity. I imagine the reason is obvious =) . Any assistance is appreciated. Thanks.
 
Solution
Well, I'm not sure since it's early and I haven't had enough coffee yet, but this works for me. I broke the algorithm into steps in the hopes that ToS will deal more elegantly with piecewise calculation and it seems to run just fine.

Code:
input n = 15;

def a = Sum(Max(high, close[1]) - Min(low, close[1]), n);
def b = Highest(high, n) - Lowest(low, n);

def c = Log(a/b);

def d = c / Log(n);

plot f = if sum(d > 0.618, n) >= n then 1 else double.nan;

I simply replaced the instances of '10' with 'n'. I'm not sure which of them should really have been changed. but it runs. It showed 2 results on the daily scanner as of this morning. (Saturday 20 Nov 2021).

Hope that helps.

-mashume

as an aside: I find, when dealing with long and...
I've some luck with the following code gleaned from a Reddit post:

Code:
# Consolidation Scan (Trading Flat)
# Mobius
# To Scan for Flatter Consolidation Raise .618 to .7 and to lengthen or shorten consolidation period raise or lower the value 10.
sum((Log(Sum(Max(high, close[1]) -
Min(low, close[1]), 10) /
(Highest(high, 10) - Lowest(low, 10))) /
Log(10)) > .618, 10) >= 10

It's picked out a couple of stocks that seem to fit what I'm looking for, and quite a few more that do not at about a 5/1 ratio. But it's a start.

I tried to add:

Code:
def lngth = 10;

..in order to make it easier to change the period length, but that single line breaks everything after SUM, and I don't know why. As you can probably tell, I have had only sporadic coding experience, and am a rank beginner at ThinkScript.

Here's another perfect example of what I'm looking for that popped up on FinViz:

8INxzV9S_o.png


The above example would not have been picked up by this code of course because of the recent flurry of trading, and that means it's already too late anyway. I've seen enough of these to know what's going to happen very soon (possibly in the next trading day consider how sharply it has already spiked): it's going to crash. Hard. edited by mods
 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Well, I'm not sure since it's early and I haven't had enough coffee yet, but this works for me. I broke the algorithm into steps in the hopes that ToS will deal more elegantly with piecewise calculation and it seems to run just fine.

Code:
input n = 15;

def a = Sum(Max(high, close[1]) - Min(low, close[1]), n);
def b = Highest(high, n) - Lowest(low, n);

def c = Log(a/b);

def d = c / Log(n);

plot f = if sum(d > 0.618, n) >= n then 1 else double.nan;

I simply replaced the instances of '10' with 'n'. I'm not sure which of them should really have been changed. but it runs. It showed 2 results on the daily scanner as of this morning. (Saturday 20 Nov 2021).

Hope that helps.

-mashume

as an aside: I find, when dealing with long and complex equations it is almost always better to break them into their basic blocks and calculate those independently rather than as a monolithic block of code. Easier to read, easier to debug. I had to put this one into a text editor and break it down like this:
Code:
sum(
    (
        Log(
            Sum(
                Max(
                    high, close[1]
                )
            -
                Min(
                    low, close[1])
                , 10
            )
        /
            (
                Highest(
                    high, 10
                )
            -
                Lowest(
                    low, 10
                )
            )
        )
    /
        Log(
            10
        )
    )
    > .618,
10
)
>= 10
to figure out what went with what, and then I still had to rely on the parenthesis matching of my favourite text editor to get me through. I guess this is my fate having learned mathematics with an RPN HP calculator.
 
Solution
Well, I'm not sure since it's early and I haven't had enough coffee yet, but this works for me. I broke the algorithm into steps in the hopes that ToS will deal more elegantly with piecewise calculation and it seems to run just fine.

Code:
input n = 15;

def a = Sum(Max(high, close[1]) - Min(low, close[1]), n);
def b = Highest(high, n) - Lowest(low, n);

def c = Log(a/b);

def d = c / Log(n);

plot f = if sum(d > 0.618, n) >= n then 1 else double.nan;

I simply replaced the instances of '10' with 'n'. I'm not sure which of them should really have been changed. but it runs. It showed 2 results on the daily scanner as of this morning. (Saturday 20 Nov 2021).

Hope that helps.

-mashume

as an aside: I find, when dealing with long and complex equations it is almost always better to break them into their basic blocks and calculate those independently rather than as a monolithic block of code. Easier to read, easier to debug. I had to put this one into a text editor and break it down like this:
Code:
sum(
    (
        Log(
            Sum(
                Max(
                    high, close[1]
                )
            -
                Min(
                    low, close[1])
                , 10
            )
        /
            (
                Highest(
                    high, 10
                )
            -
                Lowest(
                    low, 10
                )
            )
        )
    /
        Log(
            10
        )
    )
    > .618,
10
)
>= 10
to figure out what went with what, and then I still had to rely on the parenthesis matching of my favourite text editor to get me through. I guess this is my fate having learned mathematics with an RPN HP calculator.


Thank you, that is far more parse-able. Now to see how it works...
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
264 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top