This post is also available in my blog. In finance, technical analysis is an analysis methodology for forecasting the direction of prices through the study of past market data, primarily price and volume. Technical analysts rely on a combination of technical indicators to study a stock and give insight about trading strategy.

Here is a list of technical indicators. In a previous storyI talked about how to collect such information with Pandas. Bollinger Bands is used to define the prevailing high and low prices in a market to characterize the trading band of a financial instrument or commodity. Bollinger Bands are a volatility indicator. Bands are consists of Moving Average MA line, a upper band and lower band.

The upper and lower bands are simply MA adding and subtracting standard deviation. Standard deviation is a measurement of volatility. MA is typical 20 day moving average and K is 2. I will use them in this example. Prerequisite environment setup follow Step1 in this post. We will use a csv file AMZN. Therefore the bands can be used to identify potential overbought or oversold conditions.

If stock price breaks out the upper band, it could be an overbought condition indication of short. Similarly, when it breaks out the lower band, it could be oversold condition indication of long. One should consider the overall trend with the bands to identify the signal. Otherwise, with only Bollinger Bands, one could make wrong orders constantly.

In the above Amazon example, the trend is up. So one should only take long positions when the lower band is tagged.Discussion in ' App Development ' started by rsApr 7, Log in or Sign up.

Elite Trader. Hi All, I am working on a project and need your help with a module. I have daily stock prices for Index for last 10 years. The question goes like Considering last 10 year daily price movements of NASDAQ, write a program to check whether fractal geometrics could have better predicted stock market movements than log-normal distribution assumption.

## Speculation on Fractal Programming Language

Explain your findings with suitable graphs. Please could you recommend on how to implement fractals for stock market prediction and how can I compare this with the forecast of lognormal distribution. Its a bit of open ended question and I am lost here. The programming language I use is Python but right not I am stuck on how to tackle this question.

You just isolate the source of returns. If lognormal, buy and sell the stock market for the same durations. The degree of skewness for the distribution of returns will prove it is lognormal.

Essentially, a baseline for your fractal experiment. If fractal, buy and hold for different durations.

### Indicator Reference

I would expect the fractal dimension to be time. There might be a more practical way of finding fractal patterns in stock charts. This may require that you identify specific patterns to trade in varying time frames using technical analysis. If it is for school, may I get a copy of the finished study and code?

I am looking for elementary material on the subject. Additionally, you can write a cool blog about that. I am more than happy to share the code but please help me out with this. I need little more detauls on what you mean. I take log of these returns. Then I generate random numbers from a normal distribution with same mean and standard deviation as above 3. This would tell me how well the lognormal distribution would have predicted the returns?

I can implement this for the stock returns to show that the data has a trend and the OLS r-square is high. There are three possible situations: Fractal Dimension of 1. Remember that Mr. Get your "I. Its a python course and I am jst lookign for a basic implementation fractals.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service.

The dark mode beta is finally here. Change your preferences any time. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Does anybody know of a library or gist for this? Edit: From what I can understand is that you need to split the fractal in 2 every time. So you have to calculate the y-axis point from the line between the two middle points.

Then the two sections need to be formed according to the fractal? As far as I understood the description in the linked page and some of the parent pagesit works like this:.

Learn more. How to generate a fractal graph of a market in python Ask Question. Asked 5 years, 8 months ago. Active 5 years, 8 months ago. Viewed 2k times.

Tjorriemorrie Tjorriemorrie You want to generate a website about fractals? There are a number of interesting web frameworks available. Have you tried Django? Kevin lol, no, obviously not.

I'm looking for the recursion function. Can you provide a more specific link? What you have now just goes to the front page. Kevin thanks for the info. Stupid iframes, sigh. I've updated the link. Not really clear what you are asking.These fractals were generated by Python programs from the Active State website. They often make use of recursion. Recursion is the process of repeating items in a self-similar way. For instance, when the surfaces of two mirrors are exactly parallel with each other, the nested images that occur are a form of infinite recursion.

The term has a variety of meanings specific to a variety of disciplines ranging from linguistics to logic. Specifically, this defines an infinite number of instances function valuesusing a finite expression that for some instances may refer to other instances, but in such a way that no loop or infinite chain of references can occur.

The term is also used more generally to describe a process of repeating objects in a self-similar way. This site uses Akismet to reduce spam. Learn how your comment data is processed. Fractal Python Programs. Square Tiles via ActiveState. Sierpinski Koch Snowflake via ActiveState. Random Spiral via ActiveState.

Percolation via ActiveState. Newton via ActiveState. Logistic Map via ActiveState. Fern via ActiveState. Circle Squares via ActiveState. Circle Inversion via ActiveState.

Logistic Bifurcation via ActiveState. Apollonian Gasket via ActiveState.By Milind Paradkar. Technical Indicator is essentially a mathematical representation based on data sets such as price high, low, open, close, etc.

There are several kinds of technical indicators that are used to analyse and detect the direction of movement of the price for momentum trading, mean reversion trading etc. Traders use them to study the short-term price movement since they do not prove very useful for long-term investors. They are employed primarily to predict future price levels.

