关于平仓后再次开仓问题
双均线交易系统带有固定点位止损止盈有以下几个问题:
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> AvgValue1)
{
myentryprice=open;
Buy(LOTS,myentryprice);
}
If(MarketPosition <>-1 and AvgValue< AvgValue1 )
{
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 最好只在金叉、死叉出现时开仓,过了就不做了。对第二点,如果出现止损,要再等到新出现交叉再开仓。
If(MarketPosition <>1 and AvgValue <= AvgValue1 and AvgValue> AvgValue1)
Buy();
If(MarketPosition <>-1 and AvgValue >= AvgValue1 and AvgValue< AvgValue1)
SellShort(); Yuen_Lee 发表于 2021-8-3 11:44 static/image/common/back.gif
最好只在金叉、死叉出现时开仓,过了就不做了。对第二点,如果出现止损,要再等到新出现交叉再开仓。
If(Ma ...
谢谢! http://www.wjs7878.com/
页:
[1]