#twitter-follow { border: 0;position: fixed; top: 240px; left:0;} #live-support { border: 0;position: fixed; top: 370px; left:0;} #knowledge-base { border: 0;position: fixed; top: 170px; left:0;}

## Chi Squared Indicator

by Brian Brown, 3931 days ago

The Chi-Squared is a widely used statistical hypothesis test to determine whether observed results are significantly different from expected results or not.

In trading, we can use the Chi-Squared test to determine how meaningful or statistically significant the performance that follows a specific pattern is.

Let us for example say that our pattern, which is the crossover between the price and its moving average, produces a positive return average over the next one-bar.
We would like to test whether this has occurred by chance or not.

Here, we can use the Chi-Squared test to determine the confidence level (that the return following our pattern is positive). The higher the confidence level, the less likely our result occurred by change.

How to use The Chi-Squared function in a chart:

a = cross(close, sma(10));
b = ChiSquared(a, 0, 1);
plot(b, "");

Parameters of the "ChiSquared" indicator:
1: Pattern to test
2: Threshold. The pattern is compared with this threshold. Example: cross(close, sma(10)) > 0 or Not
3: The number of bars to calculate the future performance. Set 1 to calculate the next bar's performance.

In a trading system, you can type the following formula to buy on crossover only when the Chi-Squared result based on previous crossovers is high (less likely that it was occurred by change):

a = cross(close, sma(10));
chi = ChiSquared(a, 0, 1);
chi = chi[1]; // We reference the previous chi result here because the calculation uses one bar in the future

buy = a and chi > 5;

Or you can purchase on crossover while ranking stocks based on their Chi-Squared result:

a = cross(close, sma(10));
chi = ChiSquared(a, 0, 1);
chi = chi[1];
SetSimLongRank(chi);

What is this?

 Type: Trading Indicator Object ID: 1387 Country: All Market: All Style: Technical Analysis

 Related objects Empty
Number of reviews
Average rate
Click to rate this item
Number of rates the current object received
Report an object
if you can't run it for example or if it contains errors
Click to report this object

 Random Blog Posts Custom Shortcuts - Move a Chart to Display the Last Quotes/Data Export Trading Orders from a Portfolio to a File Backtesting Your Trading Systems: Symbol Segmentation Update Chart Layout based on Active Time Frame Presentation of QuantShare's new Real Time Version Charting, Backtesting and Trading using Fundamental Data Different Ticker Symbols for Each Data Source How to Automatically Import Local Data Into QuantShare Show All

Number of reviews
Average rate
Click to rate this item
Number of rates the current object received
Report an object
if you can't run it for example or if it contains errors
Click to report this object