Conditional Script

Optuma Forums Optuma Scripting Conditional Script

Tagged: 

This topic contains 2 replies, has 3 voices, and was last updated by Matthew Matthew 7 months, 2 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #44419

    George
    • Topics: 3
    • Replies: 4
    • Posts: 7

    Hi 

    I have written a script to colour code chart bars but wish to enhance it so if I select a daily chart, it uses value A for MA and if it is a weekly chart, it uses value B for MA.

    The existing script uses value A for MA regardless if I am selecting Daily or Weekly charts.

    I have looked but unable to find a Chart function to specify which timeframe my chart is using to use a conditional or IF statement.

    Would be greatly appreciated if anybody has any tips or sample code I can look at that would help me accomplish this?

     

    Cheers

    George

    #44423
    Darren
    Darren
    • Topics: 25
    • Replies: 110
    • Posts: 135

    Hi George,

    It’s not possible to make a script conditional on the chart timeframe being used. However, it is possible to use scripts calculated on data from different time frames from the chart.

    For example, on this daily chart the red bars are when the weekly RSI(10) is above 70:

    RSI(Week(PERIODAMOUNT=1), BARS=10) > 70

    Capture

    #44439
    Matthew
    Matthew
    • Topics: 3
    • Replies: 67
    • Posts: 70

    Hi George,

    Further to Darren’s previous reply, I believe it maybe possible to setup a script which takes time frame into account. (This script requires the latest build of Optuma 64bit V1.2).

    Here is an example:

    TF = BARDATE() – BARDATE(OFFSET=1);
    $a = IF(TF == 7, 10,50) ;
    CLOSE() CrossesAbove MA(BARS=$a)

    In the above example the script will use a 10SMA for Weekly charts (ie when the BARDATE difference (TF) between consecutive bars is 7), and a 50SMA for any other time frame (when the value of TF is anything other than 7).  You maybe able to use a similar script to achieve the result you are after.

     

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

Pin It on Pinterest

Share This

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