Send an Invite      Sign in   
Tuhunga logo
Sign up now

Finding trend changes

Written by Jason on October 13, 2010

As we’ve written about previously, Tuhunga can help find patterns in data series and alert users when they occur. We originally started discussing this topic here using foreign exchange rates. Also, tutorial #3 discusses how to build a monitoring system that alerts you when your custom criteria are met.

Today, we’re going to take it a step further and build an alert system that is triggered not off a level, or a change in the level, but a change in the trend. We’re also going to look at evaluating performance after the trigger event on a historical basis.

We’ll use the same daily foreign exchange data to search for what technical traders call the “golden cross.” That is, where a shorter-term moving average rises from beneath a longer-term moving average to above it, and is often considered a bullish sign. However, you don’t need to be an FX whiz to benefit from this kind of application – businesses with currency exposures can also benefit from understanding this trend to minimize costs.

We’ll demonstrate two applications today:

  1. Examine the Euro’s performance after a golden cross. We will determine the performance of the Euro against the US Dollar after a golden cross occurs using 30-day and 60-day moving averages.
  2. Automate detection of golden crosses going forward. We will want to receive notification of the event so we don’t need to keep checking for the event ourselves.

For this example, we’ll look for crosses from the beginning of 2008 through present, during which there have been eleven crosses:

Using these moving averages, over this period at least, the golden cross has been an effective indicator that the average exchange rate after a golden cross is higher, with 9 out of 11 trials in both one-week and four-week future periods higher than the day of the cross.

Everything we’ve done here can be modified to search for other indicators with stronger metrics and, of course, can also be applied in reverse on “death crosses” as well – which are the reverse of the golden cross.

After the jump, we’ll provide the filter and report details we used to construct the output, as well as how to configure Tuhunga to monitor the data so you receive an alert when there’s another cross.

Filter:

  • Date>="Jan 1, 2008"
  • back_mean(EURUSD,29,-1,Date,1)>back_mean(EURUSD,59,-1,Date,1) (keep results where the 30-day trailing average including today, is greater than the 60-day average)
  • back_mean(EURUSD,30,0,Date,1)<back_mean(EURUSD,60,0,Date,1) (keep results where the prior day’s 30-day trailing average is less than the 60-day average)

Report:

  • Date
  • EURUSD (Current rate on the date)
  • (forward_mean(EURUSD,7,0,Date,1)/EURUSD-1)*100 (change from today to the mean over the next week, in percent)
  • (forward_mean(EURUSD,28,0,Date,1)/EURUSD-1)*100 (change from today to the mean over the next four weeks, in percent)

Once the filter and report have been built, we’ll automate the monitoring in two steps:

  1. Save the filtered data into a saved slot (under advanced options)
  2. Now that the “base” result set has been saved, we’ll run an incremental filter using the data we just saved – i.e., find data that matches the filter’s criteria AND is not in the saved slot. To ensure that our master list of data is maintained, incrementally (checkbox underneath the list) save the filter’s results back in the same slot.

To see this illustrated graphically, check out this portion of tutorial #3.

One last note on the embedding of this table – there are eleven rows, while the default embedded table only displays ten. To customize the number of rows that are displayed, add the following bit of text to the end of the link in the embedded table:

  • &rows={# of rows to display}

Using this option will also remove the user’s ability to change the number of rows to display. If you’d like to continue to allow them to change the option, add &userrows after the the previous number of rows to display. These configuration options are also explained on the “Share” portion of your results.

e.g., for this example, our link to display the eleven rows was:

  • http://app.tuhunga.com/embedtable?keysr=7251e395ff902836&rows=11

Tags: analysis, examples, tables


  About    Contact    Legal    Privacy    Follow us on Twitter  

© 2009 - 2013. All Rights Reserved.