龙听期货论坛's Archiver

龙听 发表于 2022-11-2 10:32

【LinearRegLine】

[code]Inputs: Len(Numeric), BarsPlus(Numeric), SlctDate(Numeric), SlctTime(Numeric), Color(Numeric), ExtRight(TrueFalse);
Variables: var0(0), var1(0), var2(0), var3(0);

var0 = LinearRegValue(Close, Len, BarsPlus);
var1 = LinearRegValue(Close, Len, Len-1);

condition1 = LastBarOnChart AND SlctDate = 0 AND var3 = 0 ;
If condition1 Then Begin
        var2 = TL_New(Date[Len-1], Time[Len-1], var1, Date, Time, var0);
        var3 = 1;
End;
condition1 = Date = SlctDate AND (Time = SlctTime OR SlctTime = 0) ;
If condition1 Then Begin
        var2 = TL_New(Date[Len-1], Time[Len-1], var1, Date, Time, var0);
        var3 = 2;
End;
condition1 = var3 = 1 OR var3 = 2 ;
If condition1 Then Begin
        If var3 = 2 Then
                var3 = 3;
        TL_SetColor(var2, Color);
        TL_SetExtLeft(var2, False);
        If ExtRight Then
                TL_SetExtRight(var2, True)
        Else
                TL_SetExtRight(var2, False);
End;

If var3 = 1 Then Begin
        TL_SetBegin(var2, Date[Len-1], Time[Len-1], var1);
        TL_SetEnd(var2, Date, Time, var0);
End;

If var0 <> -1 Then
        LinearRegLine = 1
Else
        LinearRegLine = -1;
[/code]

页: [1]