Custom Code MIN(a,b) formula

Optuma Forums Optuma General Discussion Custom Code MIN(a,b) formula

Tagged: ,

This topic contains 1 reply, has 2 voices, and was last updated by Darren Darren 2 years, 3 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #28943
    Avatar
    Andy
    • Topics: 11
    • Replies: 10
    • Posts: 21

    Hi. I am trying to bound a value in a custom code (could be in a script also). I’m attempting to bound the top value plotted to 35. This doesn’t work but should provide the algorithm I am trying to implement.

    MIN(SPX:WI, 35) … to print the SPX value or 35 if SPX is higher than 35.

    Of course, this does not make sense to bound the SPX to at high of 35 – but it is just a simple example.

    Thanks. Andy

    #28987
    Darren
    Darren
    • Topics: 36
    • Replies: 211
    • Posts: 247

    Hi Andy,

    You can use an IF(condition, value if true, value if false)  statement for this, ie if SPX < 35 use SPX value, else use 35.

    IF(CLOSE() < 35, CLOSE(), 35)

    Here is an example of a watchlist column that uses the highest value between the closing value and the 13 period exponential moving average, using the following formula:

    EMA13 = MA(BARS=13, STYLE=Exponential, CALC=Close);

    IF(CLOSE() > EMA13, CLOSE(), EMA13)

     

    Capture1

    For a video on using IF statements sign in to the scripting course here and watch Lecture 5:

    Intermediate Scripting

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