The i-regr indicator can do arbitrary polynomial regressions to any degree. I have never attempted anything higher than 3rd degree, but the code is there for you to look at. 6th degree will probably kill your CPU, but you can give it a try.

122

The i-regr indicator can do arbitrary polynomial regressions to any degree. I have never attempted anything higher than 3rd degree, but the code is there for you to look at. 6th degree will probably kill your CPU, but you can give it a try.

162

Thanks rocketman! Didn't kill my CPU at all - I'll work with this for awhile using and see what I come up with.

Update:

i-regr doesn't seem to have a high degree of accuracy - could be possibly due to the gauss (i-regr) and least squares (excel) method used to solve. I don't know - still looking, anyone have any better poly procedures?

2002

i-regr is working on Close[] value of every bar, which probably makes difference (i guess that you have equalized the pattern lengths in MT4 and excel).

you can change this easily by changing Close[] to Open/High/Low or to any other analytical expression e.g. weight function.

however i don't believe that you can make a profit out of this, it is just like any other repainting trend indicator.

7089

Hi dennisj2,

are you sure you really need your formula?

May be you try first to search for other filters like Kalman, Ehlers, Gauss, Jurik (JMA), DEMA. Most of them derived from low-pass (physical) frequency filters and most of them have found their way into mt4-code.

May be a JMA (there are many variations) with a longer period-set does what you are looking for?

122

2584

Now my quest begins.

Now that I identified a practical application, I sought to learn (or, in my case, re-learn) the math behind the poly trend line formula. Good luck with that. Least squares reduction and matrices added to the extremely complex formula and required coefficient calculations introduced by the polynomial equation is far too difficult (for me) to translate into code. So, I figured it would be easiest to call Excel (most likely from c++), supply an array of (x,y) data values, compute the poly (x,y) intercept (trendline value) using LINEST(), and returning this value back to my desktop application (a closed proprietary software app with limited call-out functionality).

Assembling the formula using LINEST() has become a substantial hurdle. It's easy enough to supply the data - but, how can I compute the (x,y) intercepts shown so flawlessly on the graph? Every new measure changes the formula and uses newly calculated coefficients? Why does this happen? I have spent hours, upon hours (and then some) scouring the internet for solutions - and (just like a man) have decided finally to ask for directions.

I've got the source values (years upon years of it). What I'm missing is a) the method to generate the poly(x,y) intercept, b) by calling Excel externally to c) return the poly(x,y) based on supplied (x,y) data -

If anyone has an article or very specific treatment of this topic, or even willing to lend a hand, I would be forever in your debt.

dj

There are a lot of articles out there about algebra with examples in Greek but really it is voodoo.

For example there is a wikipedia article about linear regression that makes no sense to me at all, yet I could code a linear regression version of your line right now because somewhere else I learned to use the formula

y=a+bx

Yet nowhere in the wikipedia article is that formula even mentioned, how can that make sense ?

also I learned when using that formula

a == slope

b== intercept

the math for calculating slope and intercept is known and is pretty simple procedure of calculating the sums of the values, squaring some of them etc.

I also know the formula for a quadratic regression (2nd degree) is y=ax^2 + bx + c

So I am thinking they are related which should mean the equation for 3rd degree regression is

y=ax^3 + bx^2 + cx + d

so I think the 6th regression would be

y=ax^6 + bx^5 + cx^4 + dx^3 + ex^2 + fx + g

but if a is slope and b is intercept what is c and what would be d etc ? That is the only reason I could not code your line, I don't know what the coefficients are or how to calculate them.

UPDATE: ok I learned something else which is confusing me now.

in another article quadratic polynominal is described as

ax^2 + bx + c = 0

Does that mean we dont need to know the math for slope intercept at all and we could solve the quadratic to find the values of a, b and c ?

But how does ax^2 + bx + c = 0

relate to

y=ax^2 + bx + c ?

They look similar but how come one is y= and the other is =0 ?

7089

SDC,

the slope in one point can be calculated by the first derivation of a function.

A linear function like y=ax+b has at any point the same slope: a.

In general the derivation of a linear function ax^n + bx^n-1 + ... + z = y is simply: nax^(n-1) + (n-1)bx^n-2 .. = y' - the last constant of the original function becomes 0, always!

So ax + b = y => y' = a ( <= 1*a^(1-1); b=0 )and the quadratic function becomes y' = 2ax + b ( <= 2ax^(2-1) + 1bx^(1-1); c=0 ).

But I think to understand the idea of filters you better think (and read) about filtering frequencies. No matter whether it is sound or pictures or quotes or ..

One always want to get rid of the noise - in general - the shorter term frequencies. And the use of linear functions is just one approach.

2584

Thanks for trying to explain that to me but I don't know why those equations mean what they mean. If I know how to calculate the coefficients individually in a procedural way I can use them and plug in the values but that's about it.

I do understand the concept of filters, I was just interested in figuring out how to code the OP's line.

But in regard to doing that, when you say,

"So ax + b = y => y' = a ( <= 1*a^(1-1); b=0 )and the quadratic
function becomes y' = 2ax + b ( <= 2ax^(2-1) + 1bx^(1-1); c=0 )."

I have no clue what you are talking about or even how that is relevant so I probably wont be doing any poly line coding any time soon lol

162

**SDC:**

There are a lot of articles out there about algebra with examples in Greek but really it is voodoo.

SDC - you are now at the same level that I am - the linear regression formula I found works - and there are two distinctly different formulas I found that produce identical results. These formulas are great if linear regression (a straight trend line) is what we were after.

First, some reference material:

Microsoft: http://office.microsoft.com/en-us/excel-help/linest-HP005209155.aspx

IntegralCalc: https://www.youtube.com/watch?v=1pawL_5QYxE&noredirect=1

Given the linear regression equation y = mx + b:

Where y = price, (e.g., Close[x])

and x = index (e.g., Bar[x])

and m = Slope (the coefficient applied to each (x,y) pair)

and b = Y-intercept (the base value of Y-intercept applied to each (x,y) pair)

Method A: From IntegralCalc Method B: From Microsoft (where x(overbar) and y(overbar) are means)

Even the polynomial regression trend line formula to the nth degree is relatively easy to apply:

Given the formula: y = m1*x1 + m2*x2 + m3*x3 + ... + b

Where the variables x, y, m, and b carry the same definition described in the linear equation.

**Seems I have everything, so what's missing?**

What is missing is the calculation for the m (Slope) and the b (Y-intercept) for a polynomial regression; the linear equation for computing these values does not apply to a polynomial regression. From what I've learned, the polynomial regression requires a formula that calculates least squares based on a system of polynomial equations using a matrix. Look at the example graphs above. In the first graph, the poly(6) lines are absolutely immaculate - tops and bottoms are clearly called out. With this data, I will be able to hold trades longer than I do today ultimately doubling, potentially tripling my average pips per trade.

In the second graph, I show the results of the poly(6) vs. the i-regr method that uses a gauss matrix to solve for the slope coefficients - and, needless to say, it's fairly useless due to the substantial latency of the method. On the other hand, a simple moving average is even worse - the SMA is far too sensitive during intermediate market corrections that could cause an overreaction of my EA.

I am willing to pay someone to develop a true polynomial regression indicator - but, the results absolutely must mirror the results that Excel produces. The LINEST() function is a black box where much voodoo is used to calculate the coefficients. Quite simply, I need to understand this voodoo.

**Update: I attached a file showing the method implemented in Excel.**

linest.zip 15 kb

162

i-regr is working on Close[] value of every bar, which probably makes difference (i guess that you have equalized the pattern lengths in MT4 and excel).

you can change this easily by changing Close[] to Open/High/Low or to any other analytical expression e.g. weight function.

however i don't believe that you can make a profit out of this, it is just like any other repainting trend indicator.

Grazi -

