Hi all, I just found a Linear Regression Indicator for metatrader, unfortunately it’s in mql, can somebody convert it to mq4? Any help is very appreciated.
Here is the code :
/*[[
Name := linear regression indicator
Author := Copyright e 2004, Nick Bilak, beluck[at]ukr.net
Link := http://bilak.port5.com
Separate Window := No
First Color := Red
First Draw Type := Line
Use Second Data := No
]]*/
Inputs : Rperiod(5);
Variables : shift(0), cnt(0), loopbegin(0), first(True), prevbars(0);
Variables : sum(0), length(0), i(0), mt(0), WT(0), vWT2(0),value(0);
SetLoopCount(0);
// initial checkings
If RPeriod < 1 Then Exit;
length=RPeriod;
loopbegin = 206-length-1;
For shift = loopbegin Downto 0 Begin
sum=0;
For i = length downTo 1 Begin
sum = sum + (i-(length+1)/3)*Close[length-i+shift];
End;
WT=sum*6/(length*(length+1));
SetIndexValue(shift,WT);
End;
Thank you