当前位置: 网站首页 > 股票软件公式 > 同花顺公式 > 文章 当前位置: 同花顺公式 > 文章

同花顺源码:风险控制,顶底趋势,缠论分笔及中枢主图

点击: 次    来源:顶尖财经    作者:股市狙击 - 小 + 大

1、风险控制

///资金抄底
IF(PERIODNAME<>"日线")
{
统计:"该指标只在日线周期下有效。";
RETURN;
}
//大单净量
r:=((ZDMR[-1]+BDMR[-1])-(ZDMC[-1]+BDMC[-1]))/SHGZG*100;
//相对强弱
LC := REF(CLOSE,1);//前一日收盘价;
RSI$1:=SMA(MAX(CLOSE-LC,0),3,1)/SMA(ABS(CLOSE-LC),3,1)*100;
RSI$2:=SMA(MAX(CLOSE-LC,0),5,1)/SMA(ABS(CLOSE-LC),5,1)*100;
RSI$3:=SMA(MAX(CLOSE-LC,0),8,1)/SMA(ABS(CLOSE-LC),8,1)*100;
相对强弱:=0.5*RSI$1+0.31*RSI$2+0.19*RSI$3;
wave$1:=SMA(100*(CLOSE-LLV(LOW,8))/(HHV(HIGH,8)-LLV(LOW,8)),3,1);
wave$2:=SMA(100*(CLOSE-LLV(LOW,8))/(HHV(HIGH,8)-LLV(LOW,8)),5,1);
wave$3:=SMA(100*(CLOSE-LLV(LOW,8))/(HHV(HIGH,8)-LLV(LOW,8)),8,1);
短线波段:=0.5*wave$1+0.31*wave$2+0.19*wave$3;
机会区:20,POINTDOT,colorred;
风险区:80,POINTDOT,colorgreen;
风险系数:0.5*相对强弱+0.5*短线波段,coloryellow;
//买入条件;
CD1:=IF(风险系数<20 AND CLOSE>OPEN AND r>0,1,0);//波段小于20,股价翻红;
CD2:=IF(风险系数<20 AND LOW>=REF(LOW,1) AND CLOSE>LOW AND r>0,1,0);//波段小于20,股价未翻红,但未创新低;
CD3:=IF(REF(风险系数,1)<20 AND 风险系数>REF(风险系数,1),1,0);//前一日波段小于20,今日转向;http://www.58188.com/
SIGNALBUY=(CD1=1 OR CD2=1 OR CD3=1);
X=(SIGNALBUY AND COUNT(SIGNALBUY,3)=1);
DRAWICON(X,机会区,"buy");
///资金仓位
IF(PERIODNAME<>"日线")
{
统计:"该指标只在日线周期下有效。";
RETURN;
}
m5=0;
m10=0;
m20=0;
m30=0;
m60=0;
a2=MA(C,1);
a5=MA(C,5);
a10=MA(C,10);
a20=MA(C,20);
a30=MA(C,30);
a60=MA(C,60);
IF(a5=NULL)m5=100;
IF(a2>=a5)
{
m5=100;
IF(a2>=a10)
{
m10=0;
IF(a2>=a20)
{
m20=0;
IF(a2>=a30)
{
m30=0;
IF(a2>=a60)
{
m60=0;
}
IF(a2<a60)
{
m60=-100;
}
}
IF(a2<a30)
{
m30=-70;
IF(a2>=a60)
{
m60=0;
}
IF(a2<a60)
{
m60=-30;
}
}
}
IF(a2<a20)
{
m20=-50;
IF(a2>=a30)
{
m30=0;
IF(a2>=a60)
{
m60=0;
}
IF(a2<a60)
{
m60=-50;
}
}
IF(a2<a30)
{
M30=-20;
IF(a2>=a60)
{
m60=0;
}
IF(a2<a60)
{
m60=-30;
}
}
}
}
IF(a2<a10)
{
m10=-50;
IF(a2>=a20)
{
m20=10;
IF(a2>=a30)
{
m30=0;
IF(a2>=a60)
{
m60=0;
}
IF(a2<a60)
{
m60=-60;
}
}
IF(a2<a30)
{
m30=-30;
IF(a2>=a60)
{
m60=0;
}
IF(a2<a60)
{
m60=-30;
}
}
}
IF(a2<a20)
{
m20=-10;
IF(a2>=a30)
{
m30=0;
IF(a2>=a60)
{
m60=0;
}
IF(a2<a60)
{
m60=-40;
}
}
IF(a2<a30)
{
m30=-20;
IF(a2>=a60)
{
m60=0;
}
IF(a2<a60)
{
m60=-20;
}
}
}
}
}
IF(a2<a5)
{
m5=0;
IF(a2>=a10)
{
m10=50;
IF(a2>=a20)
{
m20=20;
IF(a2>=a30)
{
m30=10;
IF(a2>=a60)
{
m60=0;
}
IF(a2<a60)
{
m60=-80;
}
}
IF(a2<a30)
{
m30=-40;
IF(a2>=a60)
{
m60=0;
}
IF(a2<a60)
{
m60=-30;
}
}
}
IF(a2<a20)
{
M20=0;
IF(a2>=a30)
{
m30=0;
IF(a2>=a60)
{
m60=0;
}
IF(a2<a60)
{
m60=-50;
}
}
IF(a2<a30)
{
m30=-20;
IF(a2>=a60)
{
m60=0;
}
IF(a2<a60)
{
m60=-30;
}
}
}
}
IF(a2<a10)
{
m10=0;
IF(a2>=a20)
{
m20=50;
IF(a2>=a30)
{
m30=0;
IF(a2>=a60)
{
m60=0;
}
IF(a2<a60)
{
m60=-50;
}
}
IF(a2<a30)
{
m30=-20;
IF(a2>=a60)
{
m60=0;
}
IF(a2<a60)
{
m60=-30;
}
}
}
IF(a2<a20)
{
M20=0;
IF(a2>=a30)
{
m30=30;
IF(a2>=a60)
{
m60=0;
}
IF(a2<a60)
{
m60=-30;
}
}
IF(a2<a30)
{
m30=0;
IF(a2>=a60)
{
m60=10;
}
IF(a2<a60)
{
m60=0;
}
}
}
}
}
IF(a2>=a5 AND a2>=a10 AND a2>=a20 AND a2>=a30 AND a2<a60)m5=150;
IF(a2>=a5 AND a2>=a10 AND a2<a20 AND a2>=a30 AND a2<a60)m5=130;
IF(a2>=a5 AND a2>=a10 AND a2>=a20 AND a2<a30 AND a2<a60)m5=130;
IF(a2>=a5 AND a2<a10 AND a2<a30 AND a2<a60)m5=110;
IF(a2<a5 AND a2>=a10 AND a2>=a20 AND a2>=a30 AND a2<a60)m5=30;
IF(a2>=a5 AND a2>=a10 AND a2>=a20 AND a5>=a10 AND a2<a30 AND a2<a60)m5=130;
IF(a2>=a5 AND a2>=a10 AND a5>=a10 AND a2<a20 AND a2<a30 AND a2<a60)m5=120;
IF(a2>=a5 AND a2>=a10 AND a5<a10 AND a2<a20 AND a2<a30 AND a2<a60)m5=110;
IF(a2>=a5 AND a2>=a10 AND a2>=a20 AND a2>=a30 AND a2<a60 AND a5<a10 AND a10<a30)m5=130;
m=m5+m10+m20+m30+m60;
IF(m>=50){STICKLINE(m,0,m,10,1),colorred;}ELSE{STICKLINE(m,0,m,10,1),colorgreen;}
//买入条件
CD1:=IF(风险系数<20 AND CLOSE>OPEN AND r>0,1,0);//波段小于20,股价翻红;
CD2:=IF(风险系数<20 AND LOW>=REF(LOW,1) AND CLOSE>LOW AND r>0,1,0);//波段小于20,股价未翻红,但未创新低;
CD3:=IF(REF(风险系数,1)<20 AND 风险系数>REF(风险系数,1),1,0);//前一日波段小于20,今日转向;
SIGNALBUY=(CD1=1 OR CD2=1 OR CD3=1);
X=(SIGNALBUY AND COUNT(SIGNALBUY,3)=1);
DRAWICON(X,机会区,"buy");
LC:=REF(CLOSE,1);
RSI:=((SMA(MAX(CLOSE - LC,0),4.1,1))/(SMA(ABS(CLOSE - LC),4.1,1)))*(100);
波段底部:=(CROSS(RSI,11))*(70),colorred;
STICKLINE(波段底部,0,3,10,0),colorliblue;
STICKLINE(波段底部 ,3,6,9,0),coloryellow;
STICKLINE(波段底部 ,6,9,6,0),colorred;
STICKLINE(波段底部 ,9,12,6,0),colorffccaa;
DRAWTEXT(波段底部,15,'↖波'),COLORffccaa;
DRAWTEXT(波段底部,10,'↖段'),COLORffccaa;
DRAWTEXT(波段底部,5,'↖底'),COLORffccaa;
N1:=21;
VAR1A:=(HHV(HIGH,9)-CLOSE)/(HHV(HIGH,9)-LLV(LOW,9))*100-70;
VAR2A:=SMA(VAR1A,9,1)+100;
VAR3A:=(CLOSE-LLV(LOW,9))/(HHV(HIGH,9)-LLV(LOW,9))*100;
VAR4A:=SMA(VAR3A,3,1);
VAR5A:=SMA(VAR4A,3,1)+100;
VAR6A:=VAR5A-VAR2A;
端庄窝:=IF(VAR6A>N1,VAR6A-N1,0),colorgray,DOTLINE;
果断出击:=IF(CROSS(端庄窝,0.01),100,0),STICK,colorgreen,LINETHICK2;
STICKLINE(果断出击,0,15,15,0),colorred;
STICKLINE(果断出击 ,15,25,12,0),colorcyan;
STICKLINE(果断出击 ,25,35,9,0),colorblue;
STICKLINE(果断出击 ,35,45,6,0),coloryellow;
DRAWICON(果断出击>0,55,1),colorgreen;
DRAWTEXT(果断出击,95,'果'),colorffaacc;
DRAWTEXT(果断出击,85,'断'),colorffaacc;
DRAWTEXT(果断出击,75,'出'),colorffaacc;
DRAWTEXT(果断出击,65,'击'),colorffaacc;




