- UID
- 2
- 积分
- 2874604
- 威望
- 1387331 布
- 龙e币
- 1487273 刀
- 在线时间
- 13155 小时
- 注册时间
- 2009-12-3
- 最后登录
- 2024-11-24
|
【Stochastic】
- inputs:
- PriceValueH( numericseries ),
- PriceValueL( numericseries ),
- PriceValueC( numericseries ),
- StochLen( numericsimple ),
- Len1( numericsimple ),
-
- Len2( numericsimple ),
-
- SmoothingType( numericsimple ),
-
- oFastK( numericref ),
- oFastD( numericref ),
- oSlowK( numericref ),
- oSlowD( numericref ) ;
- variables:
- var0( 0 ),
- var1( 0 ),
- var2( 0 ),
- var3( 0 ),
- var4( 0 ),
- var5( 0 ),
- var6( 0 ),
- var7( 0 ) ;
- Stochastic = 1 ;
- var0 = Lowest( PriceValueL, StochLen ) ;
- var1 = Highest( PriceValueH, StochLen ) ;
- var2 = PriceValueC - var0 ;
- var3 = var1 - var0 ;
- if var3 > 0 then
- oFastK = var2 / var3 * 100
- else
- begin
- oFastK = 0 ;
- Stochastic = -1 ;
- end ;
- if SmoothingType = 1 then
- begin
- var6 = Len1 - CurrentBar ;
- condition1 = var6 > 0 and CurrentBar > 0;
- if condition1 then
- begin
-
- var4 = ( Cum( var2 ) + var6 * var2[ CurrentBar - 1 ] ) / Len1 ;
- var5 = ( Cum( var3 ) + var6 * var3[ CurrentBar - 1 ] ) / Len1 ;
- end
- else
- begin
- var4 = Average( var2, Len1 ) ;
- var5 = Average( var3, Len1 ) ;
- end ;
- if var5 > 0 then
- oFastD = var4 / var5 * 100
- else
- begin
- oFastD = 0 ;
- Stochastic = -1 ;
- end ;
- var7 = Len2 - CurrentBar ;
- condition1 = var7 > 0 and CurrentBar > 0 ;
- if condition1 then
-
- oSlowD = ( Cum( oFastD ) + var7 * oFastD[ CurrentBar - 1 ] ) / Len2
- else
- oSlowD = Average( oFastD, Len2 ) ;
- end
- else if SmoothingType = 2 then
- begin
- oFastD = XAverage( oFastK, Len1 ) ;
- oSlowD = XAverageOrig( oFastD, Len2 ) ;
- end ;
- oSlowK = oFastD ;
复制代码 |
论坛官方微信、群(期货热点、量化探讨、开户与绑定实盘)
|