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?

1955

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.

6592

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

Or go nuts with the AllAverages indicator http://www.forexfactory.com/showthread.php?t=418219

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 ?

6592

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.

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

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

MetaCOT 2 is a set of indicators and specialized utilities for the analysis of the U.S. Commodity Futures Trading Commission reports. Thanks to the reports issued by the Commission, it is possible to analyze the size and direction of the positions of the major market participants, which brings the long-term price prediction accuracy to a new higher-quality level, inaccessible to most traders. These indicators, related to the fundamental analysis, can also be used as an effective long-term filte

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

Averager is intended for averaging your deals that has had a drawdown or had gone against the trend. An example of operation of the averager in an Exeprt Advisor in the MetaTrader 5 terminal: Exp - TickSniper. The system is identical to the averaging system created for MetaTrader 4. A demo version of the averager for MetaTrader 5: Averager DEMO.Note: this is not an automated trading system (the EA doesn't work in the strategy tester). It monitors your deals and averages them in case o

The script allows users to easily close positions if their profit/loss reaches or exceeds a value specified in pips. Please set slippage value first. Sometimes some positions do not close due to high volatility of the market. Please set larger slippage or restart the script.

Does not support hedging 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 Buttons for re

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

Virtual TrailingStop is an Expert Advisor that manages trailing stop without sending its information to the broker server. Input Parameters EnableVirtualTrailingStop: enable or disable whole function VirtualTrailingStop: the pip use for determine how far the Virtual Trailing Stop will placed calculated from current price StartFromBreakEven: true/false. If true, Virtual Trailing Stop will placed after breakeven BreakEvenPoint: point profit from order open price where the Virtual T

The indicator displays economic news on the currency chart (the appropriate data must be downloaded from the Internet - please see the download instructions on the screenshots provided). The list of currencies (countries) is customizable. By default it shows all currencies. The main parameters come with a built-in description. In addition, there are parameters for advanced users. News items are divided into 3 categories by degree of importance. There is a great flexibility in display parameter s

A script for opening a grid of orders If you need to quickly open several pending orders (Buy Limit, Sell Limit, Buy Stop, Sell Stop) on a certain distance from the current price, this script will do all the routine for you! Allow AutoTrading before running the script. Usage: Run the script on a chart. Input Parameters: Language of messages displayed (EN, RU, DE, FR, ES) - language of the output messages (English, Russian, German, French, Spanish). Price for open - open price. If set to

DeltaVolumeDistribution indicator can be considered as the fusion of the DeltaVolume and TradeSizeDistribution indicators. This indicator, inspired by the MarketDelta-family charts, computes the net difference between trades occurring at bid and at ask, while trades occurring between bid and ask quotes are not computed. The indicator plots the resulting DeltaVolume as a unique distribution plot. With the DeltaVolumeDistribution indicator you will actually be able to see the order flow entering

Trade Copier Pro is a powerful tool to copy trade remotely between multiple accounts at different locations over internet. This is an ideal solution for signal provider, who want to share his trade with the others globally on his own rules. One provider can copy trades to multiple receivers and one receiver can get trade from multiple providers as well. The provider can even set the subscription expiry for each receiver, so that receiver will not be able to receive the signal after that

The most profitable trend traders are the ones who know how to recognize not only the market trend, but also the trading opportunities that arise once a trend has been established. The Pz Trend Trading indicator has been designed to profit has much as possible from trends taking place in the maket. Established trends offer dozens of trading opportunities, but most trend trading indicators neglect them completely, and leave the trader completely uninformed about what the market is doing during a

CandleTimer is an indicator that can be usable for scalper and short-term traders. It shows the following useful information: Remaining and past time of a candle on the current chart or other timeframe Alarm setting for play sound at the start of the current candle Show SL/TP line defining whether the indicator has a Sell or Buy order or both Show a spread value Show Ask and Bid lines in different colors in high and low spread Compatible with a money management EA (you can buy it separat

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 program also takes the news calendar into account: the robot does not enter the market in a 10-minute interval before and after a news rel

Ichimoku Kinko Hyo is a purpose-built trend trading charting system that has been successfully used in nearly every tradable market. It is unique in many ways, but its primary strength is its use of multiple data points to give the trader a deeper, more comprehensive view into price action. This deeper view, and the fact that Ichimoku is a very visual system, enables the trader to quickly discern and filter "at a glance" the low-probability trading setups from those of higher proba

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

COSMOS4U Volume indicator facilitates your trade decisions. It gives confirmation of the running movement and market trends. It highlights current and past accumulation and distribution volumes, comparing them to moving average volume and the highest volume. In addition, it identifies and marks nuances as well as convergence and divergence patterns of bears and bulls in order to provide the market trend and price ranges. The supported features are as follows: Fast Volume Moving Average Slow

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

Does not support hedging 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 attention

The Heiken Ashi indicator drawn using a tick chart. It draws synthetic candlesticks that contain a definite number of ticks. Parameters: option prices - price option. It can be Bid, Ask or (Ask+Bid)/2. the number of ticks to identify Bar - number of ticks that form candlesticks. price levels count - number of displayed price levels (no levels are displayed if set to 0 or a lower value). calculated bar - number of bars on the chart.Buffer indexes: 0 - OPEN, 1 - HIGH, 2 - LOW, 3 - CLOSE.

The Expert Advisor implements the classic "triangular arbitrage", which is successfully used by hedge funds. "Triangular" arbitrage refers to a class of neutral-market strategies, in which the profit or loss of open positions does not depend on the direction of the market movement as a whole. In order to take profit, the EA exploits a weak spot of market makers - it utilizes the difficulty of balancing cross rates of all currency pairs. The advantages of the strategy are the following: n

Exp COPYLOT CLIENT for MT5 is a copier for the МetaТrader 5 platform. It copies forex trades from any accounts. Including those from terminals МТ5 and МТ4. Setup Install the Expert Advisor in the terminal where you want to copy trades. Specify any text label name as pathRead, for example, "COPY". This should match the master terminal (to bind the two terminals). To copy trades, you need to install the free Master copier in the terminal from where you want to copy the trades: COPYLOT

The indicator determines the inside bar and marks its High/Low. It is plotted based on the closed candles (does not redraw). The identified inside bar can be displayed on the smaller periods. You may set a higher period (to search for the inside bar) and analyze on a smaller one. Also you can see the levels for Mother bar. Indicator Parameters Period to find Inside Bar — the period to search for the inside bar. If a specific period is set, the search will be performed in that period. Al

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

Auto Trade Driver is an automatic powerful tool (run as Expert Advisor) that helps you to manage risk and control orders and maximize your profit in multi-protect/trailing-stop rules. This tool is very useful for both scalpers and trend followers. It not only calculates the trade risk exactly, but also protects and maximizes your profits in real-time. With this tool, the only thing you have to do is to enter trade by your own strategy, then it will auto-drive your position with exit strategy y

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

MACD All MAs-14 is a MACD indicator that allows choosing usual parameters of the standard MACD (constructed from EMA) as well as the type of the moving average to be applied: up to 14 different types. You can select 9 standard MAs available in MetaTrader 5 - SMA, EMA, SMMA, LWMA, DEMA, TEMA, Frama, VIDYA, AMA, TRIX, and 4 non-standard - LRMA, HMA, JMA, AFIRMA. General Parameters Method MA - select the type of moving average to be displayed in the current graph. Period slow MA - the number

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