开拓者突破型日内交易策略源码 [开拓者 TB]
- 源码:
Params
Numeric endTime(14.55); //结束交易时间
Numeric RiskRatio(1); //风险率(0-100)
Numeric boLength(18); //突破周期
Numeric ATRLength(20); //平均波动周期
Numeric Quitlength(10); //离市周期
Numeric weightnumber(1); //加权参数
Numeric Limitednumber(3); //交易限制次数(能交易的次数为limitednumber+1次)
Bool Filtercondition(True); //入市过滤条件
Vars
Numeric Minpoint; //最小变动单位
NumericSeries AvgTR; //ATR
Numeric F; //表示市场波动性的F值
Numeric Capital; //入市资本
Numeric scale; //买卖规模
NumericSeries Passwayhi; //通道上轨
NumericSeries Passwaylo; //通道下轨
NumericSeries quithighprice; //离市时判断需要的离市周期最高价
NumericSeries quitlowprice; //离市时判断需要的离市周期最低价
Numeric myEntryPrice; //开仓价格
Numeric myExitPrice; //平仓价格
NumericSeries tempnum(0); //临时计数器
Bool Sendorderthisbar(False); //当前Bar是否有过交易
NumericSeries preEntryprice(0); //前一次开仓的价格
Begin
Minpoint=Minmove*PriceScale;
AvgTR=XAverage(TrueRange,ATRlength);
F=weightnumber*AvgTR[1];
Capital=Portfolio_CurrentCapital()+Portfolio_UsedMargin();
scale=(Capital*RiskRatio/100)/(F*ContractUnit()*BigPointValue());
scale=IntPart(scale);
Passwayhi=HighestFC(High[1],boLength);
Passwaylo=LowestFC(Low[1],boLength);
quitlowprice=LowestFC(Low[1],Quitlength);
quithighprice=HighestFC(High[1],Quitlength);
Commentary("scale="+Text(scale));
Commentary("preEntryprice="+Text(preEntryprice));
If(Date!=currentdate) //只限于当日交易
{return;}
If((Date!=Date[1])or(CurrentBar==0))
{
//当日的第一个Bar
preEntryprice=InvalidNumeric;
tempnum=Limitednumber;
return;
}
If(tempnum[1]<1)
{
tempnum=limitednumber;
}
//开仓
If(time<endtime/100)
{
If(MarketPosition==0 And Filtercondition)
{
If(High>Passwayhi And scale>=1)
{
myEntryPrice=Min(high,passwayhi+minpoint);
myentryprice=IIF(myentryprice<open,open,myentryprice);
preentryprice=myentryprice;
Buy(scale,myentryprice);
sendorderthisbar=True;
}
If(Low<passwaylo And scale>=1)
{
myentryprice=Max(low,passwaylo-Minpoint);
myentryprice=IIF(myentryprice>open,open,myentryprice);
preentryprice=myentryprice;
SellShort(scale,myentryprice);
sendorderthisbar=True;
}
}
If(Marketposition==1)
{
Commentary("quitlowprice="+Text(quitlowprice));
If(Low<quitlowprice)
{
myexitprice=Max(low,quitlowprice-Minpoint);
myexitprice=IIF(myexitprice>open,open,myexitprice);
Sell(0,myexitprice);
tempnum=limitednumber;
}Else
{
tempnum=tempnum[1];
If(preentryprice!=Invalidnumeric And scale>=1)
{
If((open>=preentryprice+0.5*F) And (tempnum>=1))
{
myentryprice=open;
preentryprice=myentryprice;
Buy(scale,myentryprice);
sendorderthisbar=True;
tempnum=tempnum-1;
}
While((High>=preentryprice+0.5*F) And (tempnum>=1))
{
myentryprice=preentryprice+0.5*F;
preentryprice=myentryprice;
Buy(scale,myentryprice);
sendorderthisbar=true;
tempnum=tempnum-1;
}
}
If(low<=preentryprice-2*F And sendorderthisbar==false)
{
myexitprice=preentryprice-2*F;
Sell(0,myexitprice);
tempnum=limitednumber;
}
}
}Else If(marketposition==-1)
{
Commentary("quithighprice="+Text(quithighprice));
If(high>quithighprice)
{
myexitprice=Min(High,quithighprice+Minpoint);
myexitprice=IIF(myexitprice<open,open,myexitprice);
BuyToCover(0,myexitprice);
tempnum=limitednumber;
}Else
{ tempnum=tempnum[1];
If(preentryprice!=Invalidnumeric And scale>=1)
{
If((open<=preentryprice-0.5*F) And (tempnum>=1))
{
myentryprice=Open;
preentryprice=myentryprice;
SellShort(scale,myentryprice);
sendorderthisbar=True;
tempnum=tempnum-1;
}
While((Low<=preentryprice-0.5*F) And (tempnum>=1))
{
myentryprice=preentryprice-0.5*F;
preentryprice=myentryprice;
SellShort(scale,myentryprice);
sendorderthisbar=True;
tempnum=tempnum-1;
}
}
If(High>=preentryprice+2*F And sendorderthisbar==False)
{
myexitprice=preentryprice+2*F;
BuyToCover(0,myexitprice);
tempnum=limitednumber;
}
}
}
}
If(Time==0.145500 && /*CurrentTime>0.145800 &&*/ MarketPosition<>0) //收盘平仓用于5Min
{
Sell(0,Close);
BuyToCover(0,Close);
}
End
有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友
可联系技术人员 QQ: 262069696 进行 有偿 编写!(不贵!点击查看价格!)
相关文章
-
没有相关内容