Using the BARSTRUE function

Optuma Forums Optuma Scripting Using the BARSTRUE function

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #42911
    DarrenDarren
    • Topics: 63
    • Replies: 557
    • Posts: 620

    The BARSTRUE function calculates how many times a condition is true over a given lookback period. In this example, we want to know when the low price has crossed the 13period EMA for the first time in 10 days. To do this we can create 2 variables, one for the crossover and one for the barstrue lookback, and then return the result when both are true:

    In the c2 condition we’re looking at 10 bars prior to the crossover (c1) where the low is above the 13EMA every day, so == 10 (remember to use the ‘==’ for equality).

    Capture

    If you wanted to look back 20 days and know when any 15 days out of the 20 are above the 13EMA you would use the following for c2:

    c2 = BARSTRUE(LOW()[1] > MA(BARS=13, STYLE=Exponential)[1], LOOKBACK=20) == 15;

    • This topic was modified 3 years, 4 months ago by DarrenDarren.
    #62515
    DarrenDarren
    • Topics: 63
    • Replies: 557
    • Posts: 620

    Tom McClellan’s 9 Day Up-Down Oscillator (as seen here) can be calculated with the following BARSTRUE() function:

    Turn it in to a boolean (ie MA(V1, BARS=3, CALC=Close) > 70) to colour the bars. Workbook attached.

    Capture

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

Pin It on Pinterest

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close