//周期绑定///////////////////////////
周期:DATATYPE,linethick0;
if 周期<>1 then begin//绑定为1分钟
drawtextex(1,1,500,500,'请切换到1分钟周期'),colorwhite;
exit;
end
//将以上代码放在代码的最前面,可以使该程序只在一分钟图下显示。
//如果想绑定在5分钟,可以改为
周期:DATATYPE,linethick0;
if 周期<>2 then begin//绑定为5分钟
drawtextex(1,1,500,500,'请切换到5分钟周期'),colorwhite;
exit;
end
[此贴子已经被作者于2012-9-24 10:20:46编辑过]
//绑定指定机器
正版:not(strcmp(engincode(),'5CD511E858033BA8')),linethick0;
if 正版=0 then begin
drawtextex(1,1,500,500,'未注册');
exit;
end
drawtextex(1,1,500,500,engincode());
新建一个技术指标,放入以上这行代码,调出指标即可显示,所在电脑的机器码。
//到期控制
if CURRENTDATE>1121029 then exit;
//将上面这行代码加入到程序的前面,该程序将在1121029(即2012年10月29日)到期。
//超简单海龟代码,供入门者学习,高手瓢过。
h10:ref(hhv(h,10),1),colorgreen;//前10根K线高点
l10:ref(llv(l,10),1),colorgreen;//前10根K线低点
h20:ref(hhv(h,20),1),colorred;//前20根K线高点
l20:ref(llv(l,20),1),colorred;//前20根K线低点。
long:=cross(c,h20);//价格上穿前20根线高点,做多条件
longend:=cross(l10,c);//价格跌破前10根K线低点,做多终止条件
short:=cross(l20,c);//价格跌破前20根K线低点,做空条件
shortend:=cross(c,h10);//价格上穿前10根K线高点,做空终止条件
if holding=0 then begin//建仓代码
buy(long,1,thisclose);
buyshort(short,1,thisclose);
end
if holding<>0 then begin//平仓代码
sell(longend,1,thisclose);
sellshort(shortend,1,thisclose);
end
[此贴子已经被作者于2012-9-27 10:24:19编辑过]
//这是我给我们公司的同事做入门引导用的2个例子,可以组合使用。
//区间多,专做多
input:N(18,1,100,1);
开盘K线数:barslast(day<>ref(day,1))+1,linethick0;
开盘价:ref(c,开盘K线数-1),colorwhite;
上轨:开盘价+N,colorred;
long:=cross(c,上轨);
longend:=cross(开盘价,c);
if holding=0 then buy(long,1,thisclose);
if holding>0 then sell(longend,1,thisclose);
if holding>0 and enterprice-c>=20 then sell(1,1,thisclose);
if time>150500 and holding>0 then sell(1,1,thisclose);
//区间空,专做空
input:N(10,1,100,1);
开盘K线数:barslast(day<>ref(day,1))+1,linethick0;
开盘价:ref(c,开盘K线数-1),colorwhite;
下轨:开盘价-N,colorred;
short:=cross(下轨,c);
shortend:=cross(c,开盘价);
if holding=0 then buyshort(short,1,thisclose);
if holding<0 then sellshort(shortend,1,thisclose);
if time>150500 and holding<0 then sellshort(1,1,thisclose);
//在每天收盘的最后一个K线做一个标志线,方便看盘用。
收盘时间:CLOSETIME(0),linethick0;
VERTLINE(time=收盘时间,hhv(h,240),llv(l,240),coloryellow,1,vtdash);
//股指与300ETF之间的价差套利代码演示//做空股指
VERTLINE(time=CLOSETIME(0),hhv(h,240/5),llv(l,240/5),coloryellow,1,vtDASH);
股指:"IF00$CLOSE",linethick0;
沪深300:"000300$CLOSE",linethick0;
差值:股指-沪深300,linethick0;
short:=差值>=20;
shortend:=差值<=10;
t1:=time>093500 and time<145500;
if holding=0 and t1 then begin
buyshort(short,1,thisclose);
end
if holding<0 and t1 then sellshort(shortend,1,thisclose);
//做多300ETF
VERTLINE(time=CLOSETIME(0),hhv(h,240/5),llv(l,240/5),coloryellow,1,vtDASH);
股指:"IF00$CLOSE",linethick0;
沪深300:"000300$CLOSE",linethick0;
差值:股指-沪深300,linethick0;
long:=差值>=20;
longend:=差值<=10;
t1:=time>093500 and time<145500;
if holding=0 and t1 then begin
buy(long,1,thisclose);
end
if holding>0 and t1 then sell(longend,1,thisclose);
//特别提示,一手股指的合约金额比较大,对应的ETF份数也比较大。这里需要自行调节买卖的ETF份数