I used the i-regr and compared the results above - the Poly(6) algorithm vs. i-regr shows the i-regr has a substantially greater latency then the poly(6) based on the same set of data - latency is death in this market. My EAs don't trade intraday oscillation but rather, hold for the trend. So, you are mistaken - I do profit from my EAs and, with a slower reactive indicator, my EAs will capture more of the market then they do today. Specifically, once I've integrated a true poly(6) algorithm, I'll have the ability to hold open positions longer and predict trend changes 3-4 periods earlier improving my entry points.

This indicator extracts a trend from a price series and forecasts its further development. Algorithm is based on modern technique of Singular Spectral Analysis (SSA). SSA is used for extracting the main components (trend, seasonal and wave fluctuations), smoothing and eliminating noise. Does not require the series to be stationary, as well as the information on presence of periodic components and their periods. It can be applied both to price series and to the data of other indicators. Implemen

The Trade Manager Pro EA is a MetaTrader Expert Advisor that performs position management for you avoiding human errors and enhancing your trading activity. Amazingly easy to use Trade easily from the chart Trade with precise risk management, hassle free Capital preservation is top priority Let profits run without your attention Enjoy risk-free trades as soon as possible Automatic trailing stops for all opened trades Initial stop losses are placed as soon as trades are

The main purpose of the indicator is to detect and mark on a chart the following trade signals described in "New Trading Dimensions": Bullish and bearish reverse bars with angulation (including squat). Bars in the green and red zones according to the histogram color of Awesome Oscillator and Accelerator Oscillator. Bars in the grey zone, when the Awesome Oscillator and Accelerator Oscillator histograms below these bars have opposite directions. Blue squat bars on chart independent of the

Parameters Three variables are available for every strategy, any one of them can be disabled, their period can be changed. type_order=ORDER_FILLING _FOK - order filling type. ReverseTrade=false — trades opens in reverse direction if true. ExitOnBar=true — trades close on each bar only. spreadcover=false — Spread you pay includes in profit trades. It's like trade with zero spread but you should remember that it can decrease exact match between tester's result and live one. It

This is an utility for automatic scaling of a chart and making at least 140 bars visible in it. This is necessary for a correct wave analysis according to the Bill Williams' strategy "Trading Chaos". The utility can be used on any timeframe available in МetaТrader 5. It draws a vertical line through the first bar the calculation starts from. This line allows you to see the probable starting point of the wave sequence along with a sufficient number of bars displayed in the chart. It also makes t

Create your own list of trading instruments Watch list* and combine it with several open charts Link **. Using this program, a user can create fully-fledged Watch lists, create and delete trading instruments and move through the list. A selected symbol shows charts in linked windows. Linked windows can have different periods, indicators, experts, trading panels, etc... Moving through his/her Watch list, a trader an see the full image of his/her strategy in all windows. A lot of traders use 1

Fast Copy MT5 allows you to copy trades between different MetaTrader 5 (netting)(hedge) and MetaTrader 4 accounts in any direction and amount, quickly and easily (without loading the system). Any type of copying is available MT4 → MT5 MT4 → MT4 MT5 → MT5 MT5 → MT4 * For the MetaTrader 4 terminal — Fast Copy MT4 * For the MetaTrader 5 terminal — Fast Copy MT5 ** Before the purchase, you can test the program by downloading the free demo versions — Fast

Tick volume is equal to amount of ticks at the unit of time. There is direct correlation between tick volume and real amount of deals. Every change of the price is a result of a real request to perform a deal. Consequently, fewer requests we have, the less price changes we get, and, as a consequence, tick volume is smaller. In this case, when big amount of requests appear on the market, price changes happen more often. Big tick volume appears. Tick volume is an important indicator of trad

Market Profile defines a number of day types that can help the trader to determine market behaviour. A key feature is the Value Area, representing the range of price action where 70% of trading took place. Understanding the Value Area can give traders valuable insight into market direction and establish the higher odds trade. It is an excellent addition to any system you may be using. Blahtech Limited presents their Market Profile indicator for the MetaTrader community. Inspired by Jim Dalton’s

