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?

1980

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.

6793

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 ?

6793

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.

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

Easy Order is an Expert Advisor allowing you to enter any type of trade with one click based on your RISK preferences. You can choose to enter a trade and automatically calculate your lot size based on how much of your account you want to risk. Risk is calculated based on your Stop Loss placement. You can use a fixed lot size if you don't want to use risk based calculation of lot size. Your previous setting of risk based or fixed lot size remains saved for your next use of this Expert Advi

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

CCFpExt is an extended version of the classic cluster indicator - CCFp. Main Features Arbitrary groups of tickers or currencies are supported: can be Forex, CFDs, futures, spot, indices; Time alignment of bars for different symbols with proper handling of possibly missing bars, including cases when tickers have different trading schedule; Using up to 30 instruments for market calculation (only first 8 are displayed).Parameters Instruments - comma separated list of instruments with a com

The indicator determines and marks the short-term lows and highs of the market on the chart according to Larry Williams` book "Long-term secrets to short-term trading". "Any time there is a daily low with higher lows on both sides of it, that low will be a short-term low. We know this because a study of market action will show that prices descended in the low day, then failed to make a new low, and thus turned up, marking that ultimate low as a short-term point. A short-term market high is just

This indicator will help you add any custom indicators to a mini chart that is open on the main chart. When you start this indicator, in the parameter table, you have to choose the name the of mini chart you want to add to the main chart, and you have to choose the symbol, period and coordinates of the minichart on the main chart with X-distance and Y-distance parameters. Then you type the indicator's name (that indicator must exist in the indicator folder already). If you want, you can choos

Reverse TradeCopier Follow can copy trades from an account that is running Reverse TradeCopier Source. Features: Copies trades from one source (master) account to multiple following (slave) accounts. Allow investor (read only) password for source (master) account. There are no complicated settings and input parameters, everything is easy. Works with different brokers. Works with different quotes symbols (EURUSD_FX, eurusd_m, etc.). Can copy orders from 4-digit quotes platform to 5-digi

The principle of the indicator operation lies in the analysis of the currency pair history and determining the beginning and the end of the "power" driving the current trend. It also determines the Fibonacci levels in the main window. The indicator also shows how long ago the local Highs and Lows have been reached. How to Use Waves in the subwindow show the strength and the stage of the trend movement. That is, if the waves only start rising, then the trend is in the initial stage. If the

The fractal analysis of the markets is used in the indicator operation algorithm. According to the fractals theory, after the breakthrough of the fractal level confirmed by the closing price located below or above the fractal, the trend wave in the direction of the breakthrough starts to develop. Until the fractal has been passed in the opposite direction, the trend is considered to be acting even if the price is flat or moves backwards. If a bullish fractal has been previously broken through on

This indicator allows you to enjoy the two most popular products for analyzing request volumes and market deals at a favorable price: Actual Depth of Market Chart Actual Tick Footprint Volume ChartThis product combines the power of both indicators and is provided as a single file. The functionality of Actual COMBO Depth of Market AND Tick Volume Chart is fully identical to the original indicators. You will enjoy the power of these two products combined into the single super-indicator!

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

The indicator is an inter-week hourly filter. When executing trading operations, the indicator allows considering time features of each trading session. Permissive and restrictive filter intervals are set in string form. The used format is [first day]-[last day]:[first hour]-[last hour]. See the screenshots for examples. Parameters: Good Time for trade - intervals when trading is allowed. Bad Time for trade - intervals when trading is forbidden. time filter shift (hours) - hourly shift

IceFX VelocityMeter Mini is a very unique indicator on MetaTrader 4 platform which measures the speed of the Forex market. It is not a normal volume or other measurement indicator because IceFX VelocityMeter Mini is capable to understand market speed movements which are hidden in ticks and those valuable information cannot be read in an ordinary way from the candles. The software monitors the received ticks (frequency, magnitude of change) within a specified time range, analyzes these info and

Auto Trade Copier is designed to copy trades between multi MetaTrader 5 accounts/terminals with 100% accuracy. With this tool, you can act as either a provider (source) or a receiver (destination). All trading actions will be copied from the provider to the receiver with no delay. Note: Demo version for testing can be downloaded at: https://www.mql5.com/en/market/product/5006. Followings are highlight features: Switch between Provider or Receiver role within one tool.One provider can copy tr

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 Expert Advisor for increasing (or opening) market positions. Allows specifying the desired risk, target and searching for the best open price and trade volume. It is included in the ActivePanel product.

Fast Copy MT5 allows 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 MT5 —> MT5 MT5 —> MT4 MT4 —> MT5 MT4 —> MT4 * For any interaction with the MT4, it is necessary to additionally install Fast Copy MT4 Main functionalities One tool for sending and receiving transactions: [master] > [slave] operation mode can be selected in th

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

The EASIEST way to manage your risk for each trade! Simply: Add the indicator to your chart, configure a risk percentage (of account equity) Enter the number of pips for your stop loss into the text entry field that appears on the chart The position size to take will automatically be updatedThe product features two modes - a compact mode which allows entry of stop loss pips and shows the resulting lot size based on the percent risk setting, as well as an expanded mode that also shows

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

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

SafeZone is a method for setting stops on the basis of recent volatility, outside the level of market noise. It is described in "Come into my Trading Room" book. In an uptrend, SafeZone defines noise as that portion of the current bar that extends below the low of the previous bar, going against the prevailing trend. It averages the noise level over a period of time and multiplies it by a trader-selected factor. For long trades, SafeZone subtracts the average noise level, multiplied by a fac

This is a panel for controlling the profit/loss in dollars, pips or % of balance. A new function for trailing profits has been implemented. The panel can be used as a virtual Stop Loss or Take Profit. It also features the emergency button - CLOSE ALL. You can also try the full version of the VirtualTradePad for mt5 panel, as well as the Profit or Loss for mt4 panel Other versions in this collection: VirtualTradePad for mt5 Digit Market Time Pad Market Time Pad Scalper PadMain f

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

We present you an effective software solution for arbitrage between brokers. The Arbitrage on the market became widespread due to decentralization. There are many liquidity providers, whose quotes differ for various reasons. By tracking the dynamics of changes in the quotes of different brokers, it is possible to determine the delayed and leading brokers, thereby predicting the future prices of the delayed broker for a short time. Knowing these prices and using efficient built-in software filte

Safe Automatic is a safe MetaТrader 5 trading robot working autonomously on a VPS server. The good results are achieved on EURUSD. Trading Strategy The EA applies modified versions of a trend-following strategy, half-pyramiding, scalping, Elliott Wave method and speculating trading with a deposit protection. The EA switches the strategies automatically. The robot does not trade at night from 10 p.m. to 4 a.m. (server time). The robot was tested in the special tester on real ticks. Empirical e

This is a linear indicator of a currency power having the ability to filter by smoothing values. It shows the current power of selected currencies (the maximum number is 8), as well as historical values. The product is based on CPM Extended MT5. Calculation depends on the selected chart timeframe the indicator is launched at. iPeriod - number of bars used to analyze currency power. HistoryBars - number of calculated bars on history. The parameter affects execution time during the first launc

This software has no equals in the world and represents a universal trade "console" covering trading signals, automated market entry, setting of Stop Loss and Take Profit, as well as Trailing Profit for multiple trades at the same time in a single open window. Intuitive control of the Expert Advisor in "three clicks" ensures a comprehensive use of all its functions on different computers, including tablets PCs. Interacting with additional signal indicators that mark the chart to give a real mar

The "Candle Pips" indicator is a tool that helps us a quick way to see the size of the candles on our platform; this is not only of great help to any trader who wants to study the market thoroughly, it is helpful in various strategies that are based on size of the candles. The indicator shows the value in Pips of each candle to our current graph, rounded to an integer. It has simple inputs Candle Type: this entry allows you to select which part of the Candle we want to measure. If you sel

The script creates account summary report in a separate window. The report can be created for all deals and on deals for selected financial instruments. It is possible to specify a time interval of calculation and save report to htm-file. The script creates account summary report in a separate window. The report can be created for all deals and for deals of the selected financial instruments. It is possible to specify a time interval of calculation and save report to htm-file. Input par