- 精华
- 0
- 在线时间
- 40 小时
- UID
- 287475
- 积分
- 17
- 帖子
- 10
- 阅读权限
- 10
- 注册时间
- 2020-1-2
- 最后登录
- 2022-8-9
- 精华
- 0
- UID
- 287475
- 积分
- 17
- 帖子
- 10
- 主题
- 7
- 阅读权限
- 10
- 注册时间
- 2020-1-2
- 最后登录
- 2022-8-9
|
双均线交易系统带有固定点位止损止盈
有以下几个问题:
1.比方均线金叉进多,达到止盈目标止盈后形态上仍然是多头趋势,如何限制继续开仓?
2.如果前一次止损,后面再次开仓加一个突破过滤条件?
现在代码如下:
Params
Numeric length(10);
Numeric length1(20);
Numeric TakeProfitSet(50);
Numeric StopLossSet(30);
Numeric Lots(3);
Vars
NumericSeries AvgValue;
NumericSeries AvgValue1;
Numeric MyEntryPrice;
Numeric myexitprice;
Numeric Minpoint;
Begin
AvgValue = AverageFC(C,Length);
AvgValue1= AverageFC(C,Length1);
If(MarketPosition <>1 and AvgValue[1]> AvgValue1[1])
{
myentryprice=open;
Buy(LOTS,myentryprice);
}
If(MarketPosition <>-1 and AvgValue[1]< AvgValue1[1] )
{
myentryprice=open;
SellShort(LOTS,open);
}
/////
If(MarketPosition==1) // 有多仓的情况
{
if(high>=(myentryprice+TakeProfitSet*MinPoint))
{
myexitprice=(myentryprice+TakeProfitSet*MinPoint);
if(open>myexitprice)myexitprice=open;
Sell(0,myexitprice);
}Else if(low<=(myentryprice-StopLossSet*MinPoint))
{
myexitprice=(myentryprice-StopLossSet*MinPoint);
if(open<myexitprice)myexitprice=open;
Sell(0,myexitprice);
}
}
if(MarketPosition==-1) // 有空仓的情况
{
if(low<=(myentryprice-TakeProfitSet*MinPoint))
{
myexitprice=(myentryprice-TakeProfitSet*MinPoint);
if(open<myexitprice)myexitprice=open;
BuyToCover(0,myexitprice);
}Else if(High>=(myentryprice+StopLossSet*MinPoint))
{
myexitprice=(myentryprice+StopLossSet*MinPoint);
if(open>myexitprice)myexitprice=open;
BuyToCover(0,myexitprice);
}
}
End |
|