Nonlagging Tools - page 48

 
zilliq:
We use radian too

May be an explanation: In the MT4 code we multiply alfa with price

I suppose this is the price, i périods before, no ?

And so we need to add, for example with a len of 5

alfa*close[4]+alfa*close[3]+alfa*close[2]+alfa*close[1] and alfa*close

or

alfa[4]*close[4]+alfa[3]*close[3]+alfa[2]*close[2]+alfa[1]*close[1] and alfa*close ?

And it's strange, because with a length of 1 the len is equal to 4 (4*1+0) and so the nonlagma can't be equal to close because we add the alfa*price of the last 4 periods

Thanks for your next comments

Zilliq

Is use your code, but to better understand I use the simpliest code of the NonlagMav3

double pi = 3.1415926535;

double Coeff = 3*pi;

int Phase = Length-1;

double Len = Length*Cycle + Phase;

if ( counted_bars > 0 ) limit=Bars-counted_bars;

if ( counted_bars < 0 ) return(0);

if ( counted_bars ==0 ) limit=Bars-Len-1;

for(shift=limit;shift>=0;shift--)

{

Weight=0; Sum=0; t=0;

for (i=0;i<=Len-1;i++)

{

g = 1.0/(Coeff*t+1);

if (t <= 0.5 ) g = 1;

beta = MathCos(pi*t);

alfa = g * beta;

price = iMA(NULL,0,1,0,MODE_SMA,Price,shift+i);

Sum += alfa*price;

Weight += alfa;

if ( t < 1 ) t += 1.0/(Phase-1);

else if ( t < Len-1 ) t += (2*Cycle-1)/(Cycle*Length-1);

}

if (Weight > 0) MABuffer[shift] = Sum/Weight;

You should use the alfa[4]*close[4]+alfa[3]*close[3]+alfa[2]*close[2]+alfa[1]*close[1] and alfa*close form (alpha is different for each element)

Why don't you make a simple version that displays values of alphas and compare those to values of alphas in metatrader 4?

 

Thanks Mladen,

I will try this

In fact on MT4, I have the cfd price of my broker (Activtrade), and on Prorealtime this is another flux in Cash, so there are some big difference

Thanks a lot and See U later

Zilliq

 

Well, I try many many different things but it doesn't work and I defintively doesn't know why

My code seems to be ok:

****************************

weight=0

sum=0

for i=0 to Len

if i<=Phase-1 then

t = 1.0*i/(Phase-1)

else

t = 1.0 + (i-Phase+1)*(2.0*Cyclee-1.0)/(Cyclee*Length-1.0)

endif

beta = Cos(pi*t)

g = 1.0/(Coeff*t+1)

if t <= 0.5 then

g = 1

endif

alfa = g * beta

sum=sum+alfa*close

weight=weight+alfa

next

nonlagma=sum/weight

***************************

And similar to yours but as you see on my graph, the nonlagma is far far away from the close

Do you have an idea why, and do you have the NonlagMa code in Easy language (often easier to transcript) ???

Thanks a lot Mladen, I'm tired...

See U

Zilliq

Files:
 
zilliq:
Well, I try many many different things but it doesn't work and I defintively doesn't know why

My code seems to be ok:

****************************

weight=0

sum=0

for i=0 to Len

if i<=Phase-1 then

t = 1.0*i/(Phase-1)

else

t = 1.0 + (i-Phase+1)*(2.0*Cyclee-1.0)/(Cyclee*Length-1.0)

endif

beta = Cos(pi*t)

g = 1.0/(Coeff*t+1)

if t <= 0.5 then

g = 1

endif

alfa = g * beta

sum=sum+alfa*close

weight=weight+alfa

next

nonlagma=sum/weight

***************************

And similar to yours but as you see on my graph, the nonlagma is far far away from the close

Do you have an idea why, and do you have the NonlagMa code in Easy language (often easier to transcript) ???

Thanks a lot Mladen, I'm tired...

See U

Zilliq

Here is a version that calculates only the alphas : _nonlag_ma_alphas.mq4

Make something like that in protrader. Once they are the same, after that it should be easy to make the non lag ma the same too. The example is for period 50

Files:
 

Thanks a lot Mladen,

I will test with this first step

See U

Zilliq

 

Well,

First: good news I have the same EUR/USD as you as it will be easier to compare

But I don't succeed actually

Your code t ocalculate alpha is:

double Cycle = 4.0;

double Coeff = 3.0*Pi;

int Phase = NlmPeriod-1;

int len = NlmPeriod*4 + Phase;

if (ArraySize(alphas) != len) ArrayResize(alphas,len);

for (int k=0; k<len; k++)

{

if (k<=Phase-1)

double t = 1.0 * k/(Phase-1);

else t = 1.0 + (k-Phase+1)*(2.0*Cycle-1.0)/(Cycle*NlmPeriod-1.0);

double beta = MathCos(Pi*t);

double g = 1.0/(Coeff*t+1); if (t <= 0.5 ) g = 1;

alphas[k] = g * beta;

}

for(int i=len-1; i>=0; i--) nlm = alphas;

So, if I have well understand:

1/ First sted: It calculate all alphas from 0 to len-1

This is:

alphas[k] = g * beta;

2/ Second step, it adds all alphas from 0 to len-1

This is

for(int i=len-1; i>=0; i--) nlm = alphas;

The problem is that I have always the same alpha on my graph ? How can you have a different alpha on each candle as k, t and so on are always the same on each candles ?, and don't depends on the close ?

The code I have on Prorealtime seems to be the same:

Pi=3.14159265358979323846264338327950288

Cyclee = 4.0

Coeff = 3.0*Pi

Phase = NlmPeriod-1

len = NlmPeriod*4 + Phase

alph=0

for k=0 to len-1

t=0

if (k<=Phase-1) then

t = 1.0 * k/(Phase-1)

else

t = 1.0 + (k-Phase+1)*(2.0*Cyclee-1.0)/(Cyclee*NlmPeriod-1.0)

endif

beta = Cos(Pi*t)

g = 1.0/(Coeff*t+1)

if (t <= 0.5 ) then

g = 1

endif

alphas= g * beta

alph=alph+alphas

next

 
zilliq:
Well,

First: good news I have the same EUR/USD as you as it will be easier to compare

But I don't succeed actually

Your code t ocalculate alpha is:

double Cycle = 4.0;

double Coeff = 3.0*Pi;

int Phase = NlmPeriod-1;

int len = NlmPeriod*4 + Phase;

if (ArraySize(alphas) != len) ArrayResize(alphas,len);

for (int k=0; k<len; k++)

{

if (k<=Phase-1)

double t = 1.0 * k/(Phase-1);

else t = 1.0 + (k-Phase+1)*(2.0*Cycle-1.0)/(Cycle*NlmPeriod-1.0);

double beta = MathCos(Pi*t);

double g = 1.0/(Coeff*t+1); if (t <= 0.5 ) g = 1;

alphas[k] = g * beta;

}

for(int i=len-1; i>=0; i--) nlm = alphas;

So, if I have well understand:

1/ First sted: It calculate all alphas from 0 to len-1

This is:

alphas[k] = g * beta;

2/ Second step, it adds all alphas from 0 to len-1

This is

for(int i=len-1; i>=0; i--) nlm = alphas;

The problem is that I have always the same alpha on my graph ? How can you have a different alpha on each candle as k, t and so on are always the same on each candles ?, and don't depends on the close ?

The code I have on Prorealtime seems to be the same:

Pi=3.14159265358979323846264338327950288

Cyclee = 4.0

Coeff = 3.0*Pi

Phase = NlmPeriod-1

len = NlmPeriod*4 + Phase

alph=0

for k=0 to len-1

t=0

if (k<=Phase-1) then

t = 1.0 * k/(Phase-1)

else

t = 1.0 + (k-Phase+1)*(2.0*Cyclee-1.0)/(Cyclee*NlmPeriod-1.0)

endif

beta = Cos(Pi*t)

g = 1.0/(Coeff*t+1)

if (t <= 0.5 ) then

g = 1

endif

alphas= g * beta

alph=alph+alphas

next

Zilliq

As I told : there is an array of aplhas

What I displayed there is an array of alphas - disregard the time component. Those are values of each and every alpha value in the array of alphas, Those are the weights that are applied to each price element that you use for calculation

 

I probably don't understand what you call array of alphas (I understand different alphas on each candle), sorry

I will try one more time...

 
zilliq:

I probably don't understand what you call array of alphas (I understand different alphas on each candle), sorry

I will try one more time...

Zilliq

Coefficient (alpha) for price 0 == 1

Coefficient (alpha) for price 1 == 0.9nnnnn

and so on (as it is displayed by the non lag ma alphas indicator) and all that used for the len prices to get the current non lag ma value

 

Okay, I think I understand your explanations (you're great ) and I made differents tests on MT4 with your code

the alpha who as a different value from 1 to len-1 ponderate the price and at the end we divide by the summation of alphas

Thats why the first value of alphas to the right is always 1 and that's why evenv if we change ne nlm value the aspect of the alphas on the graph is always the same sort of snake)

Well, know I need to seek how I can do this on Prorealtime...