K线指标线计算方法
指标线计算方法
l dataDR = Kdata(原始数据)/dr(除权) //除权数据等于原始数据除以DR(除权) 其中,日K数据 需要本地进行除权处理。周K和月K的旧数据部分由服务器进行处理,新数据部分是需要本地进行处理的。使用DR数据时需要检查是否需要去掉预先给的DR数据。
l K线MA5 : 5天收盘价平均值
l K线MA10: 10天收盘价平均值
l K线MA20: 20天收盘价平均值
l K线MA60: 60天收盘价平均值
l 成交量MA5 : 5天成交量平均值
l 成交量MA10: 10天成交量平均值
l 成交量MA20: 20天成交量平均值
l 成交量MA60: 60天成交量平均值
l MACD: 需要使用数据:dataDR
定义参数:SHORT = 12, MID = 9, LONG = 26;
MACD_LARGER = 100; // 缩放因子
变量:DI, EMA_DI_SHORT, EMA_DI_LONG, DEA
len = KData.length //数据的长度
计算:
//计算每个数据的DIF,DEA,BAR三条线的数值
for(int i= 0 ;i<len;i++)
{
DI = MACD_LARGER * (dataDR[high]+ dataDR[low]+ dataDR[close]*2*0.25);
If(i==0)
{
EMA_DI_SHORT = DI;
EMA_DI_LONG = DI;
}
Else
{
EMA_DI_SHORT = EMA_DI_SHORT + (DI - EMA_DI_SHORT) * shortRate;
EMA_DI_LONG = EMA_DI_LONG + (DI - EMA_DI_LONG) * longRate;
}
DIF值= ((EMA_DI_SHORT - EMA_DI_LONG) / EMA_DI_LONG) * MACD_LARGER;
if (i == 0) {
DEA值 =DIF值;
} else {
DEA 值= DEA值 + (DIF值- DEA值) * (2.0 / MID);
}
BAR值= DIF值-DEA值;
}
l KDJ: 需要使用数据:dataDR KData (原始数据)
定义参数:RSVCyc = 9, KCyc = 3, DCyc = 3;
highWindow 数组, lowWindow 数组;
maxValue, minValue;
RSV, K, KB, D, DB, J, JB;
curClosePrice;
len = KData.length //数据的长度
计算://计算每个数据K 、D、 J值
//初始化
for (int i = 0; i < RSVCyc; i++) {
highWindow[i] = data[high] [0](第0个元素);
lowWindow[i] = data [low][0] (第0个元素);
}
KB = 50;
DB = 50;
JB = 50;
//计算
for(int i= 1;i< len;i++)
{
curClosePrice = dataDR [close];
if(curClosePrice<=0)
{
K值=50;
D 值= 50;
J值=50;
}
else
{
highWindow[i % RSVCyc] = dataDR [high];
lowWindow[i % RSVCyc] = dataDR [low];
maxValue = highWindow中最大值;
minValue = lowWindow 中最小值;
if(maxValue> minValue)
{
RSV = (curClosePrice - minValue) / (maxValue - minValue) * 100.0;
K值 = KB * (KCyc - 1) / KCyc + RSV / KCyc;
D 值= DB * (DCyc - 1) / DCyc + K / DCyc;
J 值= K * DCyc - D * (DCyc - 1);
KB= K值;
DB= D值;
JB= J值;
}
else
{
K值 =50;
D 值=50;
J 值=50;
}
}
}
l RSI: 需要使用数据:dataDR
定义参数:closeArray数组 = dataDR[close];
cyc(取值6和12 : 6天或者12天);
curClosePrice, lastClosePrice;
RA, DA, RD;
len = KData.length //数据的长度
计算://计算出一条RSI线的各个数据值
RSI值 = 50 //初始化
RA = 0.1;
DA = 0.1;
for (int i = 1; i < len; i++) {
curClosePrice = closeArray[i];
lastClosePrice = closeArray[i - 1];
if (curClosePrice <= 0) {
RSI值 = 50;
} else {
if (curClosePrice > lastClosePrice) {
RD = curClosePrice / lastClosePrice - 1.0;
RA = RA * (cyc - 1.0) / cyc + RD / cyc;
DA = DA * (cyc - 1.0) / cyc;
} else {
RD = 1.0 - curClosePrice / lastClosePrice;
RA = RA * (cyc - 1.0) / cyc;
DA = DA * (cyc - 1.0) / cyc + RD / cyc;
}
RSI值= RA / (RA + DA) * 100.0;
}
}
l BIAS: 需要使用数据:dataDR
定义参数:closeArray数组 = dataDR[close];
cyc(取值5/10/20 :三条线);
closeMaArray;
len = KData.length //数据的长度
计算://计算一条bias线的各个值
closeMaArray = closeArray的每cyc个数据的平均值构成的数组;
for (i = 0; i < len; i++) {
bias值 = (closeArray[i] - closeMaArray[i]) / closeMaArray[i] * 100.0;
}
l CCI: 需要使用数据:dataDR
定义参数:Cyc = 14;
len = KData.length //数据的长度
TYPArray, maTYPArray, aveDevArray
计算:
for (int i = 0; i < len; i++) {
TYPArray [i] = (dataDR[high] + dataDR [low]+ dataDR[close]) / 3.0
}
maTYPArray = TYPArray的每cyc个数据的平均值构成的数组;
aveDevArray = 先求TYPArray和maTYPArray的每个数据之差的绝对值,然后每cyc个绝对值的平均值构成的数组。
for (int i = 1; i < len; i++) {
CCI值= (TYPArray [i] - maTYPArray [i]) / (0.015 * aveDevArray [i]);
}
l ROC: 需要使用数据:dataDR
定义参数:closeArray数组 = dataDR[close];
cyc1=12,cyc2 =6; (两条线);
rocArray(第一条线值的数组)
len = KData.length //数据的长度
计算:
第一条线:
rocArray前cyc1个数据赋值为0;
for (int i=cyc1; i < len; i++) {
rocArray[i] = ((closeArray[i] - closeArray[i – cyc1]) / closeArray[i – cyc1] * 100);
}
第二条线:
rocMArray = rocArray的每cyc2个数据的平均值构成的数组;
l ASI: 需要使用数据:dataDR
定义参数:lastClosePrice;
AA, BB, CC, DD, R, X, SI;
- openArr, highArr, lowArr, closeArr
len = KData.length //数据的长度
计算:
openArr = dataDR[open]数据构成的数组
highArr = dataDR[high]数据构成的数组
lowArr = dataDR[low]数据构成的数组
closeArr = dataDR[close]数据构成的数组
ASI值[0] = 0;
for (int i = 1; i < len; i++) {
lastClosePrice = closeArr[i - 1];
AA = (highArr[i] - lastClosePrice)的绝对值;
BB = (lowArr[i] - lastClosePrice) 的绝对值;
CC = (highArr[i] - lowArr[i - 1]) 的绝对值;
DD = (lastClosePrice - openArr[i - 1]) 的绝对值;
R = (AA > BB && AA > CC) ? (AA + BB / 2 + DD / 4) : (BB > CC && BB > AA ? (BB + AA / 2 + DD / 4) : (CC + DD / 4));
X = closeArr[i] + (closeArr[i] - openArr[i]) / 2 - openArr[i - 1];
if (R == 0.0) {
SI[i]=0;
} else {
SI[i]=(16 * X / R * max(AA, BB));
}
ASI值 = ASI值[i-1]+ SI[i];
}
l PSY: 需要使用数据:dataDR
定义参数:cyc = 12;
closeArr = dataDR[close]数据构成的数组
count
len = KData.length //数据的长度
计算:
for (int i = 1; i < cyc && i < len; i++) {
if (closeArr[i] > closeArr[i - 1]) {
count++;
}
PSY值= count / cyc * 100.0;
}
for (int i=cyc; i < len; i++) {
if (closeArr[i - cyc] > closeArr[i - cyc - 1]) {
count--;
}
if (closeArr[i] > closeArr[i - 1]) {
count++;
}
PSY值= count / cyc * 100.0;
}
#import "EzMakeLineData.h" @implementation EzMakeLineData +(NSMutableArray *)getLineData:(NSMutableArray *)data type:(int)type
{
NSMutableArray *lineDataArr = nil;
switch (type) {
case :
lineDataArr = [self getVolData:data];
break;
case :
lineDataArr = [self getMACDData:data];
break;
case :
lineDataArr = [self getKDJData:data];
break;
case :
lineDataArr = [self getRSIData:data];
break;
case :
lineDataArr = [self getBIASData:data];
break;
case :
lineDataArr = [self getCCIData:data];
break;
case :
lineDataArr = [self getROCData:data];
break;
case :
lineDataArr = [self getASIData:data];
break;
case :
lineDataArr = [self getPSYData:data];
break;
default:
break;
}
return lineDataArr;
} #pragma mark - 成交量
+(NSMutableArray *)getVolData:(NSMutableArray *)data
{
return data;
} #pragma mark - MACD
+(NSMutableArray *)getMACDData:(NSMutableArray *)data
{
//定义参数
CGFloat SHORT = ;
CGFloat MID = ;
CGFloat LONG = ;
CGFloat MACD_LARGER = ; //缩放因子
CGFloat DI;
CGFloat EMA_DI_SHORT = 0.0;
CGFloat EMA_DI_LONG = 0.0;
CGFloat DEA = 0.0;
CGFloat DIF;
CGFloat BAR;
CGFloat shortRate;
CGFloat longRate; NSMutableArray *arr = [[NSMutableArray alloc] initWithCapacity:];
if (SHORT == ) {
shortRate = 0.1538;
} else {
shortRate = 2.0 / (SHORT + );
} if (LONG == ) {
longRate = 0.0741;
} else {
longRate = 2.0 / (LONG + );
}
//计算每个数据的DIF,DEA,BAR三条线的数值
for(int i= ;i<data.count;i++)
{
NSMutableArray *subArr = data[i]; DI = MACD_LARGER * ([subArr[] floatValue]+ [subArr[] floatValue]+ [subArr[] floatValue]*)*0.25;
if(i==)
{
EMA_DI_SHORT = DI;
EMA_DI_LONG = DI;
}
else
{
EMA_DI_SHORT = EMA_DI_SHORT + (DI - EMA_DI_SHORT) * shortRate;
EMA_DI_LONG = EMA_DI_LONG + (DI - EMA_DI_LONG) * longRate;
}
DIF= ((EMA_DI_SHORT - EMA_DI_LONG) / EMA_DI_LONG) * MACD_LARGER;
if (i == ) {
DEA =DIF;
} else {
DEA= DEA + (DIF- DEA) * (2.0 / MID);
}
BAR= DIF-DEA; [subArr addObject:[NSNumber numberWithDouble:DIF]];
[subArr addObject:[NSNumber numberWithDouble:DEA]];
[subArr addObject:[NSNumber numberWithDouble:BAR]]; [arr addObject:subArr];
}
return arr;
} #pragma mark - KDJ
+(NSMutableArray *)getKDJData:(NSMutableArray *)data
{
//定义参数
CGFloat RSVCyc = ;
CGFloat KCyc = ;
CGFloat DCyc = ;
NSMutableArray *highWindow;
NSMutableArray *lowWindow ;
CGFloat maxValue;
CGFloat minValue;
CGFloat RSV, K, KB, D, DB, J, JB;
CGFloat curClosePrice; NSMutableArray *arr = [[NSMutableArray alloc] initWithCapacity:]; //计算每个数据K 、D、 J值
//初始化
highWindow = [[NSMutableArray alloc] initWithCapacity:];
lowWindow = [[NSMutableArray alloc] initWithCapacity:];
if (data.count>) { for (int i = ; i < RSVCyc; i++) {
highWindow[i] = [data[] objectAtIndex:]; //第0个元素的high
lowWindow[i] = [data[] objectAtIndex:]; //第0个元素的low
}
KB = ;
DB = ;
JB = ; NSMutableArray *subArr = data[];
[subArr addObject:[NSNumber numberWithDouble:]];
[subArr addObject:[NSNumber numberWithDouble:]];
[subArr addObject:[NSNumber numberWithDouble:]]; [arr addObject:subArr];
if (data.count>) {
//计算
for(int i= ;i<data.count;i++)
{
subArr = data[i];
curClosePrice = [subArr[] floatValue];
if(curClosePrice<=)
{
K=;
D= ;
J=;
}
else
{
highWindow[(int)fmod(i, RSVCyc)] = subArr[];
lowWindow[(int)fmod(i, RSVCyc)] = subArr[]; maxValue = [[highWindow valueForKeyPath:@"@max.floatValue"] floatValue];
minValue = [[lowWindow valueForKeyPath:@"@min.floatValue"] floatValue];
if(maxValue> minValue)
{
RSV = (curClosePrice - minValue) / (maxValue - minValue) * 100.0;
K = KB * (KCyc - ) / KCyc + RSV / KCyc;
D = DB * (DCyc - ) / DCyc + K / DCyc;
J = K * DCyc - D * (DCyc - );
KB= K;
DB= D;
JB= J;
}
else
{
K =;
D =;
J =; }
}
[subArr addObject:[NSNumber numberWithDouble:K]];
[subArr addObject:[NSNumber numberWithDouble:D]];
[subArr addObject:[NSNumber numberWithDouble:J]]; [arr addObject:subArr];
} }
} return arr;
} #pragma mark - RSI
+(NSMutableArray *)getRSIData:(NSMutableArray *)data
{
//定义参数
NSMutableArray *closeArray;
CGFloat cyc6 = ;
CGFloat cyc12 = ; //计算出一条RSI线的各个数据值
closeArray = [[NSMutableArray alloc] initWithCapacity:];
for(int i = ; i < data.count; i++) {
[closeArray addObject:[data[i] objectAtIndex:]] ;//第i个元素的close
} //RSI6
NSMutableArray *arr = [self makeRSI:data closeArray:closeArray cyc:cyc6];
//RSI12
arr = [self makeRSI:arr closeArray:closeArray cyc:cyc12];
return arr;
}
+(NSMutableArray *)makeRSI:(NSMutableArray *)data closeArray:(NSMutableArray *)closeArray cyc:(CGFloat)cyc
{
CGFloat curClosePrice;
CGFloat lastClosePrice;
CGFloat RA,DA,RD,RSI;
RSI = ;
RA = 0.1;
DA = 0.1; NSMutableArray *arr = [[NSMutableArray alloc] initWithCapacity:];
if (data.count>) {
NSMutableArray *subArr = data[];
[subArr addObject:[NSNumber numberWithDouble:RSI]];
[arr addObject:subArr]; for(int i = ;i<data.count;i++) {
subArr = data[i];
curClosePrice = [closeArray[i] floatValue];
lastClosePrice = [closeArray[i - ] floatValue]; if (curClosePrice <= ) {
RSI = ;
} else {
if (curClosePrice > lastClosePrice) {
RD = curClosePrice / lastClosePrice - 1.0;
RA = RA * (cyc - 1.0) / cyc + RD / cyc;
DA = DA * (cyc - 1.0) / cyc;
} else {
RD = 1.0 - curClosePrice / lastClosePrice;
RA = RA * (cyc - 1.0) / cyc;
DA = DA * (cyc - 1.0) / cyc + RD / cyc;
}
RSI= RA / (RA + DA) * 100.0;
}
[subArr addObject:[NSNumber numberWithDouble:RSI]];
[arr addObject:subArr];
} }
return arr;
} #pragma mark - BIAS
+(NSMutableArray *)getBIASData:(NSMutableArray *)data
{ //定义参数
NSMutableArray *closeArray;
CGFloat cyc5 = ;
CGFloat cyc10 = ;
CGFloat cyc20 = ;
closeArray = [[NSMutableArray alloc] initWithCapacity:];
for(int i = ; i < data.count; i++) {
[closeArray addObject:[data[i] objectAtIndex:]] ; //第i个元素的close
} //
NSMutableArray *arr = [self makeBIAS:data closeArray:closeArray cyc:cyc5];
//
arr = [self makeBIAS:arr closeArray:closeArray cyc:cyc10];
//
arr = [self makeBIAS:arr closeArray:closeArray cyc:cyc20];
return arr;
}
+(NSMutableArray *)makeBIAS:(NSMutableArray *)data closeArray:(NSMutableArray *)closeArray cyc:(CGFloat)cyc
{
NSMutableArray *closeMaArray;
//计算一条bias线的各个值
closeMaArray = [self moveAvgArr:closeArray cyc:cyc]; NSMutableArray *arr = [[NSMutableArray alloc] initWithCapacity:];
for (int i = ; i < data.count;i++) {
NSMutableArray *subArr = data[i];
CGFloat bias = ([closeArray[i] floatValue]-[closeMaArray[i] floatValue]) / [closeMaArray[i] floatValue] * 100.0;
[subArr addObject:[NSNumber numberWithDouble:bias]];
[arr addObject:subArr];
} return arr;
} //计算滑动平均值
+(NSMutableArray *)moveAvgArr:(NSMutableArray *)Array cyc:(CGFloat)cyc
{
NSMutableArray *AvgArray;
NSMutableArray *littleArr;
//计算一条bias线的各个值
AvgArray = [[NSMutableArray alloc] initWithCapacity:];
littleArr = [[NSMutableArray alloc] initWithCapacity:]; //计算获取滑动平均值数组
int num=;
for (int i = ; i<Array.count; i++) {
if (i<=cyc-) {
num++;
[littleArr addObject:Array[i]];
CGFloat avg = [[littleArr valueForKeyPath:@"@sum.floatValue"] floatValue]/num;
[AvgArray addObject:[NSNumber numberWithFloat:avg]]; }
else
{
[littleArr removeObjectAtIndex:];
[littleArr addObject:Array[i]];
CGFloat avg = [[littleArr valueForKeyPath:@"@sum.floatValue"] floatValue]/num;
[AvgArray addObject:[NSNumber numberWithFloat:avg]];
}
} return AvgArray;
} #pragma mark - CCI
+(NSMutableArray *)getCCIData:(NSMutableArray *)data
{
//定义参数
NSMutableArray *TYPArray,*maTYPArray,*aveDevArray;
CGFloat cyc14 = ; NSMutableArray *arr = [[NSMutableArray alloc] initWithCapacity:];
TYPArray = [[NSMutableArray alloc] initWithCapacity:];
maTYPArray = [[NSMutableArray alloc] initWithCapacity:];
aveDevArray = [[NSMutableArray alloc] initWithCapacity:];
for (int i = ; i < data.count; i++) {
CGFloat typ =([[data[i] objectAtIndex:] floatValue] + [[data[i] objectAtIndex:] floatValue]+ [[data[i] objectAtIndex:] floatValue])/3.0;
[TYPArray addObject:[NSNumber numberWithFloat:typ]];
}
maTYPArray = [self moveAvgArr:TYPArray cyc:cyc14]; aveDevArray = [self aveDevArr:TYPArray arr2:maTYPArray cyc:cyc14]; if (data.count>) {
NSMutableArray *subArr = data[];
[subArr addObject:[NSNumber numberWithDouble:]];
[arr addObject:subArr];
if (data.count>) {
for (int i = ; i < data.count; i++) {
subArr = data[i];
CGFloat CCI= ([TYPArray [i] floatValue] - [maTYPArray [i] floatValue]) / (0.015 * [aveDevArray [i] floatValue]);
[subArr addObject:[NSNumber numberWithDouble:CCI]];
[arr addObject:subArr];
}
} } return arr;
} //Make aveDevArray
+(NSMutableArray *)aveDevArr:(NSMutableArray *)Array arr2:(NSMutableArray *)arr2 cyc:(CGFloat)cyc
{
NSMutableArray *AvgArray;
CGFloat windowSum;
int j;
AvgArray = [[NSMutableArray alloc] initWithCapacity:]; for (int i = ; i< Array.count; i++) {
windowSum =;
for (j=i; j>i-cyc&&j>; j--) {
windowSum = windowSum+ fabs([Array[j] floatValue]-[arr2[i] floatValue]);
}
if (j==i-cyc) {
[AvgArray addObject:[NSNumber numberWithFloat:(windowSum/cyc)]];
}
else
{
[AvgArray addObject:[NSNumber numberWithFloat:(windowSum/(i-j+))]];
} } return AvgArray; } #pragma mark - ROC
+(NSMutableArray *)getROCData:(NSMutableArray *)data
{
//定义参数
NSMutableArray *closeArray;
int cyc6 = ;
int cyc12 = ; closeArray = [[NSMutableArray alloc] initWithCapacity:];
for(int i = ; i < data.count; i++) {
[closeArray addObject:[data[i] objectAtIndex:]] ; //第i个元素的close
}
NSMutableArray *arr = [[NSMutableArray alloc] initWithCapacity:];
NSMutableArray *subArr;
NSMutableArray *ROCarr = [[NSMutableArray alloc] initWithCapacity:];
if (data.count<cyc12) {
cyc12= (int)data.count;
}
//
for (int i = ; i<cyc12; i++) {
subArr = data[i];
[subArr addObject:[NSNumber numberWithDouble:]];
[ROCarr addObject:[NSNumber numberWithDouble:]];
}
for (int i= cyc12; i<data.count; i++) {
subArr = data[i];
CGFloat ROC = ([closeArray[i] floatValue] - [closeArray[i-cyc12] floatValue])/[closeArray[i-cyc12] floatValue]*;
[subArr addObject:[NSNumber numberWithDouble:ROC]];
[ROCarr addObject:[NSNumber numberWithDouble:ROC]];
}
//
ROCarr = [self moveAvgArr:ROCarr cyc:cyc6];
for (int i = ; i<data.count; i++) {
subArr = data[i];
[subArr addObject:[NSNumber numberWithDouble:[ROCarr[i] floatValue]]];
[arr addObject:subArr];
}
return arr;
} #pragma mark - ASI
+(NSMutableArray *)getASIData:(NSMutableArray *)data
{
//定义参数
NSMutableArray *openArr, *highArr, *lowArr, *closeArr,*SI;
CGFloat lastClosePrice;
CGFloat AA, BB, CC, DD, R, X; openArr = [[NSMutableArray alloc] initWithCapacity:];
highArr = [[NSMutableArray alloc] initWithCapacity:];
lowArr = [[NSMutableArray alloc] initWithCapacity:];
closeArr = [[NSMutableArray alloc] initWithCapacity:];
SI = [[NSMutableArray alloc] initWithCapacity:];
for(int i = ; i < data.count; i++) {
[openArr addObject:[data[i] objectAtIndex:]];
[highArr addObject:[data[i] objectAtIndex:]];
[lowArr addObject:[data[i] objectAtIndex:]];
[closeArr addObject:[data[i] objectAtIndex:]]; //第i个元素的close
} NSMutableArray *arr = [[NSMutableArray alloc] initWithCapacity:];
NSMutableArray *subArr;
if (data.count>) {
subArr=data[];
[subArr addObject:[NSNumber numberWithFloat:]];
[arr addObject:subArr];
[SI addObject:[NSNumber numberWithFloat:]];
if (data.count>) {
for (int i = ; i < data.count; i++) {
subArr = data[i];
lastClosePrice = [closeArr[i - ] floatValue]; AA = fabs([highArr[i] floatValue] - lastClosePrice);
BB = fabs([lowArr[i] floatValue] - lastClosePrice);
CC = fabs([highArr[i] floatValue] - [lowArr[i - ] floatValue]);
DD = fabs(lastClosePrice - [openArr[i - ] floatValue]); R = (AA > BB && AA > CC) ? (AA + BB / + DD / ) : (BB > CC && BB > AA ? (BB + AA / + DD / ) : (CC + DD / ));
X = [closeArr[i] floatValue] + ([closeArr[i] floatValue] - [openArr[i] floatValue]) / - [openArr[i - ] floatValue];
if (R == ) {
[SI addObject:[NSNumber numberWithFloat:]];
} else {
[SI addObject:[NSNumber numberWithFloat:( * X / R * (AA>BB?AA:BB))]];
}
NSMutableArray *subArr11;
subArr11 = data[i-];
CGFloat ASI= [[subArr11 lastObject] floatValue]+ [SI[i] floatValue];
[subArr addObject:[NSNumber numberWithFloat:ASI]];
[arr addObject:subArr];
} } }
return arr;
}
#pragma mark - PSY
+(NSMutableArray *)getPSYData:(NSMutableArray *)data
{
//定义参数
NSMutableArray *closeArr;
int cyc12=;
CGFloat count = ;
closeArr = [[NSMutableArray alloc] initWithCapacity:];
for(int i = ; i < data.count; i++) {
[closeArr addObject:[data[i] objectAtIndex:]]; //第i个元素的close
} NSMutableArray *arr = [[NSMutableArray alloc] initWithCapacity:];
if (data.count>) {
NSMutableArray *subArr;
subArr = data[];
[subArr addObject:[NSNumber numberWithFloat:]];
[arr addObject:subArr];
if (data.count>) {
if (data.count<cyc12) {
cyc12= (int)data.count;
}
for (int i = ; i < cyc12 && i < data.count; i++) {
subArr = data[i];
if ([closeArr[i] floatValue] > [closeArr[i-] floatValue]) {
count++;
} CGFloat PSY= count / cyc12 * 100.0;
[subArr addObject:[NSNumber numberWithFloat:PSY]];
[arr addObject:subArr];
} for (int i=cyc12; i < data.count; i++) {
subArr = data[i];
if (i==cyc12) {
}
else
{
if ([closeArr[i - cyc12] floatValue] > [closeArr[i - cyc12 - ] floatValue]) {
count--;
}
} if ([closeArr[i] floatValue] > [closeArr[i-] floatValue]) {
count++;
} CGFloat PSY= count / cyc12 * 100.0;
[subArr addObject:[NSNumber numberWithFloat:PSY]];
[arr addObject:subArr];
} } }
return arr;
} @end
K线指标线计算方法的更多相关文章
- 如何看K线图基础知识
在日K线图中一般白线.黄线.紫线.绿线依次分别表示:5.10.20.60日移动平均线,但这并不是固定的,会根据设置的不同而不同,比如你也可以在系统里把它们设为5.15.30.60均线. 你看K线图的上 ...
- vue使用tradingview开发K线图相关问题
vue使用tradingview开发K线图相关问题 1.TradingView中文开发文档https://b.aitrade.ga/books/tradingview/CHANGE-LOG.html2 ...
- 用Python的Pandas和Matplotlib绘制股票KDJ指标线
我最近出了一本书,<基于股票大数据分析的Python入门实战 视频教学版>,京东链接:https://item.jd.com/69241653952.html,在其中给出了MACD,KDJ ...
- 3. K线基础知识三
1. 阴线 证券市场上指开盘价高于收盘价的K线,K线图上一般用淡蓝色标注,表示股价下跌,当收盘价低于开盘价,也就是股价走势呈下降趋势时,我们称这种形态的K线为阴线. 中间部分实体为蓝色,此时,上影线的 ...
- 2. K线学习知识二
1. K线 - 阳线 定义:阳线是证券市场上指收盘价高于开盘价的K线,K线图中用红线标注表示涨势. A:小阳星 全日中股价波动很小,开盘价与收盘价极其接近,收盘价略高于开盘价. 小阳星的出现,表明行情 ...
- 如何从零绘制k线图 -- 原生js canvas图表绘制
样式如下图 源码地址: https://github.com/sutianbinde/charts 编写这个需要具备canvas基础,如果没有canvas基础可以学习我前面的cnavas基础博客. 具 ...
- 黄金K线理论简述
黄金K线理论简述 [Ⅰ]. 隐藏在K线背后的多空搏杀 黄金K线的多空搏杀理论,说到底,其核心就是研判K线时,必须从多空搏杀的角度去认知,否则仅仅从表面到表面,是无法掌握K线精髓的.具体来说,多方和空方 ...
- 在MPAndroidChart库K线图的基础上画均线
CombinedChart 可以直接使用MPAndroidChart库里面提供的CombinedChart实现组合图形 Demo:CombinedChartDemo ------分割线(如果想在一个图 ...
- MPAndroidChart的K线图上添加均线
MPAndroidChart的K线图上添加均线 效果图 均线计算方法: 通常说的5日均线,10日均线,其实就是根据当前K线节点的时间维度来说的,当前每个节点代表一天,那么上面的均线就叫做日均线(几日均 ...
随机推荐
- Json 数据
来自:极课学院 简介: json与xml json语法 json对象 json对象数组 用到的包 读取json数据例子 创建json数据
- IOS第五天(1:取消按钮的监听和设置代理textField字数限制)
***********取消按钮的监听和设置代理textField字数限制 UITextFieldDelegate #import "HMViewController.h" @int ...
- Maven 私有库 Nexus的安装
1.下载 Nexus下载地址:http://www.sonatype.org/nexus/go/ # wget https://sonatype-download.global.ssl.fastly. ...
- JavaScript 数组详解(转)
在程序语言中数组的重要性不言而喻,JavaScript中数组也是最常使用的对象之一,数组是值的有序集合,由于弱类型的原因,JavaScript中数组十分灵活.强大,不像是Java等强类型高级语言数组只 ...
- Web前端开发:什么是页面重回(repaints)与回流(reflow)
前言:什么是重绘与回流? 重绘(repaints)是一个元素外观的改变所触发的浏览器行为,例如改变vidibility.outline.背景色等属性.浏览器会根据元素的新属性重新绘制,使元素呈现新的外 ...
- jquery()的三种$()
jQuery中的$以及选择器总结 $号是jQuery”类”的一个别称,$()构造了一个jQuery对象.所以,”$()”可以看作jQuery的”构造函数”(个人观点). 一.$符号 1.$()可以是$ ...
- dynamic-link library shared library of functions and resources
https://msdn.microsoft.com/en-us/library/1ez7dh12.aspx A dynamic-link library (DLL) is an executable ...
- Off-heap Memory in Apache Flink and the curious JIT compiler
https://flink.apache.org/news/2015/09/16/off-heap-memory.html Running data-intensive code in the J ...
- JAVA基础讲义
一.安装JDK 第一步:双击JDK的exe文件. JDK(Java开发包),JRE(Java运行环境) 第二步:配置 path:jdk的根目录,jdk下的bin目录(两个目录之间记得用分号隔开) cl ...
- Delphi的并行计算
有如下循环体: hits:=; do begin {perform some calculations dependent on random number generation to determi ...