Help Converting Indicator

 

Hi,

I have an indicator which is in TradeStation.

I have already had the function written in MQL but the developer went awol. I hope that its simple to finish because the actual indicator is very simple.

In TradeStation this is the code

 

Inputs: 
                Price(Close),           
                Period(32),
                UpColour(green),
                DnColour(red);
        

Value1 = function1(Price, period, 2);

Plot1(Value1, "line");

{ Color criteria }
if Value1 > Value1[1] then 
                SetPlotColor[0]( 1, UpColour)
else if Value1 < Value1[1] then 
                SetPlotColor[0]( 1, DnColour )
else
                SetPlotColor[0]( 1, Cyan );

Now like

The part which says Value1 = function1(Price, period, 2);

This is the function here.

double function1 ( int CurrentBar, double Price, int iptPeriod, int iptPoles) {
static double  aa, b , w , y1 , y2 , y3 , y4 ,
    a_1 , a_12 , a_13 , a_14 , a2 , a3 , a4 ;
   double x = 0;
   double y = 0;
   int period = 2; 
   int poles = 0;
   double SQRT2 = MathSqrt(2.0);
   double pi=3.1415926535;


        if (iptPeriod < 2)  
                period = 2;
        else
                period = iptPeriod;
        
        
        if (iptPoles < 1) 
                poles = 1;
        else if (iptPoles > 4)
                poles = 4;
        else 
                poles = iptPoles;


         if (CurrentBar == MaxBarsBack) {
            w = 1.2222* 2.0 * pi / period; 
            //w = 220 * w / pi; // in degrees
            //w = w*pi/180.0;  // convert to radians  
            b = (1 - MathCos(w)) / (MathPow(SQRT2, 2.0/poles) - 1.0);
        
            aa = -b + MathSqrt(b*b + 2*b);
            a_1 = 1.0 - aa;
            a_12 = a_1 * a_1;
            a_13 = a_12 * a_1;
            a_14 = a_12 * a_12;
            a2 = aa * aa;
            a3 = aa * aa * aa;
            a4 = a2 * a2;
        
            y1 = Price;
            y2 = y1;
            y3 = y2;
            y4 = y3;
        }

        x = Price;
        
        if (poles == 1) 
                y = aa * x + a_1 * y1;
        else if (poles == 2) 
                y = a2 * x + 2 * a_1 * y1 - a_12 * y2;
        else if (poles == 3) 
                y = a3 * x + 3 * a_1 * y1 - 3 * a_12 * y2 + a_13 * y3;
        else if (poles == 4) 
                y = a4 * x + 4 * a_1 * y1 - 6 * a_12 * y2 + 4 * a_13 * y3 - a_14 * y4;
        
        if (New_Bar) {
          y4 = y3; 
          y3 = y2; 
          y2 = y1; 
          y1 = y;  
        } 
        
        return (y);
}

 

The work is almost done I just need to get this indicator to be put together so that it plots.

 Thanks

Kris 

 
kraziekris:

Hi,

I have an indicator which is in TradeStation.

I have already had the function written in MQL but the developer went awol. I hope that its simple to finish because the actual indicator is very simple.

In TradeStation this is the code

 

Now like

The part which says Value1 = function1(Price, period, 2);

This is the function here.

 

The work is almost done I just need to get this indicator to be put together so that it plots.

 Thanks

Kris 

Do you have a name for this indicator or filter?
 

all i know is its a moving average with a gausian filter. I have used it for years in tradestation but I have now moved back to MT4 because I prefer the automation.

 The tough part was getting the function coded the front end which draws the line is very simple but I cant work out how to put it all together.

 

 Here is a picture of what it should look like, im not too worried about the bar colour, just the line being drawn.

 

bool

 

have a look here(?):

https://www.mql5.com/en/code/10600

https://www.mql5.com/ru/code/10590

Beside that for almost not lagging ma google for ullma.mq4 (Ultra Low Lagging ma), HMA, JMA, ...

There has been so much code written for mt4 - you'll certainly find more than you need.

 

Hi,

 

I have now tested both of those, they are not as good at all, the code above gets you in much earliet than both.

Most of the coding is done above, the function is there for mt4 already

I just need the call and the drawing done!

 

I can pay someone if they can do it?

 
I dont even need the bars colouring just the line drawn.
 
click on the top of this page ->Freelance
 

Hi man, here is your ma :

Files:
Reason: