//均线模块 function juxian(){ var records = exchange.GetRecords() if (records && records.length > junxiant) { var ema = TA.EMA(records, junxiant) // K线bar 数量满足指标计算周期。 if(ema[ema.length-2]>junxianx && ema[ema.length-1]>junxianx){ Log("均线值超过设定值!当前日均线:",ema[ema.length-1]," 前一均线值:",ema[ema.length-2],"设定均线值为:",junxianx); } if(ema[ema.length-2]<junxianx && ema[ema.length-1]<junxianx){ Log("均线值低于设定值!当前",junxiant,"日均线:",ema[ema.length-1]," 设定均线值为:",junxianx); } }else{ Log("均线不足",junxiant,"日"); } } //止盈止损提醒模块:可以选择监测X币在当前时间单位(可编辑小时或日等)内收盘价涨跌幅达到X%,触发止盈/止损提醒(或操作) function Riseandfall(){ if(!rise_fall){ rise_fall=1; } //获取前一小时的关盘价格 if(rise_fall==1){ ress = exchange.GetRecords(PERIOD_H1); return ress[ress.length-2]; } //获取前一日的关盘价格 if(rise_fall==2){ ress= exchange.GetRecords(PERIOD_D1); return ress[ress.length-2]; } } //获取当前买单价格 function checkPrice(){ lastPrice = Riseandfall(); lastPrice =lastPrice.Close; nowPrice = exchange.GetTicker(); nowPrice=nowPrice.Buy; //涨幅 if((nowPrice-lastPrice)>0 && ((nowPrice-lastPrice)/lastPrice)>(rise_warn/100)){ Log("当前价格:",nowPrice,"上一收盘价:",lastPrice,"涨幅达到:"+rise_warn+"%") } //跌幅 if((lastPrice-nowPrice)>0 && ((lastPrice-nowPrice)/lastPrice)>(fall_warn/100)){ Log("当前价格:",nowPrice,"上一收盘价:",lastPrice,"跌幅达到:"+rise_warn+"%") } //跌幅 } //macd提醒值 function macdwarning(){ if(!macdzhouqi){ macdzhouqi=0; } var macdarr = new Array(); macdarr[0]=PERIOD_M1; macdarr[1]=PERIOD_M5; macdarr[2]=PERIOD_M15; macdarr[3]=PERIOD_M30; macdarr[4]=PERIOD_H1; macdarr[5]=PERIOD_D1; var records = exchange.GetRecords(macdarr[macdzhouqi]);//可以填入不同k线周期,比如PERIOD_M1,PERIOD_M30,PERIOD_H1...... var macd = TA.MACD(records, 12, 26, 9); if( macd[2][macd[2].length-2]>macdwarn && macd[2][macd[2].length-1]>macdwarn){ Log("前一Macd值大于设定值 当前Macd值大于设定值!前一值:", macd[2][macd[2].length-2],"当前值:",macd[2][macd[2].length-1],"设定值",macdwarn); } if( macd[2][macd[2].length-2]<macdwarn && macd[2][macd[2].length-1]<macdwarn){ Log("前一Macd值小于设定值 当前Macd值小于设定值!前一值:", macd[2][macd[2].length-2],"当前值:",macd[2][macd[2].length-1],"设定值",macdwarn); } } //rsi function getrsi(){ var records = exchange.GetRecords(PERIOD_M30); var rsi = TA.RSI(records, 14); Log(rsi); } function kdjzhishu(){ if(!kdjtp){ kdjtp=0; } var macdarr2 = new Array(); macdarr2[0]=PERIOD_M1; macdarr2[1]=PERIOD_M5; macdarr2[2]=PERIOD_M15; macdarr2[3]=PERIOD_M30; macdarr2[4]=PERIOD_H1; macdarr2[5]=PERIOD_D1; var records = exchange.GetRecords(macdarr2[kdjtp]); var kdj = TA.KDJ(records, kdj1,kdj2, kdj3); var k = kdj[0]; var d= kdj[1]; var j = kdj[2]; if(k[k.length-2] > kdjkwarn && k[k.length-1] >kdjkwarn){ Log("前一K值,当前K值 大于预警值!前一:",k[k.length-2],"当前:",k[k.length-1],"预警:",kdjkwarn); } if(d[d.length-2] > kdjdwarn && d[d.length-1] >kdjdwarn){ Log("前一d值,当前d值 大于预警值! 前一:",d[d.length-2],"当前:",d[d.length-1],"预警:",kdjdwarn); } if(j[j.length-2] > kdjjwarn && j[j.length-1] >kdjjwarn){ Log("前一j值,当前j值 大于预警值! 前一:",j[j.length-2],"当前:",j[j.length-1],"预警:",kdjjwarn); } if(k[k.length-2] <kdjkwarn && k[k.length-1] <kdjkwarn){ Log("前一K值,当前K值 小于预警值! 前一:",k[k.length-2],"当前:",k[k.length-1],"预警:",kdjkwarn); } if(d[d.length-2] < kdjdwarn && d[d.length-1] <kdjdwarn){ Log("前一d值,当前d值 小于预警值! 前一:",d[d.length-2],"当前:",d[d.length-1],"预警:",kdjdwarn); } if(j[j.length-2] < kdjjwarn && j[j.length-1] <kdjjwarn){ Log("前一j值,当前j值 小于预警值! 前一:",j[j.length-2],"当前:",j[j.length-1],"预警:",kdjjwarn); } } // function main() { //kdjzhishu() while(1){ Log("=======================均线模块 开始========================"); juxian(); Log("=======================均线模块 结束========================"); Log("=======================KDJ模块 开始========================"); kdjzhishu(); Log("=======================KDJ模块 结束========================"); Log("=======================价格涨跌模块 开始========================"); checkPrice(); Log("=======================价格涨跌模块 结束========================"); Log("=======================止盈止损模块 开始========================"); Riseandfall(); Log("=======================止盈止损模块 结束========================"); Log("=======================macd模块 开始========================"); macdwarning(); Log("=======================macd模块 结束========================"); Sleep(90000); } // getrsi() /* while(1){ checkPrice() Sleep(90000) } */ // 、、var records = Riseandfall(); // Log(records.length) // Log("第一根k线数据为,Time:", records[0].Time, "Open:", records[0].Open, "High:", records[0].High, // "Low:", records[0].Close, "Volume:", records[0].Volume); }
oyeshbase 当前日均线:",ema[ema.length-1]," 前一均线值:",ema[ema.length-2] ,请问下,怎么打印出来后和K线不一致
6821281 173970984微信
bobo188 你好!请问 如何联系你?