ELD code conversion to MQL4 - page 2

 
thank you william.

I just looked at my data and what is wrong and I do not know where is my mistakes though as you way I try.

eg in Multicharts for AUDUSD = 1mn TF here is good data

 Coefficient= 0.00046

 TimeSeries= 1.04844

 PredictedEdge  = 1.04904

 LeadingEdge = 1.04876

and my program MT4 this is what I have.

TimeSeries   =  1.0484

Coefficient   =  2147483647.0000000

Polynomial[p * DataSize + Width + j]   =  2147483647.00000000

PredictedEdge   =  517792549419260340000000

LeadingEdge   =  0

As you can see I am very very far and I do not understand where is the problems.

there are things that I have not translated because I do not know meur equivalence.

instance.

LastBarOnChart

Array_SetMaxIndex

barnumber 

Value1 ,Value2 

may be that I have to start all over?

friendly
 
Hello.

can you tell me what is the equivalent instructions MQL4 then I think I could pass a convert this ELD in MQL4 code

 

LastBarOnChart

Array_SetMaxIndex

barnumber 

Value1 ,Value2  

 


friendly
 
phenix77:
Hello.

can you tell me what is the equivalent instructions MQL4 then I think I could pass a convert this ELD in MQL4 code

This is an mql4 Forum,  how do yo expect people to know what those variables or functions are in ELD,  perhaps if you could explain what they are in ELD then people will be able to give the equivalent in mql4 . . . 
 
phenix77:
Hello.

can you tell me what is the equivalent instructions MQL4 then I think I could pass a convert this ELD in MQL4 code

LastBarOnChart

Array_SetMaxIndex

barnumber 

Value1 ,Value2  


Easy Language:  http://www.zjtmqh.com/UploadFile/20120626103731.pdf

 LastBarOnChart  -  there is no mql4 equivalnt, you can easily create your own.

 Array_SetMaxIndex  -  ArrayResize()

 barnumber  -  not sure

 Value1 ,Value2    -  these are variables,  declare your own  double Value1 ,Value2;  

 

thank you very much RaptorUK.
I am not competent enough to create that kind of thing.
I'll start all over again and I will decompose the ELD program in 5 blocks and I'll try to translate block by block and I'll post my results here hoping your help when it is needed.
but I do not know how to translate and  barnumber LastBarOnChart  .
right here is the original code in 5 blocks and I'll do it block by block seems more logical.
thank you again for your help.
friendly

 

 

  // START BLOC 1

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;

 // END BLOC 1


//Now decompose data into the polynomial set and determine the overlap coefficients:

 // START BLOC 2

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];
                print(" Coefficient= " ,Coefficient[p]:5:5 ); 
                print(" TimeSeries= " ,TimeSeries[Width-j]:5:5 ); 
                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  = " ,PredictedEdge :5:5 ); 
       print(" LeadingEdge = " ,LeadingEdge :5:5 ); 
end;

 // END BLOC 2

//Plotting routines

 // START BLOC 3

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;

 // END BLOC 3
 
        
//////////////////////////////////////////////////////////////////////////////////////////////////
//
//      Create the Orthoginal Legendre Polynomials during the first bar, including ForwardExtension data
//
//////////////////////////////////////////////////////////////////////////////////////////////////      


 // START BLOC 4
 
 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; 

 // END BLOC 4


//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]:

 // START BLOC 5

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; // FIN if barnumber = 1

 // END BLOC 5 
 
 
 
 
Good afternoon.
unnecessary to answer my questions the solution was given me a Russian forum and without moral lesson :-)
not to say Russian programmers are by far the best anyway I do not think this forum was the level to answer me except with blabla.
good luck.
 
phenix77:
Good afternoon.
unnecessary to answer my questions the solution was given me a Russian forum and without moral lesson :-)
not to say Russian programmers are by far the best anyway I do not think this forum was the level to answer me except with blabla.
good luck.
You are welcome . . . 
 

Hello dd.

Could you share the working indicator please ?

Reason: