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.

Scan to Hit off Multiple Timeframes

Hi -Is there a way for a single scan to hit off multiple time frames? Ex: Looking for certain criteria on a weekly but then also need other filled on a daily?

Comments

  • As far as I know, the scan engine will not give you an error for mixing time frames.

    You would have to keep in mind that (as far as I know) a scan run mid-week with weekly timeframe conditions will consider that day the end of the current week.

    So, you have to be clear in your own mind what what you are asking for, and how to interpret the results as a valid hit, and whether it is what you asked for.

    A way to keep it simple would be to run a scan for weekly conditions, but those conditions in a list, then run a daily scan against the list.
  • Disregard the above please but I do have a question on how to scan for something like the below. Note I'm currently using the standard scan bench, maybe I have to switch to the advanced one for some of this? I'm having trouble translating it to usable code (as I'm somewhat new to this). Would appreciate any thoughts/comments on the below.
    1. Rising 26 week EMA (26 period EMA close 0 weeks ago > 26 period EMA close 1 week ago).
    2. Falling 13 week EMA and falling MACD histogram 12,26,9 (looking to exclude this condition?)
    3. Price is currently between or below two moving averages, a 13 day EMA and 26 day EMA specifically.
    4. 13 day EMA is falling and MACD histogram rising or 13 day EMA rising and MACD histogram falling
    5. Two day force below zero
  • Thanks Mark, I didn't see your reply before posting my second thread here but that is a good point you make and I'll definitely keep it in mind. Curious if you have any suggestions/thoughts on my other note.
  • markdmarkd mod
    edited June 2018
    Well, you need a lot of "or" statements, which are tricky because you have to watch how you group the alternative or conditions with your brackets, and you have to group the compound conditions within the or statements.

    I'd be surprised if you could do it at all on the standard bench.

    I would recommend you work out the or logic first before writing any code. You could do that by setting up the brackets, then writing the conditions in plain english (meaning in pseudo code).

    So for price between or below the emas it might start like this:


    // begin example

    ....

    and

    [ // open btwn-blw

    // btwn

    or
    // blw


    ] // close btwn-blw

    ...

    // end example



    Then work out between.


    // begin example

    ...

    [ // open btwn-blw

    // btwn

    [ // open btwn

    [ price blw ema 1]
    and [price above ema 2]


    ] // close btwn



    or
    // blw


    ] // close btwn-blw

    ...

    // end example

    And so on.


    If you need help with syntax, here's a link to a previous answer with my quick and dirty summary of the rules:

    http://scan.stockcharts.com/discussion/comment/4308#Comment_4308


    If you get lost, post what you have and we'll work on it.
  • Thank you Mark, I appreciate it. Let me have a look into this and will get back to you with any concerns.
  • Hi Mark - I have completed all the conditions I specified above (all using "and" statements) but I am stuck on the moving average expression. Below is what I have thus far.

    and [[today's close is <= daily EMA(13, daily close) and today's close >= daily EMA (26, daily close) or today's close is <= daily EMA (26, daily close)]]

    I think my second "and" condition inside the brackets is throwing off the results, but I'm not sure how to fix it. Would be curious to get your thoughts on this?






  • markdmarkd mod
    edited July 2018

    I think this is what you want:

    and

    [

    [
    [today's close is <= daily EMA(13, daily close)]
    and [today's close >= daily EMA (26, daily close)]
    ]

    or

    [ today's close is <= daily EMA (26, daily close)]

    ]


    You have to put brackets around each condition - a condition means "term 1 - operator - term 2".

    Your formulation has several conditions inside one pair of brackets.


    Also, if you want two or more conditions to be evaluated together, you have to put an extra pair of brackets around them. In this case, your "between" statement requires that two conditions are both true, so they get an "extra" pair of brackets around them.

  • Thanks for all your feedback on this thread Mark. I really appreciate you working through this with me.
Sign In or Register to comment.