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.
Options

Scanning for candlesticks with small bodies

Hello everyone!

Long time since I've posted. I'm trying to create a scan that looks for candlesticks where the body only compromises 30% or less of the total trading range for that day. I thought I had the scan written correctly, but I am getting non-sensical results. Does someone feel like taking a gander at the code:

// Absolute value open / close range is less than 30% trading range

and [ AbsVal (today close - today open) < [ [today high - today low] * .3] ]
and [ AbsVal (yesterday close - yesterday open) < [ [yesterday high - yesterday low] * .3] ]
and [ AbsVal (2 days ago close - 2 days ago open) < [ [2 days ago high - 2 days ago low] * .3] ]

Any help would be appreciated. Thanks!

Comments

  • Options
    markdmarkd mod
    edited May 2018
    The first statement works correctly. The next two pass syntax but don't return the expected results.

    It appears that the AbsVal() function is ignoring the "yesterday" and the "2 days ago" modifiers, so that the results getting returned come from a comparison of the difference between today's open and close and yesterday's and 2 day ago's high and low.

    The way around this is to write 'or' statements that account for the possibility of a positive or negative or zero result from close - open, and then comparing the high and low. Watch your brackets.

    and

    [ // day one

    [ // positive, zero

    [ close - open >= 0]
    and [close - open < range * .3 ]

    ] // end positive, zero

    or

    [ // negative

    [close - open < 0]
    and [ [close - open] * [-1] < range * .3]

    ] // end negative

    ] // end day one

    and

    [ // day two

    [ // positive, zero

    [ 1 day ago close - ... etc.
  • Options
    Ah, forgot about the range function. That really helps. Thanks!
Sign In or Register to comment.