- 精华
- 0
- 在线时间
- 121 小时
- UID
- 226268
- 积分
- 64
- 帖子
- 45
- 阅读权限
- 30
- 注册时间
- 2016-1-6
- 最后登录
- 2023-9-28
- 精华
- 0
- UID
- 226268
- 积分
- 64
- 帖子
- 45
- 主题
- 10
- 阅读权限
- 30
- 注册时间
- 2016-1-6
- 最后登录
- 2023-9-28
|
Params
Numeric XiShu1(0.65);
Numeric XiShu2(0.65);
Numeric Lots(1); //手数,自己想开几手就设置几手
Numeric Hyl(0.8); //最高盈利百分比,1表示1%
Numeric Hc(0.3); //回撤百分比,1表示1%
Vars
NumericSeries OpenToday;
NumericSeries Band1;
NumericSeries Band2;
NumericSeries UpperBand;
NumericSeries LowerBand;
NumericSeries SellBand;
NumericSeries BuyToCoverBand;
NumericSeries myEntryPrice;
NumericSeries isHyl;//是否达到最大盈利
Begin
If(Date >= 20170501) return;
OpenToday=OpenD(0);
Band1=(HighD(1)-LowD(1))*Max(XiShu1,XiShu2);
UpperBand=OpenToday+Band1;
LowerBand=OpenToday-Band1;
Band2=(HighD(1)-LowD(1))*Min(XiShu1,XiShu2);
SellBand=OpenToday-Band2;
BuyToCoverBand=OpenToday+Band2;
PlotNumeric("UpperBand",UpperBand);
PlotNumeric("LowerBand",LowerBand);
PlotNumeric("SellBand",SellBand);
PlotNumeric("BuyToCoverBand",BuyToCoverBand);
//PlotNumeric("OpenToday",OpenToday);
If(MarketPosition==1 and (High[1]-EntryPrice)/EntryPrice>=Hyl/100)
{
isHyl=1;
}
If(MarketPosition==1 and isHyl[1]==1 and (Low-EntryPrice)/EntryPrice<=Hc/100)
{
isHyl=0;
Sell(Lots,EntryPrice*(1+Hc));
}
If(MarketPosition==-1 and (EntryPrice-Low[1])/EntryPrice>=Hyl/100)
{
isHyl=1;
}
If(MarketPosition==-1 and isHyl[1]==1 and (EntryPrice-High)/EntryPrice<=Hc/100)
{
isHyl=0;
BuyToCover(Lots,EntryPrice*(1-Hc));
}
If(MarketPosition==-1 && High>=BuyToCoverBand)
{
If(Open>BuyToCoverBand) myEntryPrice=Open;
Else myEntryPrice=BuyToCoverBand;
BuyToCover(Lots,myEntryPrice);
}
If(MarketPosition==1 && Low<=SellBand)
{
If(Open<SellBand) myEntryPrice=Open;
Else myEntryPrice=SellBand;
Sell(Lots,myEntryPrice);
}
If(MarketPosition!=-1 && Low<=LowerBand)
{
If(Open<LowerBand) myEntryPrice=Open;
Else myEntryPrice=LowerBand;
SellShort(Lots,myEntryPrice);
}
If(MarketPosition!=1 && High>=UpperBand)
{
If(Open>UpperBand) myEntryPrice=Open;
Else myEntryPrice=UpperBand;
Buy(Lots,myEntryPrice);
}
End |
|