均线原理指标(附指标源码+原理+使用方法+贴图)
把理论转化为指标(实现理论和实践相结合的道路)。理论来至于生活,生活经验总结就是理论
1.黄线标示金叉日和金叉所需的最低收盘价;浅黄线标示n1日
前的位置.
2.绿线标示死叉日和死叉所需的最高收盘价;浅绿线标示n1日
前的位置.
3.蓝柱线标示主图中最后一根k线n1日前的位置.
4.白曲线为均线一,金黄曲线为均线二;淡兰曲线标示今日交叉
均线一的数值;兰曲线为淡兰曲线向右移动n1日所得;
5.明日交叉价给出光标所指次日交叉所需的收盘价;
{ MA叉左理 均线交叉的左侧定理 }
input:n1(10,1,500,1),n2(30,10,1000,1);
均线一:ma(c,n1),colorffffff,linethick1,PRECIS3;
均线二:ma(c,n2),color00aaff,PRECIS3;
均叉左理线:=ma(c,(n2/n1-1)*n1);
均叉左理线,color777700,linethick1,PRECIs0;
左理线:ref(均叉左理线,n1),coloraaaa00,linethick1,PRECIS3;
今叉价:=(ref(均线二,1)-ref(均线一,1)+ref(c,n1)/n1-ref(c,n2)/n2)
*n1*n2/(n2-n1);
{Y0:(n2-1)*REF(MA(c,(n2-1)),1)-n2/n1*(n1-1)*REF(MA(c,(n1-1)),1),colorffffff,linethick0,PRECIS2;}
今金叉低价:if(ref(均线一,1)<ref(今叉价,1),今叉价,0),color00ffff,linethick0,PRECIS3;
今死叉高价:if(ref(均线一,1)>ref(今叉价,1),今叉价,0),color00ff00,linethick0,PRECIS3;
明日交叉价:(ref(c,n1-1)*n2-ref(c,n2-1)*n1)/(n2-n1) -(ma(c,n1)-ma(c,n2))*n1*n2/(n2-n1),colorffaaaa,linethick0,PRECIS2;
{Y00:((n2-1)*MA(c,n2-1)-n2/n1*(N1-1)*MA(c,N1-1))/(n2/n1-1),color00ffff,linethick0,PRECIS2;}
{明日交叉价:((n2-1)*MA(c,n2-1)-n2/n1*(N1-1)*MA(c,N1-1))/(n2/n1-1),colorffaaaa,linethick0,PRECIS2;}
今叉均线一:=ref(ma(c,(n2/n1-1)*n1),n1);
stickline(cross(均线一,均线二),今叉均线一,今叉均线一,n1*25,0),color00dddd,linethick1;
stickline(cross(均线二,均线一),今叉均线一,今叉均线一,n1*25,0),color00dd00,linethick1;
stickline(cross(backset(DISPSTATUS=2,n1+1),0.5),均叉左理线,均叉左理线*1.12,1,0),colorffff00,linethick1;
stickline(cross(backset(DISPSTATUS=2,n1+1),0.5),均叉左理线,均叉左理线,200,0),colorffff00,linethick1;
m11:=barslast(cross(均线一,均线二))+1;
m12:=barslast(cross(均线二,均线一))+1;
m21:=backset(cross(均线一,均线二),m11+n1);
m22:=backset(cross(均线二,均线一),m12+n1);
stickline(cross(m21,0.5) ,均叉左理线*0.95,均叉左理线*1.05,1,0),color00aaaa,linethick1;
stickline(cross(m22,0.5),均叉左理线*0.95,均叉左理线*1.05,1,0),color00aa00,linethick1;
stickline(cross(均线一,均线二),今叉均线一*1.1,今叉均线一*0.9,1,0),color00ffff,linethick1;
stickline(cross(均线二,均线一),今叉均线一*1.1,今叉均线一*0.9,1,0),color00ff00,linethick1;
hhh:=hhv(max(均线一,均线二),barslast(DISPSTATUS=1))+1;
DRAWTEXT(DISPSTATUS=2 and 均线一<均线二,hhh*0.90 ,'今日 :金叉均线一:'+ref(均叉左理线,n1)+';'),color00aaaa,ALIGN2;
DRAWTEXT(DISPSTATUS=2 and 均线一<均线二,hhh*0.88 ,'明日 :金叉均线一:'+ref(均叉左理线,n1-1)+';'),color00aaaa,ALIGN2;
DRAWTEXT(DISPSTATUS=2 and 均线一<均线二,hhh*0.86 ,'后日 :金叉均线一:'+ref(均叉左理线,n1-2)+';'),color00aaaa,ALIGN2;
DRAWTEXT(DISPSTATUS=2 and 均线一<均线二,hhh*0.84 ,'后3日:金叉均线一:'+ref(均叉左理线,n1-3)+';'),color00aaaa,ALIGN2;
DRAWTEXT(DISPSTATUS=2 and 均线一<均线二,hhh*0.82 ,'后4日:金叉均线一:'+ref(均叉左理线,n1-4)+';'),color00aaaa,ALIGN2;
DRAWTEXT(DISPSTATUS=2 and 均线一<均线二,hhh*0.80 ,'后5日:金叉均线一:'+ref(均叉左理线,n1-5)+';'),color00aaaa,ALIGN2;
DRAWTEXT(DISPSTATUS=2 and 均线一>均线二,hhh*0.90 ,'今日 :死叉均线一:'+ref(均叉左理线,n1)+';'),color00aa00,ALIGN2;
DRAWTEXT(DISPSTATUS=2 and 均线一>均线二,hhh*0.88 ,'明日 :死叉均线一:'+ref(均叉左理线,n1-1)+';'),color00aa00,ALIGN2;
DRAWTEXT(DISPSTATUS=2 and 均线一>均线二,hhh*0.86 ,'后日 :死叉均线一:'+ref(均叉左理线,n1-2)+';'),color00aa00,ALIGN2;
DRAWTEXT(DISPSTATUS=2 and 均线一>均线二,hhh*0.84 ,'后3日:死叉均线一:'+ref(均叉左理线,n1-3)+';'),color00aa00,ALIGN2;
DRAWTEXT(DISPSTATUS=2 and 均线一>均线二,hhh*0.82 ,'后4日:死叉均线一:'+ref(均叉左理线,n1-4)+';'),color00aa00,ALIGN2;
DRAWTEXT(DISPSTATUS=2 and 均线一>均线二,hhh*0.80 ,'后5日:死叉均线一:'+ref(均叉左理线,n1-5)+';'),color00aa00,ALIGN2;
|