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.

How do you WRITE a Scan using the moving average of an indicator, as in, the moving average of RSI

I want to write a scan to catch what I see on my charts, which is the Crossover ( X ) of an Indicator, above a specific moving average, in this case KAMA, to assess volitility? Seems there exists no instruction for that that I have been able to find............Thanks in advance for any light shed upon this subject.....DG


  • markdmarkd ✭✭✭
    edited February 23
    The sma and ema functions will both take an indicator as the second term inside the parentheses. So, for instance

    and [sma(10, RSI(14)) x sma(50, RSI(14))]

    is a valid statement.

    For KAMA, it is undocumented as far as I can tell, but it appears you can just add the indicator as a fourth term to the KAMA function, so for instance this line:

    // KAMA of indicator crosses above indicator
    and [KAMA(10,2,30, RSI(14)) x RSI(14)]

    passes syntax.

    It may be that the syntax checker isn't coded to check for this, and it's not valid, but give it a try. The charts are coded to include KAMA with indicators, so maybe the scan engine is, too.
    If this doesn't work, you might email a suggestion to support asking for a blog feature to explain how it's done.
  • Thanks markd. I've been searching the forums and help for how to do something like that but in regards to the full stochastics overlay on the force index. I didn't try the comma before but, it appears to work. Thank you. You are a treasure of information.
  • markdmarkd ✭✭✭
    edited February 23
    Thanks for your comments as well! Always informative.

    Interesting idea to apply Stochastics to Force. Never thought of that.
  • The stochastic shows continued potential opportune times on the Force indicator if the original MA cross on Force wasn't fully supported by the rest of the chart (story). I use the same stochastic time frame that I used for the MA cross.
  • Thanks that worked really well, but always UNINTENDED Consquences then pop up.
    As a result I want to figure how to find X's or cross overs that are less then 4 days old, and add that to my "X over" phrase. Any Input?
  • markdmarkd ✭✭✭
    I would keep it simple and adjust the start date of the scan for the number of days back that you want to go.

    Presumably you want to run the scan every day, so if the scan looks for things several days back then your results each day will include symbols you have already seen.
  • just to the extent of a 1-4 interval (mkt days), so likely given the scope of the scan, new entrants will show up as well.....
  • am searching for how you would write that start date. Rather, I'd like to include a phrase that defines a window, at least or in addition
  • markdmarkd ✭✭✭
    You change the scan's run date using the calendar tool above the Advanced Scan Workbench Scan Criteria window, where it says "Starting 0 days...". Click on the 0 and choose a run date.

    If you want to code it in, it would be an "or" statement


    [KAMA(10,2,30, RSI(14)) x RSI(14)]

    or [1 day ago KAMA(10,2,30, RSI(14)) x 1 day ago RSI(14)]

    or [2 days ago... ]


  • the problem is with this error msg about not being able to parse some item like this. here is the body:
    [type is stock]
    and [region is NorthAmerica]
    and [Close > .10]
    and [group is NOT ETF] and
    [ RSI(13) x sma(10, RSI(13)

    now here is the Error Msg:
    Could not parse "(13" located in the clause "SMA(10, RSI(13)" (an integer was expected)

    have spent a lot of hours trying to resolve it but i must be blind cz try as I may differing approaches and others work as well, I cant seem to get past it...........

    TIA, DG
  • markdmarkd ✭✭✭
    edited March 1
    SMA is an indicator that requires two parentheses - a left parenthesis to open and right parenthesis to close.

    RSI also requires two parentheses.

    So, when you put RSI inside SMA, you should have two complete sets of parentheses (or four total, two left and two right).

    The error message says an integer was expected, but that is misleading. Most of the time, the error messages correctly locate where the error is, but only sometimes correctly identify the error. A more helpful error message would have been "the sma indicator or the rsi indicator is incomplete", meaning the second parenthesis from one of them is missing.
  • thank you for the info on the "misleading error msg" I will work on parenthesis placement, and thanks again, sorry to be so long in gettin back here, been creating "work-arounds" to bypass the issue, which have worked. Thanks DG
Sign In or Register to comment.