View Single Post
  #1 (permalink)  
Old 05-29-2006, 06:36 PM
Devil2000 Devil2000 is offline
Senior Member
 
Join Date: Dec 2005
Location: In front of my trading desk
Posts: 344
Devil2000 is on a distinguished road
Linear Regression Indicator

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
Reply With Quote