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.

No Supertrend indicator?

From what I can find there is no Supertrend indicator built into the scanning system. So I am trying to write one myself that identifies when the Supertrend indicator is bullish, but I am getting an error, not sure what I'm doing wrong here:

[((daily max(7,close) + daily min(7,close)) / 2) + (3 * ATR(7)) < close]

I am getting this:
Could not parse "" located in the clause "((DAILY MAX(7,CLOSE) + DAILY MIN(7,CLOSE)) / 2) + (3 * ATR(7))"

Comments

  • markdmarkd mod
    edited January 24
    Hi Carissa, welcome aboard.

    Although Stockcharts does add new indicators from time to time, I don't see Supertrend either. But it does seem to resemble Parabolic SAR, if that interests you.

    As for the scan, this passes syntax:

    // begin

    [group is sp500]

    and [[[daily max(7,close) + daily min(7,close)] / 2] + [3 * ATR(7)] < close]

    // end

    but check whether the groupings are what you want.

    When you group things, the scan language [unlike most other languages] wants square brackets -> [ ], not parens.

    The parens -> ( ) are reserved for built-in functions like max( ), and indicators/overlays like sma(... ) or MACD Line( ...) .

    Also, the errors from the editor approximate where the error is, but the error is not always identified very helpfully. In this case, it would have been the first parens that triggered the error, but you would never guess why from the error message.
  • lmkwinlmkwin ✭✭
    edited January 25
    Think of the ( and the [ as being part of a team. There must be a corresponding ) and ] for every ( or [.

    Can't Parse is usually a ( ) issue but also can just be that the system can't do what you are asking.

    [ ] issues usually result with an error message about mis-matched brackets.

    I'd say that the "Supertrend" can also be like the the Chandelier Exit or Keltner Channel, which also use the ATR value in their plot.
  • Syntax shows correct ... but I get no results with this scan on my 250 item chartlist.

    and [[[daily max(7,close) + daily min(7,close)] / 2] + [3 * ATR(7)] < close]
  • markdmarkd mod
    edited January 25
    Apparently it's a fairly rare occurrence.

    Run it against

    [[exchange is NYSE] or [exchange is NASD]]

    and change the date offset a few times. Some days you get hits, some days you don't. If you get hits, the logic is valid.
  • CarissaTCarissaT
    edited January 26
    That worked (azb). But I must still be doing something wrong logically, or the software isn't doing what I'm asking, because there aren't enough hits that I'm getting from that scan versus what I'm seeing on charts using the Supertrend indicator.
    What I'm trying to do is take the maximum price (over the last 7 days) plus the minimum price (over the last 7 days) and average that out; and then add the ATR of the last 7 days * 3, and compare that to the last close. If that's lower than the last close, it's in an uptrend.
    Ultimately I want to isolate those stocks that had a recent crossover of their close from above to below (which would be a buy signal), which I know how to do if I can get this part working right.
  • middle price channel 7 is the highest (maximum) price 7 + lowest (minimum) price 7 divided by 2. The middle price channel is a very useful visual on the charts as well as useful trend indication. It's the 50% mark of the high and the low.

    To get the Close to be > 3 times ATR 7 plus the middle price channel is going to be a large rapid movement. On ThinkorSwim, it appears that they use a moving average of the ATR instead of the raw ATR number in their SuperTrend line calculation. And they allow you to pick the MA but many I've seen talk Hull MA.

    So perhaps use + 3 * EMA(7,ATR(7)) or + 3 * HullMA(7,ATR(7)) on the ATR side of the equation, and the Middle Price Channel on that Min/Max side of the equation.



  • markdmarkd mod
    edited January 27
    I am not familiar with this indicator or how it works, but possibly you might get more hits if you use today's close against the 1 day ago max, min and ATR.

    Most indicators/overlays introduce some kind of lag - either calculated like an MA or "imposed", like price channels. Max and min don't have a lag - they are as of the current bar, so if there is a big jump, it's included in the calculation. That makes it a higher hurdle to generate a signal because the big jump is included. But if you don't include the current bar, the current bar behavior is compared to only the previous bars, which should make a signal easier to reach.

    P.S.

    @CarissaT

    I ran this for the past few days (including mid day today) and got some good hits.

    [group is sp500]

    and [[[1 day ago max(7,close) + 1 day ago min(7,close)] / 2] + [3 * 1 day ago ATR(7)] < close]

  • CarissaTCarissaT
    edited January 31
    Thanks. Great info and I appreciate everyone's taking the time to check this out for me. What got me started at this scan is the backtesting software here:
    https://www.backtestzone.com/webapp
    The Supertrend buy/sell trigger seemed to generate the most consistent positive results vs. buy and hold for the stocks I'm interested in swing trading. When I have less tequila in my system I'll wrap my head around the details and provide a better response on what works well for this indicator. I've thrown in a few other criteria like moving average crossovers etc. but have yet to find one that works better than the Supertrend. That being said I've only been swing trading for a year and there are a lot of indicators that I haven't tried to wrap my head around yet.
  • When I see expressions like these ...
    and [[[1 day ago max(7,close) + 1 day ago min(7,close)] / 2] + [3 * 1 day ago ATR(7)] < close]

    I often double or triple my results (so I get more), and then use some type of RANKING to sort

    and [
    [[[1 day ago max(7,close) + 1 day ago min(7,close)] / 2] + [3 * 1 day ago ATR(7)] < close]
    OR [[[2 days ago max(7,close) + 2 days ago min(7,close)] / 2] + [3 * 2 days ago ATR(7)] < close]
    OR [[[3 days ago max(7,close) + 3 days ago min(7,close)] / 2] + [3 * 3 days ago ATR(7)] < close]
    ]
  • After running this scan for a few selected days over the past several months, it appears to have about a one in ten great hit rate - that is, it picks up a stock just beginning a strong trend, or early in a strong trend.

    The others seem to be buyouts, with no further upside potential because price has jumped to the buyout price, or buying climaxes (or short squeezes) in (probably) manipulated stocks.

    So, it would probably work best in well established mid to large cap cyclical stocks, probably belonging to an index, that have a period of accumulation (a more or less orderly price range running horizontally slightly above its 52 weely low channel for several weeks, maybe a few months) and then breaking the quarterly or annual upper price channel (see ELBT beginning 10/7/24 scan hit date for a good example).

    Any erratic chart - random wide price bars and gaps in both directions, random volume variations - should probably be avoided. Institutions don't buy those stocks, and that's what you need for big gains.
Sign In or Register to comment.