龙听期货论坛's Archiver

龙听 发表于 2022-11-2 13:22

【StandardError】

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

var0 = CurrentBar;

IF CurrentBar > Len Then Begin
        var4 = Summation(var0 * PriceValue, Len) - (Len * Average(var0, Len) * Average(PriceValue, Len));
        var5 = Summation(Square(var0), Len) - (Len * Square(Average(var0, Len)));
        var3 = var4 / var5;
        var2 = Average(PriceValue, Len) - (var3 * Average(var0, Len));
        var6 = (Summation(Square(PriceValue), Len)) - ((var2 * Summation(PriceValue, Len))) - ((var3 * Summation(var0 * PriceValue, Len)));
        var7 = Len - 2;
        var8 = (var6 / var7);
        IF var8 > 0 Then
                var1 = SquareRoot(var6 / var7)
        Else
                var1 = var1[1];

        StandardError = 2 * Average(var1, Smooth);
End;
[/code]

页: [1]