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.

Having some trouble with scan syntax

Good day everyone!

I'm having trouble with some scan syntax, wondering if someone could assist:

1) I'm trying to create a scan that measures divergence from the sma 20 day with a 10% minimum threshold, eg stock at 110, sma at 100.

I tried the following:

[type is stock] and [(price - sma(20))/sma(20) > 0.1)]

but the editor is not happy with the syntax.

2) I'm trying to create a scan that measures reversal in the dotted middle line that is plotted on a Bollinger (8,2) overlay, eg:

if I wanted to create a bullish scan based on the last three dots, let's say 1 being the latest dot and 3 the earliest of the three, the formula to detect a turn would be 1 > 2 and 2 < 3. Meaning a bottom "V" formation of the dots.

And a bearish scan would be 1 < 2, and 2>3, meaning an inverted V formation of the dots.

If anyone could suggest how to code that I would be very appreciative!


Best Answer

  • Options
    lmkwinlmkwin ✭✭
    Answer ✓
    What happens when you select the SMA from the dropdown in the workbench?

    [type is stock] and [(price - sma(20))/sma(20) > 0.1)]

    In your code, you are asking for a SMA20 but the scan engine doesn't know what the SMA20 is for? The price? Price is also something that you need to select from the dropdowns. Price is either a High, Low, Open, Close. You get to decide.

    When you use the dropdown and ADD the SMA code to your workbench it defaults to:

    and [SMA(50,volume) > 9999999]

    You can change the information here, for example, and [SMA(20,close)]

    For you crossover question, The middle of the Bollinger Band is a SMA line. You are asking for a crossover of the SMA 8 in your example.

    The below link should be an excellent resource for scan questions.


Sign In or Register to comment.