In the following post, I will highlight six technical indicators that are popularly used in the markets to study the price movement. Technical Indicators do not follow a general pattern, meaning, they behave differently with every security. What can be a good indicator for a particular security, might not hold the case for the other.

As these analyses can be done in python, a snippet of code is also inserted along with the description of the indicators. Sample charts with examples are also appended for clarity. The commodity channel index CCI is an oscillator which was originally introduced by Donald Lambert in CCI can be used to identify cyclical turns across asset classes, be it commodities, indices, stocks, or ETFs.

## Fractal Adaptive Moving Average

The CCI looks at the relationship between price and a moving average. Steps involved in the estimation of CCI include:. CCI can be used to determine overbought and oversold levels. However, one should be careful because security can continue moving higher after the CCI indicator becomes overbought.

Likewise, securities can continue moving lower after the indicator becomes oversold. Traders can also look for divergence signals to take suitable positions using CCI. A bullish divergence occurs when the underlying security makes a lower low and the CCI forms a higher low, which shows less downside momentum.

Similarly, a bearish divergence is formed when the security records a higher high and the CCI forms a lower high, which shows less upside momentum. In the code below we use the Series, rolling mean, rolling std, and the join functions to compute the Commodity Channel Index.

The Series function is used to form a series which is a one-dimensional array-like object containing an array of data. The rolling mean function takes a time series or a data frame along with the number of periods and computes the mean. The rolling std function computes the standard deviation based on the price provided. We first create an empty figure using the plt. EVM indicates the ease with which the prices rise or fall taking into account the volume of the security. For example, a price rise on a low volume means prices advanced with relative ease, and there was little selling pressure.

Positive EVM values imply that the market is moving higher with ease, while negative values indicate an easy decline.

Ease of Movement EMV can be used to confirm a bullish or a bearish trend. A sustained positive Ease of Movement together with a rising market confirms a bullish trend, while a negative Ease of Movement values with falling prices confirms a bearish trend. Apart from using as a standalone indicator, Ease of Movement EMV is also used with other indicators in chart analysis. In the code below we use the Series, rolling mean, shift, and the join functions to compute the Ease of Movement EMV indicator.

The moving average is one of the most widely used technical indicators. It is used along with other technical indicators or it can form the building block for the computation of other technical indicators.We flew east out of Panama City, and I looked down on the faceted green hills of the Cordillera de San Blas, perhaps for the last time.

In the sky were statistically similar puffs of white cumulus cloud. Naturally, I was thinking of fractals. I had spent the past few days coding technical analysis indicators in Python, which reminded me of coding same in C.

This, in turn, reminded me that although the TA community talks a lot about geometric repetition, we have yet to invent a single fractal indicator, much less a trading strategy. I write my trading strategies in C on the MultiCharts platform. Its procedures for time series data look a lot like the vector-oriented syntax of Python.

Here is how to do Bollinger bands in each:. I have to admit not having much intuition about vector operations. Matrices and summations just look like for loops to me — clearly an obstacle to the proper appreciation of Python.

Admittedly, I have only a cursory notion of how this would work. Meanwhile, I will continue plugging away in C and Python.

### python: stock market fractals vs log-normal distribution

You are commenting using your WordPress. You are commenting using your Google account. You are commenting using your Twitter account. You are commenting using your Facebook account. Notify me of new comments via email.

Notify me of new posts via email. Skip to content Home About Contact. Here is how to do Bollinger bands in each: StandardDeviationCustom length, devs df[price].By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. Quantitative Finance Stack Exchange is a question and answer site for finance professionals and academics.

It only takes a minute to sign up. Most technical indicators must be available in the TTR package. However, if they are not then you can write a custom indicator for use in quantstrat as follows. I have defined two here, fractalindicator. You can work with these just like you do in a regular quantstrat strategy.

I may be wrong in constructing the indicator so check the logic. It is also possible to combine the two functions into one with an additional parameter.

Also, quantstrat related questions are best asked on r-sig-finance mailing list. The authors of quantstrat and many more R enthusiasts are very active on that mailing list. Again this is what worked in my env. The strategy just buys as soon as it gets and up fractal and exits on a down fractal, obviously this is not a strategy anyone would trade, This is just an example of using fractals.

Sign up to join this community. The best answers are voted up and rise to the top. Home Questions Tags Users Unanswered. Asked 4 years, 9 months ago. Active 4 years, 9 months ago.

Viewed 2k times. GeV GeV 3 3 bronze badges. At minimum, tell people you're doing it so they don't possibly expend their valuable effort trying to answer a question that was answered on another forum they do not follow. A You indicator and signal functions are presumed to be path-independent. They should return an xts time series object of the same length as the input data. Active Oldest Votes. Rohit Arora Rohit Arora 4 4 silver badges 11 11 bronze badges.

Again this is what worked in my env fractalindicator. R The strategy just buys as soon as it gets and up fractal and exits on a down fractal, obviously this is not a strategy anyone would trade, This is just an example of using fractals. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name.

Email Required, but never shown. The Overflow Blog. Socializing with co-workers while social distancing.

## Fractal indicator python