Robust median Renko style indicator for creating custom charts resembling Median Renko, Mean Renko, Turbo Renko and Better Renko candles as well as vanilla Renko with wicks plus PointO charts. This all in one package provides all of the signals needed by day traders, scalpers and even long term traders. These include: The indicator is an overlay on the main chart so it is possible to utilize one-click trading and order manipulation directly on the custom charts. Visual order placement is a

EA PENDING ORDER bars All the strongest movements occur only during the news. However, it also happens that the news on one currency pair influences other currencies, though no news was released for them. For this Expert Advisor, I do not use news lists or indicators (which are late anyway). The principle of the Expert Advisor operation is quite simple. EA Pending Оrder bars places BUYSTOP and SELLSTOP pending orders at the distance equal to the arithmetic mean value of the last bars' height o

The indicator represents an additional chart window with a lower time frame where bars are combined into groups that are equivalent in time to main chart time frame. Bars are synchronized by the right hand side of the window, i.e. the time of the last bar in the main window corresponds to the time of the last bar group in the additional window. The maximum number of groups is 16; the maximum number of bars combined into groups in the additional window is 256. Limitations on the numbers are requi

The indicator is designed for easy construction of synthetic charts based on data of various financial instruments. It will be useful both arbitrage and pair trading, as well as for analysis purposes. Its main advantage is simplicity and clarity. Each chart is given as a common mathematical formula. For example, if you want to plot the spread (difference) between EURUSD and GBPUSD with coefficients 4 and 3, then set the following formula: EURUSD * 4 - GBPUSD * 3 The resulting chart is shown in

Trade Controller provides multiple methods to protect and maximize your profits. This powerful weapon helps you to set the protect and trailing-stop rules on your trade automatically in many effective methods. Once it is set and turned on, you don't need to monitor your orders anymore, the software will keep watching and control your orders with your predefined rules. It's designed to support multi-protection and trailing strategy: Protect by break-even, protect by percentage, protect by pip, p

Cluster analysis of volumes is now available in MetaTrader 5! The YuСlusters indicator is a professional tool for analyzing the trading volumes. The cluster graph is plotted based on tick data. For the exchange financial instruments these are the volume, type and price of a deal. For the Forex instruments - the real or tick volume (depending on the broker) and Bid price. There are 6 criteria of cluster generation: Time interval, the criterion is set in seconds. Price range, the criteri

FULL Automatic is a fully autonomous trading robot for MetaТrader 5 without configurable parameters. It is similar to SAFE Automatic robot intended for traders having no knowledge of trading basics. It works in Low, Medium, High and Extremal trading modes. Trading strategy The EA applies modified versions of well-known strategies, including Elliott waves, following a trend, half-pyramiding, scalping, speculative trading with a double deposit protection. The EA switches the strategies automati

Percent Crosshair is a powerful and easy percentage measure tool. Measure the chart percentage very quick! Don't waste your time anymore! Just attach the Percent Crosshair indicator in the chart, select crosshair mode at toolbars or press "Ctrl+F" and start using the crosshair as you always do! The percent measure will be next to the indicative price. Customize your indicator the way you want! There are 4 entry parameters: Positive % color: set the desired color when % is positive. Negat

Volume is an important indicator in combination with price movements. Volumes Overaverage Notifier informs you when activity is entering the market. Features This indicator is able to notify you via push notifications, alerts, sounds and emails when it is recognizing rising volume above a customizable level. The volumes histogram is divided and colored in 4 different parts - low, normal, high and ultrahigh volume levels. Low volume zones are drawn as a rectangle into the chart. How to Use

This is the Famous Timing Indicator You can now use the most famous Timing indicator on the planet. Millionaire Mostafa Belkhayate earned his reputation by using this specific indicator to validate the entry signals supplied by his also famous Center of Gravity indicator on the Forex market. I spent hours, days, weeks to decrypt the formula and now it is finally available to you. New and Unique for MetaTrader 5 Timing will give you perfect validations for your entry signals. It is the first

