- UID
- 2
- 积分
- 2874674
- 威望
- 1387366 布
- 龙e币
- 1487308 刀
- 在线时间
- 13156 小时
- 注册时间
- 2009-12-3
- 最后登录
- 2024-11-24
|
【PercentRank】
- inputs:
- PriceValueToRank( numericsimple ),
- PriceValue( numericseries ),
- Len( numericsimple ) ;
- variables:
- var0( 0 ),
- var1( 0 ),
- var2( 0 ),
- var3( 0 ) ;
- arrays:
- arr0[1000]( 0 ) ;
- condition1 = Len > 1
- and PriceValueToRank >= Lowest( PriceValue, Len )
- and PriceValueToRank <= Highest( PriceValue, Len ) ;
- if condition1
- then
- begin
-
- for Value1 = 1 to Len
- begin
- arr0[Value1] = PriceValue[ Value1 - 1 ] ;
- end ;
- Value1 = SortArray( arr0, Len, -1 ) ;
-
- var0 = 1 / ( Len - 1 ) ;
-
-
-
- var1 = 0 ;
- for Value2 = 1 to Len
- begin
- if arr0[Value2] = PriceValueToRank then
- begin
- PercentRank = var0 * ( Value2 - 1 ) ;
- var1 = 1 ;
- Value2 = Len ;
- end ;
- end ;
-
- if var1 = 0 then
- begin
- for Value3 = 1 to Len - 1
- begin
- var2 = arr0[Value3] ;
- var3 = arr0[ Value3 + 1 ] ;
- condition1 = PriceValueToRank > var2 and PriceValueToRank < var3 ;
- if condition1 then
- begin
- PercentRank = var0 * ( ( Value3 - 1 ) + ( PriceValueToRank -
- var2 ) / ( var3 - var2 ) ) ;
- Value3 = Len - 1 ;
- end ;
- end ;
- end ;
- end
- else
- PercentRank = -1 ;
复制代码 |
论坛官方微信、群(期货热点、量化探讨、开户与绑定实盘)
|