A New Way to Speed up Your Scripts

by Oct 22, 2021All Articles, Technical Analysis, Education

One of the benefits of the Optuma Scripting Language is the flexibility it gives the user to create their own tools, scans, backtests, and analysis columns. However, because of the flexibility it can mean that some script formulas that require a lot of data to be calculated can cause a slow down in performance – particularly when using large watchlists and lots of columns.

One example we’ve seen a few times are scripts that require a lookback over a certain period, such as to find the all-time high price. For that value to be calculated in a watchlist it has to load all the data for all the symbols in the list, so if a stock has been trading for 20 years at 260 days a year that’s 5,200 prices that have to be loaded and compared to the latest price – or 2.6 million data points for all the S&P500 members (I think you can see where I’m going…).

Unless you have a new computer with plenty of RAM then adding just a few of these columns to a large list can significantly slow your system down, and in the worst cases Windows will run out of memory and close the software.

To solve this problem we now calculate a number of these values for you so that they don’t have to be calculated by your computer – therefore reducing the amount of processing required and improving performance.

If you have Fundamental Data enabled for your equity exchanges (such as ASX, US, or TSX) then you can now use the following data field options in a watchlist and script formulas:

  • All Time High Price
  • All Time High Date
  • All Time Low Price
  • All Time Low Date
  • Year High Price
  • Year High Date
  • Year Low Price
  • Year Low Date
  • 6 Month High Price
  • 6 Month High Date
  • 6 Month Low Price
  • 6 Month Low Date
  • Quarter High Price
  • Quarter High Date
  • Quarter Low Price
  • Quarter Low Date
  • Month High Price
  • Month High Date
  • Month Low Price
  • Month Low Date
  • Week High Price
  • Week High Date
  • Week Low Price
  • Week Low Date
  • Year Average Volume
  • Quarter Average Volume
  • Month Average Volume
  • Year Percent Change
  • Quarter Percent Change
  • Month Percent Change
  • Week Percent Change
To add the Fundamental Data option to your equity exchanges sign in to the Products section of your Account Page ‌‌ and click Modify Exchanges. To see what else is included in the Fundamental Data (such as sector and market cap) click here ‌‌. If you have any queries, please contact Support ‌‌.

To add the data to a watchlist click the + icon and use the search box to filter the list (eg ‘all time’) and they will be listed under the Fundamental Field section.

One watchlist we were testing with used 31.5Gb of memory using the old way to calculate multiple columns and took 3 minutes to open for the S&P500. When we changed the columns to use the new data fields the memory usage was reduced to 2.86Gb and opened in less than 30 seconds.

 

Using the Datafield() Function

 

To use these values in a scripting formula (for example to show how far the last close is from the all-time high) use the DATAFIELD() function rather than the HIGHESTHIGH(Range=All Time) function.

This example will calculate the percentage from the all-time high:

TIP: click on the text to select the required data from the Field option from the properties window (use the search box to filter) and be sure to tick the Latest Value Only box so prevent all the historical data from being loaded.

Here’s a watchlist example showing the all time high date and price using the new data fields, and the % Below ATH column using the above formula (the all time high price is also plotted on the chart).

Clients with access to the Australian or US equity and fundamental data can click the buttons below to save and open watchlist examples.

As always, leave any comments below, or contact support if you have any issues or queries.

Share Link
Darren Hawkins, MSTA

Darren Hawkins, MSTA

Senior Software Specialist at Optuma

Darren is the senior Software Specialist at Optuma. He joined the company in 2009 after attending an introductory technical analysis course. Darren now instructs users all over the world, from experienced Wall Street traders and professional money managers to individual traders drawing their first trendlines.

Darren grew up in the UK and attended college in the USA where he earned a BA in Economics from St Mary's College of Maryland. He went on to spend a few years working at the Nasdaq Stock Market in Washington DC. Going on to live and work in Australia, the US and currently the UK, Darren has a broad understanding of the individual needs of traders, portfolio managers and investors utilising a wide range of methodologies.

In 2014 Darren passed the UK-based Society of Technical Analysts diploma course, and when not looking at charts he keeps a keen eye on England's cricket team - especially if they are playing against Australia. He lives in the Essex countryside in England, with wife Wendy and their labrador, Gabba.

4 Comments

  1. Angelo Barrea

    Hi Darren

    Would it be possible to add a fibbonaci retracement tool to apply on zig zag formations? or too big a job.

    Reply
    • Darren Hawkins, MSTA

      Hi Angelo – you can enable the retracement labels for swing overlay tools (eg Gann Swing, Percentage overlays). If that’s not what you mean please post on the Feature Request forum.

      Reply
  2. Trevor R Bird

    Hi Darren,

    You mention that the data fields list work with equities – do they also work with continuous futures contract charts like SBVolSpot and the Gann data sets?

    Cheers

    Reply
    • Darren Hawkins, MSTA

      Hi Trevor – this only works for equities data. Continue to use the HighestHigh lookbacks for futures contracts.

      Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Blog Signup

Pin It on Pinterest

Share This