字符表达说明
数组:由大写字母组成,例如:BBI, BIAS, BOLL, CLOSE, OPEN
数值:由小写字母组成,例如:bbi, bias, boll, close, open
数组与数值关系表达示例:BBI = [ bbi ]
当日数值位置表达为[0], 例如:CLOSE[0]
上一交易日数值位置表达为[1], 例如:CLOSE[1]
以此类推,倒数第n日数值表达示例:CLOSE[n]
时间(天数)常量表达为: d1, d2, d3, d4, d5
函数 Average 表示求平均值
函数 Max 表示求最大值
函数 Min 表示求最小值
函数 Stddev 表示求标准均方差
BBI
sma1 = Average( BBI_d1, CLOSE )
sma2 = Average( BBI_d2, CLOSE )
sma3 = Average( BBI_d3, CLOSE )
sma4 = Average( BBI_d4, CLOSE )
bbi = ( sma1+ sma2 + sma3+ sma4) / 4.0
BBI = [ bbi ]
BIAS
sma1 = Average( BIAS_d1, CLOSE )
sma2 = Average( BIAS_d2, CLOSE )
sma3 = Average( BIAS_d3, CLOSE )
bias1 = ( close / sma1 - 1 ) * 100.0
bias2 = ( close / sma2 - 1 ) * 100.0
bias3 = ( close / sma3 - 1 ) * 100.0
BIAS1 = [ bias1 ]
BIAS2 = [ bias2 ]
BIAS3 = [ bias3 ]
BOLL
mid = Average( BOLL_d, CLOSE )
stddev = Stddev( BOLL_d, mid, CLOSE )
upper = mid + BOLL_k * stddev
lower = mid - BOLL_k * stddev
BOLL_MID = [ mid ]
BOLL_UPPER = [ upper ]
BOLL_LOWER = [lower ]
BRAR
ho = high - OPEN[1]
ol = OPEN[1] - low
for(size_t i = 0; i< OPEN.size(); i++)
{
sum_ho += ho;
sum_ol += ol;
}
SUM_HO = [ sum_ho ]
SUM_OL = [ sum_ol ]
ar = 100.0 * ( sum_ho - SUM_HO[BRAR_d] ) / ( sum_ol - SUM_OL[BRAR_d] )
arsma = Average(BRAR_SMA_d, BRAR_AR)
hc = high - CLOSE[1]
cl = CLOSE[1] - low
for(size_t i = 0; i< CLOSE.size(); i++)
{
sum_hc += hc;
sum_cl += cl;
}
SUM_HC = [ sum_hc ]
SUM_CL = [sum_cl ]
br = 100.0 * ( sum_hc - SUM_HC[BRAR_d] ) / ( sum_cl - SUM_CL[BRAR_d] )
brsma = Average( BRAR_SMA_d, BRAR_BR )
BRAR_AR = [ ar ]
BRAR_BR = [ br ]
BRAR_ARSMA = [ arsma ]
BRAR_BRSMA = [ brsma ]
CCI
tp = ( high + low + close ) / 3.0
TP = [ tp ]
tpsma = Average( CCI_d, TP )
md = |tp - tpsma|
MD = [ md ]
mdsma = Average( CCI_d, MD )
cci = ( tp - tpsma ) / md / 0.015
CCI = [cci ]
CHG
chg = 100.0 * ( CLOSE[0] / CLOSE[1] - 1 )
CHG = [ chg ]
CR
ym = ( HIGH[1] + LOW[1] + CLOSE[1] ) / 3.0
dif1 = high - ym
dif2 = ym - low
DIF1 = [ dif1 ]
DIF2 = [ dif2 ]
if( dif2 == 0 ) { cr = 0 }
else { cr = 100 * dif1 / dif2 }
if( cr < 0 ) { cr = 0 }
CR = [ cr ]
DMA
sma1 = Average( DMA_d1, CLOSE )
sma2 = Average( DMA_d2, CLOSE )
dif = sma1 - sma2
DMA_DIF = [ dif ]
ama = Average( DMA_d2, DMA_DIF )
DMA_AMA = [ ama ]
DPO
sma = Average( DPO_d / 2 + 1, CLOSE )
dpo = close - sma
dposma = Average( DPO_SMA_d, DPO)
DPO = [ dpo ]
DPO_SMA = [ dposma ]
EMA
ema1 = EMA1[1] * ( EMA_d1 - 1 ) / ( EMA_d1 + 1 ) + close * 2 / ( EMA_d1 + 1 )
ema2 = EMA2[1] * ( EMA_d2 - 1 ) / ( EMA_d2 + 1 ) + close * 2 / ( EMA_d2 + 1 )
EMA1 = [ ema1 ]
EMA2 = [ ema2 ]
ENE
ene = Average( ENE_d, CLOSE )
upper = ( 1 + ENE_M1 / 100.0 ) * ene
lower = ( 1 - ENE_M2 /100.0 ) * ene
ENE = [ ene ]
ENE_UPPER = [ upper ]
ENE_LOWER = [ lower ]
KDJ
hx = Max( KDJ_d1, HIGH )
ln = Min( KDJ_d1, LOW )
rsv = 100.0 * ( close - ln ) / ( hx - ln )
k = K[1] * ( KDJ_d2 - 1 ) / KDJ_d2 + rsv * 1 / KDJ_d2
d = D[1] * ( KDJ_d3 - 1 ) / KDJ_d3 + k * 1 / KDJ_d3
j = 3.0 * KDJ_k - 2.0 * d
KDJ_K = [ k ]
KDJ_D = [ d ]
KDJ_J = [ j ]
MACD
ema1 = EMA[1] * ( MACD_d1 - 1 ) / ( MACD_d1 + 1 ) + close * 2 / ( MACD_d1 + 1 )
ema2 = EMA[1] * ( MACD_d2 - 1 ) / ( MACD_d2 + 1 ) + close * 2 / ( MACD_d2 + 1 )
dif = ema1 - ema2
dea = DEA[1] * ( MACD_d3 - 1 ) / ( MACD_d3 + 1 ) + dif * 2 / (MACD_d3 + 1 )
macd = 2 * ( dif - dea )
MACD_DEF = [ def ]
MACD_DEA = [ dea ]
MACD = [ macd ]
MAX
max1 = Max( MAX_d1, CLOSE )
max2 = Max( MAX_d2, CLOSE )
max3 = Max( MAX_d3, CLOSE )
max4 = Max( MAX_d4, CLOSE )
max5 = Max( MAX_d5, CLOSE )
MAX1 = [ max1 ]
MAX2 = [ max2 ]
MAX3 = [ max3 ]
MAX4 = [ max4 ]
MAX5 = [ max5 ]
MIN
min1 = Min( MIN_d1, CLOSE )
min2 = Min( MIN_d2, CLOSE )
min3 = Min( MIN_d3, CLOSE )
min4 = Min( MIN_d4, CLOSE )
min5 = Min( MIN_d5, CLOSE )
MIN1 = [ min1 ]
MIN2 = [ min2 ]
MIN3 = [ min3 ]
MIN4 = [ min4 ]
MIN5 = [ min5 ]
MTM
mtm = 100 * ( close / CLOSES[MTM_d] - 1 )
mtmsma = Average( MTM_SMA_d, MTM )
MTM = [ mtm ]
MTM_SMA = [ mtmsma ]
OBV
if ( close > CLOSE[1] ) { obv = OBV[1] + volume }
else if ( close < CLOSE[1] ) { obv = OBV[1] - volume }
else { obv = OBV[1] }
obvsma = Average( OBV_SMA_d, OBV )
OBV = [ obv ]
OBVSMA = [ obvsma ]
PI
ln = Min( PI1_d1, LOW )
hx = Max( PI1_d2, HIGH )
pi1 = -100.0 * ( ln / hx - 1 )
ln = Min( PI2_d1, LOW )
hx = Max( PI2_d2, HIGH )
pi2 = -100.0 * ( ln / hx - 1 )
PI1 = [ pi1 ]
PI2 = [ pi2 ]
RSI
for( int i = RSI_d - d + 1; i < RSI_d + 1; i++ )
{
chg = CLOSE[i] - CLOSE[i - 1]
if( chg > 0 ) { sum1 + = chg }
else { sum2 += abs( chg ) }
}
ma1 = sum1 / RSI_d
ma2 = sum2 / RSI_d
MA1 = [ ma1 ]
MA2 = [ma2 ]
if( chg > 0 ) { averagegain = MA1[1] * (RSI_d - 1) / RSI_d + chg / RSI_d }
else { averagegain = MA1[1] * (RSI_d - 1) / RSI_d }
if( chg < 0 ) { averageloss = MA2[1] * (RSI_d - 1) / RSI_d - chg / RSI_d }
else { averageloss = MA2[1] * (RSI_d - 1) / RSI_d }
if( averageloss != 0) { rsi = 100 - ( 100 / ( 1 + averagegain / averageloss ) ) }
else { rsi = 100 }
RSI = [ rsi ]
SI
rate = 100.0 * ( close/ SMA3[1] - 1 )
si1 = Max( SI_d1, RATE )
si2 = Max( SI_d2, RATE )
SI1 = [ si1 ]
SI2 = [si2 ]
SMA
sma1 = Average( SMA_d1, CLOSE )
sma2 = Average( SMA_d2, CLOSE )
sma3 = Average( SMA_d3, CLOSE )
sma4 = Average( SMA_d4, CLOSE )
sma5 = Average( SMA_d5, CLOSE )
SMA1 = [ sma1 ]
SMA2 = [ sma2 ]
SMA3 = [ sma3 ]
SMA4 = [ sma4 ]
SMA5 = [ sma5 ]
SMAC
for( int i = 0; i < d; i++)
{
if( SMA[i] < SMA[i-1]) smac ++;
}
SMAC = [ smac ]
VOL
vol1 = Average( VOL_d1, VOLUME )
vol2 = Average( VOL_d2, VOLUME )
vol3 = Average( VOL_d3, VOLUME )
vol4 = Average( VOL_d4, VOLUME )
vol5 = Average( VOL_d5, VOLUME )
VOL1 = [ vol1 ]
VOL2 = [ vol2 ]
VOL3 = [ vol3 ]
VOL4 = [ vol4 ]
VOL5 = [ vol5 ]
VOLMAX
volmax1 = Max( MAX_d1, VOLUME )
volmax2 = Max( MAX_d2, VOLUME )
volmax3 = Max( MAX_d3, VOLUME )
volmax4 = Max( MAX_d4, VOLUME )
volmax5 = Max( MAX_d5, VOLUME )
VOLMAX1 = [ volmax1 ]
VOLMAX2 = [ volmax2 ]
VOLMAX3 = [ volmax3 ]
VOLMAX4 = [ volmax4 ]
VOLMAX5 = [ volmax5 ]
VOLMIN
volmin1 = Min( MIN_d1, VOLUME )
volmin2 = Min( MIN_d2, VOLUME )
volmin3 = Min( MIN_d3, VOLUME )
volmin4 = Min( MIN_d4, VOLUME )
volmin5 = Min( MIN_d5, VOLUME )
VOLMIN1 = [ volmin1 ]
VOLMIN2 = [ volmin2 ]
VOLMIN3 = [ volmin3 ]
VOLMIN4 = [ volmin4 ]
VOLMIN5 = [ volmin5 ]
VR
if( CLOSE[1] < close ) { av += volume }
else if( CLOSE[1] > close ) { bv += volume }
else { cv += volume }
AV = [ av ]
BV = [ bv ]
CV = [ cv ]
vr = 100.0 * ( ( av - AV[VR_d] ) + 0.5 * ( cv - CV[VR_d] ) ) / ( ( bv -BV[VR_d] ) + 0.5 * ( cv - CV[VR_d] ) )
VR = [ vr ]
vrsma = Average( VR_SMA_d, VR )
VRSMA = [ vrsma ]
WR
Hx = Max( WR_d1, HIGH )
Ln = Min( WR_d1, LOW )
wr1 = 100.0 * ( Hx - close ) / ( Hx - Ln )
Hx = Max( WR_d2, HIGH )
Ln = Min( WR_d2, LOW )
wr2 = 100.0 * ( Hx - close ) / ( Hx - Ln )
WR1 = [ wr1 ]
WR2 = [ wr2 ]