New Members: Be sure to confirm your email address by clicking on the link that was sent to your email inbox. You will not be able to post messages until you click that link.

Can someone help me with writing code for the Squeeze indicator by John Carter?

The SC website has a prewritten scan but it does not have useable code for long or short.

Answers

  • https://school.stockcharts.com/doku.php?id=technical_indicators:ttm_squeeze

    Is this the code you mean?

    At the bottom of the page are two examples, one for long and one for short. Are these the not usable ones?

    If so, what don't they do that you need?
  • What is the John Carter long or short code? Is there a description to use?
  • This is the code for long. The following 2 lines fail the "check syntax" test. The error message is mismatched types.

    AND [TTM Squeeze(20,2.0,20,1.5,20) is true]
    AND [yesterday's TTM Squeeze(20,2.0,20,1.5,20) is false]

    Below is the entire code.

    [type = stock] AND [country = US]
    AND [Daily SMA(20,Daily Volume) > 40000]
    AND [Daily SMA(60,Daily Close) > 20]

    AND [TTM Squeeze(20,2.0,20,1.5,20) is true]
    AND [yesterday's TTM Squeeze(20,2.0,20,1.5,20) is false]
    AND [TTM Squeeze Hist (20) > 0]
    AND [TTM Squeeze Hist (20) > yesterday's TTM Squeeze Hist (20)]
  • lmkwinlmkwin ✭✭
    edited February 2023
    when i copy and paste your entire code I don't get an error message when checking syntax




    I didn't realize that they had added the Squeeze and the GoNoGo stuff to the Technical Indicators dropdown. Learn something new every day.

    It's funny that in that link to ChartSchool they say to use the Donchian Channel mid line in the calculation section. They don't use Donchian Channel's StockCharts' name, which is Price Channel. The momentum indication is to take the 20 SMA and if it's greater than the 20 Middle Price Channel it's positive.
  • There are a slew of new indicators in the scan drop downs.
  • When I run the scan, I get no results. I think that's because it needs to be told to scan for long or short. When I follow the link you sent, scroll down to the code for long then follow the link in the instructions back to the scan, below are the 2 lines of code that fail.

    AND [TTM Squeeze(20,2.0,20,1.5,20) is true]
    AND [yesterday's TTM Squeeze(20,2.0,20,1.5,20) is false]

    The error message is mismatched types, numeric and true/false sand it applies to both lines. In words, what it is trying to say is that yesterday price was within the upper Bollinger and today it broke above the Upper Bollinger.

    BTW, thanks for helping.
  • I ran the code that was posted in your post. Just copied and pasted it, and the Syntax check is showing on the screen shot I posted. When I ran it yesterday, just prior to when I posted the reply there were 3 results. I don't have any experience testing these new workbench indicators at this point.

    When I run "the old squeeze code" mentioned in other posts on this forum and then add the momentum indication via the SMA vs the Middle Price Channel to see what comes up I get no results. But, according to the link to the TTM Squeeze indicator, they use the orginal 1960's definition of the Keltner Channel as created by Chester Keltner. For the Keltner Channel that can be used in scans and on charts, they use the "new" version of the calculation created by Linda Bradford Raschke 20 years later. So there's something off in the values when using the Keltner Channel to identify a squeeze condition vs the TTM Squeeze (ACP Only) indicator.

    When I run this today I get 3 results HIG, NGG, and PBF. Same results as yesterday.

    [type = stock] AND [country = US]
    AND [Daily SMA(20,Daily Volume) > 40000]
    AND [Daily SMA(60,Daily Close) > 20]

    AND [TTM Squeeze(20,2.0,20,1.5,20) is true]
    AND [yesterday's TTM Squeeze(20,2.0,20,1.5,20) is false]
    AND [TTM Squeeze Hist (20) > 0]
    AND [TTM Squeeze Hist (20) > yesterday's TTM Squeeze Hist (20)]

  • Thanks. It seems something isn't right but I don't think it's on the user side.
  • markdmarkd mod
    edited February 2023
    You could be right.

    Your scan as it exists on the SC server could be corrupted in some way (transmission error, disk error, etc.)

    I would delete your existing scan altogether, log out, log in again and create a completely new scan with a different name and then type in each line by hand instead of copy/pasting. The c/p could be introducing an error we can't see.

    P.S. one other thing - clear your browser cache - could be the browser keeps re-loading a version with errors.
  • StockCharts hasn't added the GoNoGo indicators to the Scan Syntax help yet. There are several GNG indicators in the Technical Indicators dropdown
Sign In or Register to comment.