Chart Elements

Optuma Forums Optuma Scripting Chart Elements

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • #55499
    • Topics: 2
    • Replies: 4
    • Posts: 6

    Hey guys,

    I was wondering if someone can point me in the right direction, I would like to have an indication on a Chart using  something like a chart element True/False box, that will show a percentage of how far +/- the current close is from my buy price.

    I have been playing with chart elements but i can’t work out how to achieve this. I can get fields from fundamental data, that change as I bring up a new code (I have saved a page layout for this) but what I would like to do is have a single stock fixed to its buy price if that makes sense.

    I apologise if I’m not explaining my self very well. But essentially I would like something that is easily visual on the chart without having to go back to a watch list or my P & L to reference the % of change.

    I have also tried with price alert, but would like to visually clear up the chart so I don’t have lines and markers all over the place, just a neat box on the corner with the info in it.

    Any help would be great


    AvatarTrevor R
    • Topics: 95
    • Replies: 276
    • Posts: 371

    Hi Raeburne,

    If I understand you correctly, you would like a script or Tool in which you can set your buy price and then have the ± percentage difference to the current close price displayed using a Chart Element.

    The primary issue I see is your requirement is that there is, to my knowledge at least, no Scripting function that will allow the entry of a price through the Properties of the Script, without opening and changing a variable value within the script code itself – not a desirable necessity.

    What you desire can be done reasonably easily using a Optuma Pascal Custom Tool, but that means you need the Optuma Programming Module and a knowledge of Pascal, which I’m assuming from the nature of your question you do not have.



    The Auld Tyma at

    Auld Tyma Data Logo with URL 1 cm


    • Topics: 4
    • Replies: 13
    • Posts: 17

    Heres my code I use for a stop loss.  Maybe you can use this as your starting point and instead of the stop price it’s your buy price.

    I made a user defined script for the Stop Level and then use DATAFIELD to pull those numbers in.


    Script Name: Price vs Stop

    (LAST() – DATAFIELD(FEED=UD, FIELD=Stop_Level) )/ LAST()

    • Topics: 32
    • Replies: 1,601
    • Posts: 1,633

    Hi Raeburne,

    One thing to look at is User Defined Fields in a Watch list. What you can do is have a watchlist with all the codes you have a position in and then in the Watchlist type in your buy price.

    That User Defined Fields is then available in scripting like any other fundamental field and you can script against that using the DataField() function.

    Matt Humphreys did a couple articles on this – have a look at this and let us know if that does not do what you need.

    Hope that helps


    • Topics: 32
    • Replies: 1,601
    • Posts: 1,633

    The second part of his post covers the scripting with the fields.

    • Topics: 2
    • Replies: 4
    • Posts: 6

    Thanks everyone for your help, really appreciate the assistance.

    I’ll have a look and work through the articles Mathew has posted and see how I get on.



    • Topics: 5
    • Replies: 317
    • Posts: 322

    Hi Raeburne,

    One additional note, if you have access to the current v1.5 beta, there is a new script function available called NEARESTALERT() which maybe of use to achieve the result you are after.

    If your buy price is setup in your Alerts you can now make reference to it in scripting.

    Here is an example using the Chart Element tool:


    You can see the Close is 1.31% away from the Alert line.  The script used for this was:

    For more information on this feature please refer to the following article:

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