- UID
- 2
- 积分
- 2893117
- 威望
- 1396590 布
- 龙e币
- 1496527 刀
- 在线时间
- 13326 小时
- 注册时间
- 2009-12-3
- 最后登录
- 2024-12-26
|
【LinearReg】
- inputs:
- PriceValue( numericseries ),
- Len( numericsimple ),
- TgtBar( numericsimple ),
- oLRSlope( numericref ),
- oLRAngle( numericref ),
- oLRIntercept( numericref ),
-
- oLRValue( numericref ) ;
- variables:
- var0( 0 ),
- var1( 0 ),
- var2( 0 ),
- var3( 0 ),
- var4( 1 / 6 ),
- var5( 0 ) ;
- if Len > 1 then
- begin
- var2 = Len * ( Len - 1 ) * .5 ;
- var3 = Len * ( Len - 1 ) * ( 2 * Len - 1 ) * var4 ;
- var5 = Square( var2 ) - Len * var3 ;
- var0 = 0;
- for Value1 = 0 to Len - 1
- begin
- var0 = var0 + Value1 * PriceValue[Value1] ;
- end ;
- var1 = Summation( PriceValue, Len ) ;
- oLRSlope = ( Len * var0 - var2 * var1) / var5 ;
- oLRAngle = ArcTangent( oLRSlope ) ;
- oLRIntercept = ( var1 - oLRSlope * var2 ) / Len ;
- oLRValue = oLRIntercept + oLRSlope * ( Len - 1 + ExecOffset - TgtBar ) ;
- LinearReg = 1 ;
- end
- else
- LinearReg = -1 ;
复制代码 |
论坛官方微信、群(期货热点、量化探讨、开户与绑定实盘)
|