Pine to mql4 Question (WMA of BarIndex)

 

"Good evening

I have to convert a tradingview indicator to MQL4 for a friend.
I have to admitt I have not much experience in pine script, but till now it was enough to creat some indicators or convert some to MQL.

But the current one has some parts I don't understand completly.


Pine Code:

x = bar_index
y = input(ohlc4, type=input.source, title="Price")
x_ = wma(x, length)
y_ = wma(y, length)
mx = stdev(x, length)
my = stdev(y, length)
c = correlation(x, y, length)

Do I understand it correctly, he calculates the wheighted moving average out of the bar index?
Does that make sense? I don't get what's the use of that.

in MQL4 I would do that with the "IMAOnArray" function right?

Does someone undertsand what the TV coder did here?
If someone can convert it it would be great :D But no worrys I don't want you to do the jop for me, if someone can explain this little code it would already help me a lot :)


This is the output of the indicator: (I didn't paste the whole code, only the parts wich are important)


 
Lukas Roth: I have to convert a tradingview indicator to MQL4 for a friend.

I have to admitt I have not much experience in pine script, but till now it was enough to creat some indicators or convert some to MQL.

But the current one has some parts I don't understand completly.

Pine Code:

Do I understand it correctly, he calculates the wheighted moving average out of the bar index?
Does that make sense? I don't get what's the use of that.

in MQL4 I would do that with the "IMAOnArray" function right?

Does someone undertsand what the TV coder did here?
If someone can convert it it would be great :D But no worrys I don't want you to do the jop for me, if someone can explain this little code it would already help me a lot :)

This is the output of the indicator: (I didn't paste the whole code, only the parts wich are important)

To me, it does not make sense for you to be asking about PineScript on the MQL forum.

Did you consider asking these questions on their forum?

Or how about reading the PineScript documentation about those variables or functions being used?

EDIT: I added links here to the relevant PineScript documentation references but the site blocks them.
 
Fernando Carreiro:

To me, it does not make sense for you to be asking about PineScript on the MQL forum.

Did you consider asking these questions on their forum?

Or how about reading the PineScript documentation about those variables or functions being used?

EDIT: I added links here to the relevant PineScript documentation references but the site blocks them.

I asked the question here, because I want to convert it into MQL4.

It's not that I don't undertand the function itself. It's more that I don't get why the coder did it.

x = bar_index			//gets the current bar index, --> MQL4 --> iBars(...)
x_ = wma(x, length)		//Calculates the WMA, --> MQL4 --> iMA(..., MODE_LWMA, ...)

I don't see a reason to calculate the wma out of barindex... You know what i mean?

 
Lukas Roth: It's not that I don't undertand the function itself. It's more that I don't get why the coder did it. I don't see a reason to calculate the wma out of barindex... You know what i mean?

Then that is even more reason for you to ask those questions on their forum. They will have more knowledge and more experience with it than us.

What you are doing now is like asking on an Apple forum about Windows functions you don't understand.

 
It seems the pine script calculates the correlation of the price to the length.
This is a calculation to a linear value.

Try to imagine you plot this to a graph. It makes some sense, in some way.

I would guess the developer is using the periods or length as a bias to calculate the correlation to a linear development and the price development.




 
Dominik Egert:
It seems the pine script calculates the correlation of the price to the length.
This is a calculation to a linear value.

Try to imagine you plot this to a graph. It makes some sense, in some way.

I would guess the developer is using the periods or length as a bias to calculate the correlation to a linear development and the price development.




Okey this really makes sense now :D

Thak you very much! just needed that little kick in the right direction :)

Reason: