ArcTan Oscillator — A New Indicator For Technical Analysis

Image for post
Image for post

The following indicator is a normalized oscillator making use of the arc tangent sigmoid function (ArcTan), this allows to “squarify” the output result, thus visually filtering out certain variations originally present in the oscillator. The magnitude of this effect can be controlled by the user. The indicator contains a gradient that shows the possibility of a reversal, with red colors indicating that a reversal might occur.

The indicator script for Pinescript is shared in this post, you can also get the indicator here.

1. The Arctan Function

Image for post
Image for post

The arc tangent function (arctan) is a trigonometric function that has a characteristic “S” shaped, this is why the arctan function is a Sigmoid function. This function is also one of the many activation functions used in neural networks.

The useful characteristic of such function in technical analysis is that the arctan function will squarify any input going trough it, this effect will be more visible with inputs having a higher amplitude.

2. Settings

  • Length: Period of the oscillator
  • Pre-Gain : Changes the amplitude of the oscillator before passing through the ArcTan function, this allows to amplify/reduce the "squarification" effect introduced by this function. In order to make it easier for the user, the setting is in a (-10,10) range, with negative values reducing the amplitude and positive one increasing it.
  • Src : Source input of the indicator

3. Usage

The oscillator can be used to determine the direction of the trend by looking at its sign, if the oscillator is positive, market is up-trending, else down-trending, based on this usage the user might not be interested to look at every variations produced by the oscillator, this is where the hyperbolic tangent function and pre-gain setting can be useful, by using an high value of pre-gain the user will be able to only focus on the sign of the oscillator.

Image for post
Image for post

Here pre-gain is set to 5, we can see that the oscillator is now easier to visualize. However, the use of sigmoid functions remove useful information for a trader that needs to find divergences, this is where using a negative value of the pre-gain setting will result useful.

Image for post
Image for post
Here pre-gain is set to -5.

The indicator makes use of a gradient to show potential reversals, this gradient is determined by the correlation between the oscillator and the price (this is a way to measure potential divergences). If the color is closer to red it means that a potential reversal might occur, it is possible to say in which direction price might go by looking at the sign of the oscillator, so if the gradient is red and the oscillator is negative price might rise. The gradient is not affected by the pre-gain setting.

Image for post
Image for post

4. Code

// This source code is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo
//@version=4
study("ArcTan Oscillator","ATO")
length = input(25)
pg = input(0,"Pre-Gain [-10,10]",minval=-10,maxval=10)
src = input(close,"Source")
//----
grad(os) => os < 10 ? #ff1100 : max(os,10) < 20 ? #d12033 :
max(os,20) < 30 ? #bd2649 : max(os,30) < 40 ? #a72d61 :
max(os,40) < 50 ? #913479 : max(os,50) < 60 ? #743d99 :
max(os,60) < 70 ? #5945b6 : max(os,70) < 80 ? #494ac7 :
max(os,80) < 90 ? #3750db : #2157f3
//----
ma = sma(src,length)
z = (ma - sma(ma,length))/stdev(ma,length)
os = atan(z*(pg <= 0 ? exp(pg) : pg*2))
cor = correlation(src,os,length)
//----
plot(os,"Reversal Potential",color = grad((.5*cor+.5)*100)
,style=plot.style_area,transp=30)
plot(os,"Osc",#0a0032,2)

Written by

Lux Algo aims to provide traders with truly useful, unique, & reliable tools that can give them an edge over others in any market.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store