2、顶底趋势

VAR2:=REF(LOW,1);
VAR3:=SMA(ABS(LOW-VAR2),13,1)/SMA(MAX(LOW-VAR2,0),13,1)*100;
VAR4:=EMA(IF(CLOSE*1.2,VAR3*13,VAR3/13),13);
VAR5:=LLV(LOW,34);
VAR6:=HHV(VAR4,34);
VAR7:=IF(LLV(LOW,55),1,0);
VAR8:=EMA(IF(LOW<=VAR5,(VAR4+VAR6*2)/2,0),3)/618*VAR7;
VAR9:=EMA(CLOSE,5);
VAR10:=(CLOSE-MA(CLOSE,34))/MA(CLOSE,34)*(-10);
VAR11:=EMA(IF(LOW<=VAR5,(VAR4+VAR6*2)/2,0),3)/618*VAR7*(-1);
VAR12:=EMA(CLOSE,5)*(-1);
STICKLINE(VAR8>REF(VAR8,1),0,VAR8,6,0),COLOR10FFFF,LINETHICK3;
备钱:=IF(VAR8>REF(VAR8,1),0,VAR8),COLOR0FFFFF;
STICKLINE(VAR11>REF(VAR11,1),0,VAR11,6,0),COLORFFF810;
界:=0,COLORFFFFFF,LINETHICK1;
www58188com:=MA(LOW,2)*0.96;
XL1:=MA(LOW,2)*0.96;
XL2:=MA(LOW,26)*0.85;
XL3:=REF(XL1,1)<XL2 AND REF(XL1,1)<XL1 AND REF(XL1,1)<REF(XL1,2);
STICKLINE(XL3,0,VAR8*3,8,0),colorred;
启动:=IF(XL3,0,VAR8*3),colorred;
VA:=(2*C+H+L)/4;
VB:=LLV(L,5);
VC:=HHV(H,5);
红线上穿买:EMA((VA-VB)/(VC-VB)*27,5),colorred,LINETHICK3;
红线下穿卖:EMA(红线上穿买,3),COLORFFFF00,LINETHICK3;
散户:= EMA(((2*CLOSE+HIGH+LOW)/4-LLV(LOW,5))/(HHV(HIGH,4)-LLV(LOW,5))*100,4);
庄家:= EMA(0.667*REF(散户,1)+0.333*散户,2);
DRAWTEXT(CROSS(散户,庄家) AND 散户<30,5,'买'),colorred;
DRAWTEXT(CROSS(散户,庄家) AND 散户<30,7,'●'),COLORFFFFFF;
DRAWTEXT(CROSS(庄家,散户) AND 散户>70,25,'顶'),COLOR00FF00;
DRAWTEXT(CROSS(庄家,散户) AND 散户>70,22,'●'),COLOR00FF00;
极品底:IF((MA(C,5)-C)/C>0.04 AND (MA(C,10)-MA(C,5))/MA(C,5)>0.04,23,0),LINETHICK2,COLORFF00FF;
DRAWICON(极品底=23,23,1),LINETHICK2,COLORFFFFFF;
RSV:=(((CLOSE - LLV(LOW,9)) / (HHV(HIGH,9) - LLV(LOW,9))) * 100);
K:=SMA(RSV,3,1);
D:=SMA(K,3,1);
J:=3*K-2*D;
X:=LLV(J,2)=LLV(J,8);
DRAWTEXT(CROSS(J,REF(J+0.01,1)) AND X AND J<19,3,'低吸'),COLORFFFF00;
DRAWTEXT(CROSS(J,REF(J+0.01,1)) AND X AND J<19,7,'▲'),colorred;
DRAWTEXT(CROSS(J,REF(J+0.01,1)) AND X AND J<19,6,'▲'),colorred;
DRAWTEXT(CROSS(J,REF(J+0.01,1)) AND X AND J<19,5,'↑'),colorred;
QVAR1A:=((HHV(HIGH,21)-CLOSE)/(HHV(HIGH,21)-LLV(LOW,21)))*(100)-10;
QVAR1B:=((CLOSE-LLV(LOW,21))/(HHV(HIGH,21)-LLV(LOW,21)))*(100);
QVAR1C:=SMA(QVAR1B,13,8);
QVAR1D:=SMA(QVAR1A,21,8);
机会来临:=SMA(QVAR1C,13,8),colorred;
AAS:=FILTER((COUNT((机会来临-QVAR1D<(-65)),3)=3),34);
波段买点:IF(AAS,15,0),colormagenta,STICK,LINETHICK6;
DRAWTEXT(波段买点,17,'波段买'),colormagenta;
低进1:=CROSS(散户,庄家) AND 散户<30;
低进2:=CROSS(J,REF(J+0.01,1)) AND X AND J<19;
低进:低进1 OR 低进2;




