- UID
- 2
- 积分
- 2874664
- 威望
- 1387361 布
- 龙e币
- 1487303 刀
- 在线时间
- 13156 小时
- 注册时间
- 2009-12-3
- 最后登录
- 2024-11-24
|
【LinRegArray】
- inputs:
- PriceValueArray[MaxSize]( numericarray ),
- Size( numericsimple ),
- TgtPos( numericsimple ),
- oLRSlope( numericref ),
- oLRAngle( numericref ),
- oLRIntercept( numericref ),
- oLRValueRaw( numericref ) ;
-
-
- variables:
- var0( 0 ),
- var1( 0 ),
- var2( 0 ),
- var3( 0 ),
- var4( 1 / 6 ),
- var5( 0 ) ;
- if Size > 1 then
- begin
- var2 = Size * ( Size - 1 ) * .5 ;
- var3 = Size * ( Size - 1 ) * ( 2 * Size - 1 ) * var4 ;
- var5 = Square( var2 ) - Size * var3 ;
- var0 = 0;
- for Value1 = 1 to Size
- begin
- var0 = var0 + ( Value1 - 1 ) * PriceValueArray[Value1] ;
- end ;
- var1 = SummationArray( PriceValueArray, Size ) ;
- oLRSlope = ( Size * var0 - var2 * var1) / var5 ;
- oLRAngle = ArcTangent( oLRSlope ) ;
- oLRIntercept = ( var1 - oLRSlope * var2 ) / Size ;
- oLRValueRaw = oLRIntercept + oLRSlope * ( Size - 1 - TgtPos ) ;
- LinRegArray = 1 ;
- end
- else
- LinRegArray = -1 ;
复制代码 |
论坛官方微信、群(期货热点、量化探讨、开户与绑定实盘)
|