An indicator that references two specific securities

Optuma Forums Optuma Scripting An indicator that references two specific securities

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #63741
    AvatarDan
    • Topics: 1
    • Replies: 0
    • Posts: 1

    I am looking to build an indicator that references two securities.
    For example,
    A percent rate of change, weekly for 4 time periods of CPER (US) minus percent rate of change, weekly for 4 time periods of GLD (US)
    If CPER is greater than GLD, even if both are negative, this should still be a positive number.

    The values could be a positive or negative number

    I would like it plotted as an indicator in two ways:
    1.Multi-plot shading…….can these values be plotted, something like a Kuomo Cloud?
    If CPER percent change is greater than GLD, then the cloud would be green; if CPER percent change is less than GLD, then the cloud would be red
    The cloud would be expand/contract based on values of percent ROC minus percent ROC

    2. Green or red ribbon
    Here, there would be no values, simply….the ribbon would be green if CPER percent ROC > GLD percent ROC
    or red, if GLD percent ROC > CPER percent ROC

    Also, to show how the coding is different for weekly values as opposed to daily, can I see:
    ROC based on daily charts, with a ROC of 30 days?

    Thanks

    #63752
    MatthewMatthew
    • Topics: 5
    • Replies: 366
    • Posts: 371

    Hi,

    There are actually two scripts that would be needed to do this.  One to set the value and one to control the colour.

    As we are only working with a single value (the difference between the two ROCs) a shaded ribbon does not really work well.  A shaded zone usually needs two reference points, so i have used a Histogram in my example.  If you were planning to have the individual ROC values as plots on the script as well as the change, a ribbon may work, what i’ve provided below should give you the foundation you need to build the display style you are after.

    The script to find the ROC variation between the two codes would be:

    Applied using a Show View, the Plot Style needs to be set to Histogram and the Colour scheme set to Custom.  This will allow us to setup the second script to control the colour so that the bars are green whenever the ROC for CPER is higher than that of GLD.

    Set the colour for this script to be green and the default colour to be red, and it will display the expected result.

    Ex7

    I’ve attached a workbook sample you can reference.

    Regarding the time frame and ROC periods, these can be changed in the script.  Time frames via the Data1 and Data2 variables, and the ROC period via the V1 and V2 variables.

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

Pin It on Pinterest