Close
Skip to content

Tutorial 172 | Missing bar correlation using a PSP

Tutorial172-1

Tutorial 171 demonstrated how to create a correlation indicator for data pairs where one of the data pairs has ‘missing bars.’ For example, for symbol 1 (data1) trading might have occurred on every bar during the trading session. Symbol 2 might be more thinly traded and hence it doesn’t have trading activity on every bar.

Tutorial 172 modifies the tutorial 171 program so that instead of using Data2, the equivalent data is taken from a Price Series Provider.

The tutorial 172 indicator is applied to a 5 min A chart. The second symbol's data is provided through a price series provider.
The tutorial 172 indicator is applied to a 5 min A chart. The second symbol’s data is provided through a price series provider.

What is the correlation coefficient?

The correlation coefficient is a number between -1 and 1, which measures the degree to which two data series are linearly related. A perfect linear relationship with positive slope gives a correlation coefficient of 1. If there is a perfect linear relationship with negative slope between the two data series, the correlation coefficient of -1. A correlation coefficient of 0 means that there is no linear relationship between the data series. The normal correlation function works by counting back bars in both data series and checking if they are both going up or both going down. The problem is that, because some bars are missing in one of the data series the program is comparing bars with potentially different time signatures.Callout Text

Tutorial 172 analyzes the data to create two arrays. Data1 bars that do not have a corresponding Data2 bar are excluded from the array, and vice versa. The standard CorrelationArray function then processes the two arrays to calculate the correlation.

Tutorial 172 can be used with TradeStation but NOT with MultiCharts. It is designed for minute bars. Processing takes place at the end of each bar. In order to avoid potential infinite loop warnings, two of the counters have been limited to be a maximum of 100 (see video for further explanation)
See a video walk through of tutorial 172

Download the tutorial 172 TradeStation EasyLanguage indicator

If you want to save yourself some typing,  the tutorial 172 code is available for immediate download for $19.50 by clicking the following button. You can pay using PayPal or credit card. The program works with TradeStation 9.5 and 10. 

The download consists of _Tutorial172 (the TradeStation EasyLanguage indicator developed in the tutorial).

THE TRADING APPS, INDICATORS, SHOW ME STUDIES, STRATEGIES AND OTHER PROGRAMS HAVE BEEN INCLUDED SOLELY FOR EDUCATIONAL PURPOSES.

TO THE BEST OF MARKPLEX CORPORATION’S KNOWLEDGE, ALL OF THE INFORMATION ON THIS PAGE IS CORRECT, AND IT IS PROVIDED IN THE HOPE THAT IT WILL BE USEFUL. HOWEVER, MARKPLEX CORPORATION ASSUMES NO LIABILITY FOR ANY DAMAGES, DIRECT OR OTHERWISE, RESULTING FROM THE USE OF THIS INFORMATION AND/OR PROGRAM(S) DESCRIBED, AND NO WARRANTY IS MADE REGARDING ITS ACCURACY OR COMPLETENESS. USE OF THIS INFORMATION AND/OR PROGRAMS DESCRIBED IS AT YOUR OWN RISK.

ANY EASYLANGUAGE OR POWERLANGUAGE TRADING STRATEGIES, TRADING APPS, SIGNALS, STUDIES, INDICATORS, SHOWME STUDIES, PAINTBAR STUDIES, PROBABILITYMAP STUDIES, ACTIVITYBAR STUDIES, FUNCTIONS (AND PARTS THEREOF) AND ASSOCIATED TECHNIQUES REFERRED TO, INCLUDED IN OR ATTACHED TO THIS TUTORIAL OR PROGRAM DESCRIPTION ARE EXAMPLES ONLY, AND HAVE BEEN INCLUDED SOLELY FOR EDUCATIONAL PURPOSES. MARKPLEX CORPORATION. DOES NOT RECOMMEND THAT YOU USE ANY SUCH TRADING STRATEGIES, SIGNALS, STUDIES, INDICATORS, SHOWME STUDIES, PAINTBAR STUDIES, PROBABILITYMAP STUDIES, ACTIVITYBAR STUDIES, FUNCTIONS (OR ANY PARTS THEREOF) OR TECHNIQUES. THE USE OF ANY SUCH TRADING STRATEGIES, SIGNALS, STUDIES, INDICATORS, SHOWME STUDIES, PAINTBAR STUDIES, PROBABILITYMAP STUDIES, ACTIVITYBAR STUDIES, FUNCTIONS AND TECHNIQUES DOES NOT GUARANTEE THAT YOU WILL MAKE PROFITS, INCREASE PROFITS, OR MINIMIZE LOSSES.