麻烦客服帮我把一个简单的均线模型改为金字塔的
//------------------------------------------------------------------------
// 简称:DualMA
// 名称:双均线交易系统
// 类别: 交易指令
// 类型: 用户应用
//------------------------------------------------------------------------
Params
Numeric FastLength(3); //短周期
Numeric SlowLength(10); //长周期
Numeric StopPoint(30); //止损点
Numeric WinPoint(100); //止赢点
Numeric FlostStopStartPoint(50); //浮动止损启动条件
Numeric FlostStopPoint(20); //浮动止损点
Numeric TradeUint(5); //每次交易手数
Vars
NumericSeries AvgValue1;
NumericSeries AvgValue2;
BoolSeries bCrossOver(false);
BoolSeries bCrossDn(False);
Begin
AvgValue1 = AverageFC(CLOSE,FastLength);
AvgValue2 = AverageFC(CLOSE,SlowLength);
PlotNumeric("MA1",AvgValue1);
PlotNumeric("MA2",AvgValue2);
bCrossOver = CrossOver(AvgValue1,AvgValue2);
bCrossDn = CrossUnder(AvgValue1,AvgValue2);
//均线交叉时开仓
if(bCrossOver[1])
{
if(MarketPosition != 1)
Buy(TradeUint,Open);
}
Else if(bCrossDn[1])
{
if(MarketPosition != -1)
SellShort(TradeUint,Open);
}
//止盈止损
SetWinPoint(WinPoint);
//止损点
SetStopPoint(StopPoint);
//浮动止损
SetFloatStopPoint(FlostStopStartPoint,FlostStopPoint);
PlotNumeric("Assets",Available+PositionProfit+Margin);
SetOwnAxis("Assets");
End
//Numeric FastLength(3); //短周期
//Numeric SlowLength(10); //长周期
fastlength:=3;
slowlength:=10;
//Numeric StopPoint(30); //止损点
//Numeric WinPoint(100); //止赢点
stoppoint:=30;
winpoint:=100;
//Numeric FlostStopStartPoint(50); //浮动止损启动条件
//Numeric FlostStopPoint(20); //浮动止损点
floststopstartpoint:=50;
floststoppoint:=20;
//Numeric TradeUint(5); //每次交易手数
tradernint:=5;
//Vars 变量
//NumericSeries AvgValue1; 平均线
//NumericSeries AvgValue2;平均线
//BoolSeries bCrossOver(false);是否上穿
//BoolSeries bCrossDn(False);是否下穿
//Begin开始
AvgValue1: ma(CLOSE,FastLength),linethick3;
AvgValue2: ma(CLOSE,SlowLength),linethick3;
//PlotNumeric("MA1",AvgValue1);
//PlotNumeric("MA2",AvgValue2);绘制均线
bCrossOver: = Cross(AvgValue1,AvgValue2);//判断是否上穿
bCrossDn: = Cross(AvgValue2,AvgValue1);//判断是否下穿
//均线交叉时开仓
//if(bCrossOver[1])
{
if(MarketPosition != 1)
Buy(TradeUint,Open);上穿买入开仓
}
//Else if(bCrossDn[1])
{
if(MarketPosition != -1)
SellShort(TradeUint,Open);下穿卖出开仓
}
if bcrossover then buy(holding=0,5,marketr);
if bcrossdn then buyshort(holding=0,5,marketr);
if c-enterprice>100 then sell(1,0,marketr);
if enterprice-c>100 then sellshort(1,0,marketr);
if enterprice-c>30 then sell(1,0,marketr);
if c-enterprice>30 then sellshort(1,0,marketr);
if hhv(h,enterbars+1)>enterprice+50 and c<hhv(h,enterbars+1)-20 then sell(1,0,marketr);
if llv(l,enterbars+1)<enterprice-50 and c>llv(l,enterbars+1)+20 then sellshort(1,0,marketr);
均线交叉平仓同时反向开仓怎么写?
if bcrossover then buy(holding=0,5,marketr);
if bcrossdn then buyshort(holding=0,5,marketr);
改为:
if bcrossover then begin
sellshort(1,0,marketr);
buy(holding=0,5,marketr);
end
if bcrossdn then begin
sell(1,0,marketr);
buyshort(holding=0,5,marketr);
end