friendly
FRENCH
je paierais jamais pour une chose comme ça et tu sais pourquoi ?
car je fais du trading comme passe temps c'est une passion comme d'autres c'est la lecture ou les jeux etc..
moi je gagnerais jamais assez pour en vivre mais ma grande force et mon avantage sur 99% des tradeurs c'est que je le sais :-)
et pour moi un forum c'est un espace gratuit et je compte sur le partage la solidarité oui je suis naif mais j'y crois encore tout n'est pas encore tout pourri par l'argent en tout cas je l'espere .
moi je gagne peu mais je pert peu et je vais te faire rire mais quand je gagne 20 ou 50 $ je suis HEUREUX tu vois je suis un petit et je le sais mais surtout je suis tres realiste .
donc si on m'aide la aussi je suis heureux car je me dit que j'ai raison de croire que tout n'est pas corompu par l'argent et qu'il y a encore des gens bien ( comme Simon G par exemple )
amicalement
Some people spend many thousands of £ or $ or € on their hobbies . . . .
hello RaptorUK
not me I can not afford :-)
|
no problem I will try to code it myself . friendly | ||||
friendly
//+------------------------------------------------------------------+ //| XCAP_POLIPREDICT.mq4 | //| Copyright 2012, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright 2012, MetaQuotes Software Corp." #property link "http: //www.metaquotes.net" #property indicator_chart_window //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+
IndicatorBuffers(8);double TimeSeries; int Width = 126; int MaxDegree = 5; int ForwardExtension = 10; bool ShowLeadingEdge = False; bool ShowPredictedEdge = FALSE; bool ShowSmoothedTimeSeries = TRUE; color LeadingEdgeColor = Blue; color PredictedEdgeColor = Magenta; color SmoothedTimeSeriesColor = Red; color ExtendedTimeSeriesColor = Yellow; double LeadingEdge; double PredictedEdge; int p, j, Value1, Value2; int DataSize; double Polynomial[]; double Coefficient[]; double SmoothedTimeSeries[]; int init() { //---- indicators DataSize = ((2 * Width + 1) + ForwardExtension);
SetIndexBuffer(0,Polynomial); SetIndexBuffer(1,Coefficient); SetIndexBuffer(2,SmoothedTimeSeries); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { //---- if (ShowLeadingEdge == TRUE || ShowPredictedEdge == TRUE) //or (LastBarOnChart=TRUE and ShowSmoothedTimeSeries=TRUE ) then begin { for (p = 0; p <= MaxDegree; p++) { Coefficient[p] = 0; for (j = -Width; j <= Width; j++) { TimeSeries = (High[Width - j] + Low[Width - j]) / 2; // Print( " TimeSeries = " ,TimeSeries); Coefficient[p] = Coefficient[p] + Polynomial[p * DataSize + Width + j] * TimeSeries; } } for (j = -Width; j <= (Width + ForwardExtension); j++) { SmoothedTimeSeries[Width + j] = 0; for (p = 0; p <= MaxDegree; p++) SmoothedTimeSeries[Width + j] = SmoothedTimeSeries[Width + j] + Coefficient[p] * Polynomial[p * DataSize + Width + j]; LeadingEdge = SmoothedTimeSeries[Width + Width]; PredictedEdge = SmoothedTimeSeries[Width + Width + ForwardExtension]; } Print(" PredictedEdge = ", PredictedEdge); Print(" LeadingEdge = ", LeadingEdge); } //**************************** for (j = -Width; j <= (Width + ForwardExtension); j++) Polynomial[0 * DataSize + Width + j] = 1; if (MaxDegree >= 1) { for (j = -Width; j <= (Width + ForwardExtension); j++) Polynomial[1 * DataSize + Width + j] = j; } if (MaxDegree > 1) { for (p = 1; p == MaxDegree - 1; p++) { // create the polynomial for degree p+1 for (j = -Width; j <= (Width + ForwardExtension); j++) { Value1 = j * (2 * p + 1) / (p + 1); //discrete Legendre polynomial solution Value2 = -(p / (p + 1)) * (2 * Width + 1 + p) * (2 * Width + 1 - p) / 4; //discrete Legendre polynomial solution Polynomial[(p + 1) * DataSize + Width + j] = Value1 * Polynomial[p * DataSize + Width + j] + Value2 * Polynomial[(p - 1) * DataSize + Width + j]; } } } for (p = 0; p <= MaxDegree; p++) { Value1 = MathPow(2, -2 * p) / (2 * p + 1); for (j = -p; j <= p; j++) { Value1 = Value1 * (2 * Width + 1 + j); } if (Value1 > 0) Value1 = 1 / MathSqrt(Value1); //this is the normalization coefficient for (j = -Width; j <= (Width + ForwardExtension); j++) { Polynomial[p * DataSize + Width + j] = Value1 * Polynomial[p * DataSize + Width + j]; } } //*************************** //---- return(0); }
/** Log * send information to OutputDebugString() to be viewed and logged by * SysInternal's DebugView (free download from microsoft) This is ideal for * debugging as an alternative to Print(). The function will take up to 10 * stringa (or numeric) arguments to be concatenated into one debug message. //*/ #import "kernel32.dll" void OutputDebugStringA(string msg); #import void Log(string s1, string s2="", string s3="", string s4="", string s5="", string s6="", string s7="", string s8="", string s9="", string s10=""){ if (IsDllsAllowed()){ string out = WindowExpertName() + ": " + s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10; OutputDebugStringA(out); } }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
friendly
{ XCAP_iPolyFitPredict: Uses a fit to polynomials to create a least squares best fit for a given maximum degree. Extends the fit forward in time for trading purposes. See reference [1] for more information. Author: Paul A. Griffin January 4, 2007 Extrema Capital, 2007 This indicator provides as output the least square best fit to a set of polynomials of maximum power (degree) using discrete Legendre polynomials. This is accomplished by decomposing the time series into discrete Legendre polynomials over the interval of orthogonality given by 2 * Width + 1 and discarding the polynomial fits degrees above some maximum degree. The remaining smoothed series is continued forward in time by following the polynomial fit. Some Comments: In this indicator, we are displaying the least squares fit to a low degree set of polynomials and extending that fit into the future. This as a tool to extend a low order trend into the future. Some Plots: All Charts: Daily chart with a width of 126 bars (126*2+1 = 253, about 1 trading year) For @US (30 year US Treasury Bond Futures), and SPY roughly for year 2006 MaxDegrees: 1, 2, 3 ForwardExtension: 10 ShowLeadingEdge = TRUE As you move forward along the time series, the fit is generated. What is displayed is the leading, rightmost bar, "[0]", for each fit. ShowPredictedEdge = TRUE As you move forward along the time series, the fit is generated, and then a prediction is made. What is displayed is the predicted, beyond the rightmost bar, "[-ForwardExtension]", for each fit. ShowLastFit = TRUE This displays the entire last fit for just the last bar on the chart, so you will only see an output on the last 2*Width + 1 bars of your chart. It will also display the polynomial extension of the fit forward in time to bar [-ForwardExtension] References: [1] Legendre Polynomial Fits https://www.tradestation.com/Discussions/Topic.aspx?Topic_ID=58534 [2] Savitzky Golay https://www.tradestation.com/Discussions/Topic.aspx?Topic_ID=59250 [3] http://en.wikipedia.org/wiki/Legendre_polynomials [4] Peter Seffen, "On Digital Smoothing Filters: A Brief Review of Closed Form Solutions and Two New Filter Approaches", Circuits Systems Signal Process, Vol. 5, No 2, 1986 } Inputs: TimeSeries((h+l)/2), // The original data to fit, put in whatever you want to look at of whatever time series // Width(126), // Length = 2*Width+1, the default gives a fit to one year (252) of daily bars // MaxDegree(5), // The degree of the polynomial fit. 0 <= MaxDegree <= 2*Width+1 // ForwardExtension(10), // The number of bars the fit is to be extended forward in time, // **you must have this many spaces in: "Format Window/Space to the Right" ** // ShowLeadingEdge(FALSE), // The leading edge is the rightmost point of every fit in the timeseries // ShowPredictedEdge(FALSE), // The predicted edge is the extended from ForwardExtension bars ago // // ShowSmoothedTimeSeries(TRUE), // This shows the entire fit over the interval 2*Width+1 for the last bar // plus the ForwardExtension predictions // LeadingEdgeColor(Blue), PredictedEdgeColor(Magenta), SmoothedTimeSeriesColor(Red), ExtendedTimeSeriesColor(Yellow); Variables: LeadingEdge(0), PredictedEdge(0), p(0),j(0), DataSize((2*Width+1) + ForwardExtension); Arrays: Polynomial[](0), Coefficient[](0), SmoothedTimeSeries[](0); if barnumber = 1 then begin //Allocate memory for the arrays. Polynomial is a 2D array Array_SetMaxIndex(Polynomial, DataSize*(MaxDegree+1)+1) ; Array_SetMaxIndex(SmoothedTimeSeries, DataSize); Array_SetMaxIndex(Coefficient, MaxDegree+1) ; end; //Now decompose data into the polynomial set and determine the overlap coefficients: if ShowLeadingEdge=TRUE or ShowPredictedEdge=TRUE or (LastBarOnChart=TRUE and ShowSmoothedTimeSeries=TRUE ) then begin //Decompose data into the polynomial set and determine the overlap coefficients: for p = 0 to MaxDegree begin Coefficient[p] = 0; for j = -Width to +Width begin Coefficient[p]= Coefficient[p] + Polynomial[p*DataSize+Width+j]*TimeSeries[Width-j]; end; end; //Recompose the original price as the truncated polynomial version - create the smoothed time series, including the //forward extension for j = -Width to Width + ForwardExtension begin SmoothedTimeSeries[Width+j] = 0; for p = 0 to MaxDegree begin SmoothedTimeSeries[Width+j] = SmoothedTimeSeries[Width+j] + Coefficient[p]*Polynomial[p*DataSize+Width+j]; end; end; //The leading edge is at j = Width LeadingEdge = SmoothedTimeSeries[Width+Width]; //The predicted edge is at j = Width+ForwardExtension PredictedEdge = SmoothedTimeSeries[Width+Width+ForwardExtension]; print(PredictedEdge :5:5 ); end; //Plotting routines if ShowLeadingEdge=TRUE and LeadingEdge<>0 then Plot1(LeadingEdge,"LdngEdge",LeadingEdgeColor); if ShowPredictedEdge=TRUE and PredictedEdge<>0 then Plot2[-ForwardExtension](PredictedEdge,"FwrdEdge",PredictedEdgeColor); if LastBarOnChart=TRUE and ShowSmoothedTimeSeries=TRUE then begin for j = -Width to Width begin plot3[Width-j](SmoothedTimeSeries[Width+j],"Fit",SmoothedTimeSeriesColor); end; if ForwardExtension > 0 then begin for j = 1 to ForwardExtension begin plot4[-j](SmoothedTimeSeries[Width+Width+j],"Prediction",ExtendedTimeSeriesColor); end; end; end; ////////////////////////////////////////////////////////////////////////////////////////////////// // // Create the Orthoginal Legendre Polynomials during the first bar, including ForwardExtension data // ////////////////////////////////////////////////////////////////////////////////////////////////// if barnumber = 1 then begin //The first polynomial is a constant, easy to create for j = - Width to + Width + ForwardExtension begin Polynomial[0*DataSize + Width+j] = 1; end; //The second polynomial is a line if MaxDegree>=1 then begin for j = -Width to +Width + ForwardExtension begin Polynomial[1*DataSize + Width+j] = j; end; end; //We use the discrete Legendre polynomial recurrence relations to create the rest if MaxDegree > 1 then begin for p = 1 to MaxDegree - 1 begin // create the polynomial for degree p+1 for j = -Width to Width + ForwardExtension begin // sum over the interval Value1 = j*(2*p+1)/(p+1); //discrete Legendre polynomial solution Value2 = - (p/(p+1))*(2*Width+1+p)*(2*Width+1-p)/4; //discrete Legendre polynomial solution Polynomial[(p+1)*DataSize+Width+j] //The recurrence relation = Value1 * Polynomial[p*DataSize+Width+j] + Value2 * Polynomial[(p-1)*DataSize+Width+j]; end; end; end; //Now we have to normalize each polynomial, so that the sum of the square of the polynomial //over the interval is 1. Instead of doing the calculation however, we apply the pre-determined answer[4]: for p = 0 to MaxDegree begin Value1 = Power(2,-2*p)/(2*p+1); for j = -p to p begin Value1 = Value1 * (2*Width+1+j); end; if Value1 > 0 then Value1 = 1/squareroot(Value1); //this is the normalization coefficient for j = -Width to +Width + ForwardExtension begin Polynomial[p*DataSize+Width+j] = Value1 * Polynomial[p*DataSize+Width+j]; end; end; //Done! We now have a orthogonal normalized set of polynomials end;