龙听期货论坛's Archiver

龙听 发表于 2022-11-1 13:02

【coeffR】

[code]Inputs: Len(Numeric);
Variables: var0(0), var1(0), var2(0), var3(0), var4(0), var5(0), var6(0);

var1 = CurrentBar;
var2 = Close;

var3 = Summation(var1 * var2, Len) - Len * Average(var1, Len) * Average(var2, Len);
var4 = Summation(Square(var1), Len) - Len * Square(Average(var1, Len));
var5 = Summation(Square(var2), Len) - Len * Square(Average(var2, Len));

If var4 * var5 > 0 Then
        var6 = SquareRoot(var4 * var5);

If var6 <> 0  Then Begin
        var0 = var3 / var6;
        condition1 = var0 <= 1 AND var0 >= -1 ;
        If condition1 Then
                coeffR = var0;
End;
[/code]

页: [1]