BARSTRUE Script

Optuma Forums Optuma Scripting BARSTRUE Script

  • This topic has 4 replies, 2 voices, and was last updated 1 year ago by Simon.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #59747
    Simon
    • Topics: 5
    • Replies: 10
    • Posts: 15

    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
    Matthew
    • Topics: 5
    • Replies: 430
    • Posts: 435

    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
    Simon
    • Topics: 5
    • Replies: 10
    • Posts: 15

    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
    Matthew
    • Topics: 5
    • Replies: 430
    • Posts: 435

    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 1 year ago by Matthew.
    #59755
    Simon
    • Topics: 5
    • Replies: 10
    • Posts: 15

    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