BARSTRUE Script

Optuma Forums Optuma Scripting BARSTRUE Script

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #59747
    AvatarSimon
    • Topics: 4
    • Replies: 7
    • Posts: 11

    I am having trouble with BARSTRUE so that every bar for custom indicators is below 1.00 for the last 10 bars. So far I have below but is not performing correctly. Can someone please assist? Thanks

    #59748
    MatthewMatthew
    • Topics: 5
    • Replies: 292
    • Posts: 297

    Hi,

    R1 in your example needs to be a Boolean result before it can be used with the BarsTrue function.

    Quick example code:

    The result on a Show View would look like this:

    Ex2
    You can see the highest result returned was 4 out of 10 days R1 was true.

    #59749
    AvatarSimon
    • Topics: 4
    • Replies: 7
    • Posts: 11

    Apologies, should of mentioned this is for a scan so wouldn’t I need to implement:

    as I am also not sure how to add Boolean to a MA script like:

    #59752
    MatthewMatthew
    • Topics: 5
    • Replies: 292
    • Posts: 297

    In your first script example, that scan would only return a pass if the number of bars that met the criteria over the last 10 days was zero.

    If you look at the example in my reply you can see that the BarsTrue (when using a look back period of 10) will procedure a result that oscillates between 0 and 9.  A result of zero means none of the bars checked passed the criteria, and 9 means all bars checked passed the criteria.

    For the simplest example, set the criteria to be Close() > Open() and use that with BarsTrue(), the output will change between 0 to 9.

    Ex3

    To use it with a scan i’d just need to adjust the BarsTrue line to output a Boolean result.  For example:

    Would mean the criteria would have to have passed 5 out of 10 bars to pass.

    With your second script, the line would output the Moving Average value.  To convert it to a Boolean you have to setup a rule.  I’m not sure what you’re looking for but some common examples are

    or

    Anything that returns a 1 or 0 result will work with BarsTrue()

    https://help.optuma.com/kb/faq.php?id=1118

    • This reply was modified 2 weeks, 4 days ago by MatthewMatthew.
    #59755
    AvatarSimon
    • Topics: 4
    • Replies: 7
    • Posts: 11

    GOT IT! Thanks so much

Viewing 5 posts - 1 through 5 (of 5 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