This is an open interest indicator for MetaTrader 5. It fixes open interest value once per minute and writes it to the file (on your PC). The product works on any timeframe but only with exchange instruments.

The indicator is intended for determining the spread and swap size, the distance for setting stop orders and stop losses from the current price allowed and the risk per 1 point in the deposit currency. The indicator informs a trader about possible additional expenses and profits connected with transferring a position to the next trade session of the financial instrument. It also informs about the spread size and the distance of pending orders, stop loss and trailing from the current price. In a

One of the versions of the regression channel in MetaTrader 5. The Regression Channel consists of two lines, which are equally distant up and down from the regression trend line. The distance between the borders of the channel and the regression line is equal to the deviation of the maximum Close price from the regression line.

All traders using VSA realize the importance of the volume. Unfortunately, tick and spot volumes are not suitable for these purposes. I have conducted mathematical calculations and managed to trnsform the price into the volume that is close to the futures one by its ratios. Now, you do not have to wrestle with the question of where to obtain the volume data. Besides, you will be able to use the currency pairs having no futures at all. With RealVolume, you do not need to remember data on each ti

Does not support openning multiple orders on a single symbol on MT5 MultiMTCopier MT5Receiver - new and improved multi-terminal positions copier for your real/demo account, works faster, requires less, flexible in managing and upgrading, new information support. This Expert Advisor is designed for the MetaTrader 5 terminal, trades will be copied into this terminal. MultiMTCopier: The EA will copy all positions without delays Additionally integrated notification in situations requiring user

Monitoring and Trend Analysis This product shows the trend strength levels based on 16 standard indicators, time periods and currency groups. Depending on the current trend, the indicator colors change from green to red, allowing you to see the full picture. Advantages Whatever your trading method and strategy are, you should always know, in which direction you are trading and what the probability of the trend change is. This indicator will help you answer these questions by calculating the

The script is intended for automatic placing of Buy Stop pending orders, Stop Losses and Take Profits on the user specified levels. Main Purposes: Avoiding unwanted entering a long position in case of false hitting the level as a result of widening of the spread by a dealing center. Avoiding unwanted triggering of a Stop Loss in case a quote pierces a significant level (fractal) without further confirmation with the close price. Setting a necessary virtual order and entering the market in

The script is intended for automatic placing of Sell Stop pending orders, Stop Losses and Take Profits on the user specified levels. This script is not that useful as "Virtual pending buy stop", since short positions are opened as Bid price crosses the levels. Thus spread widening is not dangerous. Nevertheless, you need to have this script to prevent unwanted hitting of the Stop Loss levels. Main Purposes: Automation of the process of placing the Sell Stop pending orders, Stop Losses and T

VirtualTradePad - is a contol panel for working with orders in МetaТrader 5 : buy, sell, buystop, buylimit, sellstop, selllimit, close, delete, modify, tralling stop. VirtualTradePad won 2nd prize in the "Best Control Panel in the MQL5 Language" Contest. The panel consists of 5 tabs. Demo versions: VirtualTradePad PositionsStyle VirtualTradePad Ordersstyle VirtualTradePad SignalsStyleDemo version of the panel - VirtualTradePad LiteProfit or Loss PadINFO PadYou can also try this panel for

Does not support openning multiple orders on a single symbol on MT5 MultiMTCopier MT5Source - new and improved multi-terminal positions copier for your real / demo account, works faster, requires less, flexible in managing and upgrading, new information support. This expert is designed for terminal MetaTrader5 from which the position will be copied. MultiMTCopier: The EA will copy all positions without delays Additionally integrated notification in situations requiring user attention Butt

Find Shoulder-Head-Shoulder chart patterns easily with this indicator. Easy to use Customizable colors and sizes It implements breakout signals It implements alerts of all kinds Input Parameters Indicator Settings - The amplitude represents the size of the patterns to be found. The max. history bars parameter is the amount of bars in the chart to look back. Less bars to evaluate means the indicator will load faster. Patterns - Choose the colors of the patterns. Breako