> For the complete documentation index, see [llms.txt](https://docs.flightwatching.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flightwatching.com/user-manual/designer-user-manual/examples/use-algorithm-on-trends.md).

# use algorithm on trends

trends are the time-series that can return raw values and the algorithms

For example, we would like to create the trend that returns the raw and the smoothed value of the parameter. In order to get the smoothed value, we're going to use the code that [accesses to the surrounding values](/user-manual/designer-user-manual/edit-trends/trends/access-to-the-surrounding-values.md).

Start [creating new trend](/user-manual/designer-user-manual/edit-trends/create-new-trend.md); and add a raw value of some parameter:

<div><figure><img src="https://4203901285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LucrvGdSn3RONbIcfqh%2Fuploads%2FfM6Megj6i8OnFk4xg8uq%2FScreenshot%202024-01-30%20at%2014.06.05.png?alt=media&amp;token=7d7ad99f-04f6-4ae8-b245-948e7d0e0961" alt=""><figcaption></figcaption></figure> <figure><img src="https://4203901285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LucrvGdSn3RONbIcfqh%2Fuploads%2FNqnuf3DyoMO4jyDm72zn%2FScreenshot%202024-01-30%20at%2015.20.18.png?alt=media&amp;token=a350e2b7-e860-429e-9a36-28afa34b40be" alt=""><figcaption></figcaption></figure></div>

Now, add the smoothed value, using the [algorithm](/user-manual/designer-user-manual/edit-trends/trends/access-to-the-surrounding-values.md):&#x20;

`getAround(name, countBefore, countAfter)`

<div><figure><img src="https://4203901285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LucrvGdSn3RONbIcfqh%2Fuploads%2FTbviSGes80Bzej0QNBKa%2FScreenshot%202024-01-30%20at%2015.22.48.png?alt=media&amp;token=d80fefbd-eab3-41bd-8dbe-274cc1afe31f" alt=""><figcaption></figcaption></figure> <figure><img src="https://4203901285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LucrvGdSn3RONbIcfqh%2Fuploads%2FlX4b0hLqw3x2PwDhAqUK%2FScreenshot%202024-01-30%20at%2015.23.23.png?alt=media&amp;token=e206c359-7a7b-4ce5-837c-892c3307bdd0" alt=""><figcaption></figcaption></figure></div>

The smoothed values shows up in orange at the image above.

For the calculation of smoothed value, we could take into account another factors, for example we wouldn't like to have taken into account value of the parameter lower than 300 and the ones that were triggered in flight. The improved smoothed value would be the green line below:

<div><figure><img src="https://4203901285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LucrvGdSn3RONbIcfqh%2Fuploads%2FDse5iapkjNCnstXYgfm0%2FScreenshot%202024-01-30%20at%2015.27.33.png?alt=media&amp;token=25916bd8-746e-4a6a-813f-53d5a9cb4fff" alt=""><figcaption></figcaption></figure> <figure><img src="https://4203901285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LucrvGdSn3RONbIcfqh%2Fuploads%2FmU2YOJShWO8LvgesBFGI%2FScreenshot%202024-01-30%20at%2015.29.27.png?alt=media&amp;token=69a827e3-a598-476d-a369-6139f663a0e6" alt=""><figcaption></figcaption></figure></div>

In our case, that did not change much :smile:
