- 精华
- 0
- 在线时间
- 55 小时
- UID
- 175723
- 积分
- 48
- 帖子
- 26
- 阅读权限
- 10
- 注册时间
- 2013-11-15
- 最后登录
- 2015-4-16
- 精华
- 0
- UID
- 175723
- 积分
- 48
- 帖子
- 26
- 主题
- 8
- 阅读权限
- 10
- 注册时间
- 2013-11-15
- 最后登录
- 2015-4-16
|
本帖最后由 torowills 于 2013-12-5 18:53 编辑
Params
BOOL lastprofitabletradefilter(True);
Vars
NumericSeries ma1;
NumericSeries ma2;
boolSeries lastbuy(false);
boolSeries lastsell(false);
NumericSeries takeprofitset(10);
Numeric myentryprice;
Numeric myexitprice;
Numeric minpoint;
Begin
If(barstatus==0)
{
lastbuy=true;
lastsell=true;
}
Commentary("lastbuy="+iifstring(lastbuy,"true","False"));
Commentary("lastsell="+iifstring(lastsell,"true","False"));
minpoint=MinMove*PriceScale;
ma1=AverageFC(close,5);
PlotNumeric("MA1",ma1);
ma2=AverageFC(close,10);
PlotNumeric("MA2",ma2);
If(marketposition==0)
{ If(CrossOver(ma1[1],ma2[1]) && ((!lastprofitabletradefilter)or(lastbuy)))
{Buy(1,open);
lastbuy=False;
lastsell=true;
MyEntryPrice=open;}
if(crossunder(ma1[1],ma2[1]) && ((!lastprofitabletradefilter)or(lastsell)))
{SellShort(1,open);
lastsell=false;
lastbuy=True;
MyEntryPrice=open;}
}
if(marketposition==1)
{ if(high>=myentryprice+TakeProfitSet*minpoint)
{ myexitprice=myentryprice+TakeProfitSet*minpoint;
If(Open > MyExitPrice)
{MyExitPrice = Open;
Sell(0,MyExitPrice);
lastbuy=False;
lastsell=true;}
}else
{
if(CrossUnder(ma1[1],ma2[1]))
{Sell(0,open);
lastbuy=False;
lastsell=true;}
}
}
else if(marketposition==-1 )
{ If(Low <= MyEntryPrice - TakeProfitSet*MinPoint)
{ MyExitPrice = MyEntryPrice - TakeProfitSet*MinPoint;
If(Open < MyExitPrice)
{MyExitPrice = Open;
BuyToCover(0,MyExitPrice);
lastsell=false;
lastbuy=True;}
}else
{
if(CrossOver(ma1[1],ma2[1]))
{BuyToCover(0,open);
lastsell=false;
lastbuy=True;}
}
}
End
希望达到的效果是,5分钟K线情况下,
5均线上穿10均线,开多,10跳止盈,(开仓后若下穿止损)。不管是止盈还是止损,不再开多,坐等开空
5均线下穿10均线,开空,10跳止盈,(开仓后若上穿止损)。不管是止盈还是止损,不再开空,坐等开多
请老师帮忙看看这模型编写上有没有什么问题,个人发现的问题如下,请老师帮忙修改
存在几个问题:
1,编译的时候跳出来4个逻辑错误,
2,回溯:举了能看得见的例子IF1312,12月3号15.00开空,为什么在9.15分满足了10跳的利润,为什么它没止盈,反而到了9.35去止损了?
3, 回溯:举了能看得见的例子IF1312, 12月4号9.35 明显5均线上穿10均线,为什么没开多?
本人新人再次希望得到老师的帮助与提点
|
|