Script Help – Keltner Bands

Optuma Forums Optuma Scripting Script Help – Keltner Bands

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #67103
    Mark
    • Topics: 5
    • Replies: 7
    • Posts: 12

    Hi, I need some help scripting this. I’d like to identify when price has CLOSED BELOW a Keltner’s upper plot and CLOSED ABOVE it’s average plot (middle line). I thought I might insert something like this into my other scripts but – doesn’t seem to be doing it:

    // Price Closing Above 21 EMA Average Keltner Band
    c1 = KC((Day(PERIODAMOUNT=1), BARS=21) >= 0, CALC=Close, STYLE=Exponential);

    // Price Closing Below 21 EMA Upper Keltner Band
    c2 = KC((Day(PERIODAMOUNT=1), BARS=21) <= 1, CALC=Close, STYLE=Exponential);

    c1 and c2

    #67119
    Darren
    • Topics: 70
    • Replies: 871
    • Posts: 941

    Hi Mark,

    By default the KC() function uses the upper line value in the output when nothing else is specified, so you need to select the centre line in one of the variables, along with the required CLOSE() condition.

    When creating a new script it’s best to start from scratch and use the pop-up boxes to build the formula as syntax from other scripts may not be relevant for what you are trying to achieve.

    This should do what you need:

    When used in a Show Bar tool the arrows highlight when both conditions have been met:

    Capture

    #67133
    Mark
    • Topics: 5
    • Replies: 7
    • Posts: 12

    Hi Darren,

    Is there any way to require both conditions to be met without having to use “Show Bar”? Reason I’m asking is that I’m trying to run a scan based on this script and open the results in a watch list – AND – to only have symbols appear in that watch list that have met BOTH conditions. I thought the last line (C1 and C2) would accomplish that but it doesn’t and using Show Bar doesn’t really help since I still end up with a watch list that contain a lot of results that don’t meet both conditions, and then I have to manually weed out all the incorrect results. How can this script be adjusted to eliminate those results?

    #67147
    Darren
    • Topics: 70
    • Replies: 871
    • Posts: 941

    Hi Mark,

    The Show Bar was used just to prove that the script is doing what you want it to do (it’s good practice to do this before running any tests and scans). So using the formula in a scan should return correct results.

    However, if you are getting incorrect scan results please let support know with examples and we will investigate further.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Pin It on Pinterest