3、缠论分笔及中枢主图

//同花顺缠论分笔及中枢主图源码( 顶尖财经 股票学院: http://58188.com )
KU1:=IF(HIGH=HHV(HIGH,3),1,0);
KD1:=IF(LOW=LLV(LOW,3),1,0);
UL:=IF(REF(KU1,2)=1 AND REF(KU1,1)=0
AND KU1=0,REF(HIGH,2),REF(HIGH,2+BARSLAST(REF(KU1,2)=1
AND REF(KU1,1)=0 AND KU1=0)));
DL:=IF(REF(KD1,2)=1 AND REF(KD1,1)=0 AND KD1=0,REF(LOW,2),REF(LOW,2+BARSLAST(REF(KD1,2)=1
AND REF(KD1,1)=0 AND KD1=0)));
HV:=H>UL AND H>REF(H,1) ;
LV:=L<DL AND L<REF(L,1) ;
GP:=BARSLAST(HV);
DP:=BARSLAST(LV);
IP:=IF(GP=0,DP,GP)>3;
HV1:=HV AND IP AND H>=HHV(H,BARSLAST(LV));
LV1:=LV AND IP AND L<=LLV(L,BARSLAST(HV));
DRAWLINE(LV1,LOW,HV1, HIGH,0),coloryellow,LINETHICK2;
DRAWLINE(HV1,HIGH,LV1, LOW,0),colormagenta,LINETHICK2;
///加入中枢判定
//简化版
N1:=10;N2:=10;DISP:=2;K:=1;
P1:=PEAK(1,K*N1,1);
P2:=PEAK(1,K*N1,2);
WP1:=PEAKBARS(1,K*N1,1);
WP2:=PEAKBARS(1,K*N1,2);
T1:=TROUGH(2,K*N2,1);
T2:=TROUGH(2,K*N2,2);
WT1:=TROUGHBARS(2,K*N2,1);
WT2:=TROUGHBARS(2,K*N2,2);
TJ1:=P1>T1 AND P2>T2 ;
ZD:=MAX(T1,T2);
ZG:=MIN(P1,P2);
LL:=MIN(T1,T2);
HH:=MAX(P1,P2);
TJ2:=FILTER(ZG>ZD,2);
TJ3:=ZG=REF(ZG,BARSLAST(TJ2)) OR ZD=REF(ZD,BARSLAST(TJ2));
TJ4:=TJ1 AND TJ2 AND NOT(TJ3);
TJ5:=BETWEEN(ZD,REF(ZD,REF(BARSLAST(TJ4),1)),REF(ZG,REF(BARSLAST(TJ4),1)));
TJ6:=BETWEEN(ZG,REF(ZD,REF(BARSLAST(TJ4),1)),REF(ZG,REF(BARSLAST(TJ4),1)));
TJ7:=ZG>REF(ZG,REF(BARSLAST(TJ4),1)) AND ZD<REF(ZD,REF(BARSLAST(TJ4),1));
TJ8:=TJ4 AND NOT(TJ5 OR TJ6 OR TJ7);
ZSD:=IF(TJ8,ZD,REF(ZD,1));//,coloryellow;
ZSG:=IF(TJ8,ZG,REF(ZG,1));//,colormagenta;
ZSH:=IF(TJ8,HH,REF(HH,1));//,colorblue;
ZSL:=IF(TJ8,LL,REF(LL,1));//,colorgreen;
STICKLINE(TJ8,ZSH,ZSL,0,-1),colormagenta;
STICKLINE(TJ8,ZSD,ZSG,IF(DISP=1,3,0),1),colormagenta;
DRAWTEXT(DISP=2,ZSH,''),colorwhite;
//中枢高
中枢高:ZSG,colormagenta;
POLYLINE(DISP=2,REF(ZSG,BARSLAST(TJ8))),CIRCLEDOT,colormagenta;
//中枢低:
中枢低:ZSD,coloryellow;
POLYLINE(DISP=2,REF(ZSD,BARSLAST(TJ8))),CIRCLEDOT,coloryellow;
//中枢最高:
中枢最高:ZSH,colorred;
POLYLINE(DISP=2,REF(ZSH,BARSLAST(TJ8))),POINTDOT,colorred;
//中枢最低:
中枢最低:ZSL,colorgreen;
POLYLINE(DISP=2,REF(ZSL,BARSLAST(TJ8))),POINTDOT,colorgreen;
//趋势高:
//QSGD1:POLYLINE(DISP=3,ZIG(1,K*N1)),colorblue;
//趋势低:
//QSDD1:POLYLINE(DISP=3,ZIG(2,K*N2)),colorblue;
MA5:MA(CLOSE,5),COLORFF00FF,Linethick1;
 
命真好:=MA5>REF(MA5,1);
命真坏:=MA5<REF(MA5,1);
PARTLINE(MA5,命真好,RGB(255,255,0),命真坏,RGB(0,0,255),1,RGB(255,0,255)),linethick3;

上一篇:同花顺公式下载:超准出击,超准波段多空,超准趋势,超准量能,超准超短

下一篇:同花顺源码:较好买点,一本预警主图,换缺3 空桨副图