略微增加调试代码不是可以止损的吗 PlotNumeric("ProtectStopPrice", ProtectStopPrice);
If(MarketPosition == 1 And BarsSinceEntry > 0 And Low <= ProtectStopPrice)
{
Sell(PostionLots, ProtectStopPrice);
PlotAuto("zhi", "止损",close);
}
回复:然后请针对你描述的所有问题,举例比如你认为 “设置的止损未起作用”请给出什么品种,几分几秒,图上哪里没止损
Params Numeric EFast(5); //短均线周期参数 Numeric ESlow(10); //长均线周期参数 Numeric StopLength(5); //止损统计周期数 Numeric PostionLots(1);//头寸 Vars Series<Numeric> MAEFast; //短均线 Series<Numeric> MAESlow; //长均线 Series<Numeric> Opint1; // 逆解交叉点值 Series<Numeric> AvgTR; Numeric ProtectStopPrice; //保护性止损价 Numeric TrailStopPrice; //跟踪性止损价 Series<Numeric> MyEntryPrice; // 开仓价格 Events OnBar(ArrayRef<Integer> indexs) { MAEFast = Average(Close, EFast); //短均线 MAESlow = Average(Close, ESlow); //长均线 Opint1 = ((ESlow - 1) * Average(Close[1], ESlow - 1) * EFast - (EFast - 1) * Average(Close[1], EFast - 1) * ESlow) / (ESlow - EFast); ProtectStopPrice = Lowest(Low[1],StopLength) * 0.99; TrailStopPrice = Highest(High[1],StopLength) * 1.01; If(MarketPosition <> 1 And MAEFast[1]<MAESlow[1] and High >= Opint1) { Buy(PostionLots, Max(Open, Opint1)); MyEntryPrice = Max(Open, Opint1); } If(MarketPosition<>1 And Low[1]<=Opint1[1] And Close[1]>=Opint1[1] And High >= Opint1) //过滤假死叉 { Buy(PostionLots,Max(Open,Opint1)); } If(MarketPosition == 1 And BarsSinceEntry > 0 And Low <= ProtectStopPrice) { Sell(PostionLots, ProtectStopPrice); } If(MarketPosition == 1 And BarsSinceEntry > 0 And High[1]>=Opint1[1] And Close[1]<=Opint1[1] And Low <= Opint1) //过滤假金叉 { Sell(PostionLots, Min(Open, opint1)); } If(MarketPosition == 1 And BarsSinceEntry > 0 And MAEFast[1]> MAESlow[1] And Low<Opint1) { Sell(PostionLots,Min(Open,Opint1)); } Range[0:DataSourceSize() - 1] { PlotNumeric("MAEFast", MAEFast); PlotNumeric("MAESlow", MAESlow); }
回复:你贴的3个代码都没有贴全 ,无法运行
回复:是全的啊
1.贴代码用代码模式2.止损未起作用 ,是怎么个不起作用3.优化一般指优化参数,不要和改错 改bug混淆
回复:Params
Numeric EFast(5); //短均线周期参数
Numeric ESlow(10); //长均线周期参数
Numeric StopLength(5); //止损统计周期数
Numeric PostionLots(1);//头寸
Vars
Series<Numeric> MAEFast; //短均线
Series<Numeric> MAESlow; //长均线
Series<Numeric> Opint1; // 逆解交叉点值
Series<Numeric> AvgTR;
Numeric ProtectStopPrice; //保护性止损价
Numeric TrailStopPrice; //跟踪性止损价
Series<Numeric> MyEntryPrice; // 开仓价格
Events
OnBar(ArrayRef<Integer> indexs)
{
MAEFast = Average(Close, EFast); //短均线
MAESlow = Average(Close, ESlow); //长均线
Opint1 = ((ESlow - 1) * Average(Close[1], ESlow - 1) * EFast - (EFast - 1) * Average(Close[1], EFast - 1) * ESlow) / (ESlow - EFast);
ProtectStopPrice = Lowest(Low[1],StopLength) * 0.99;
TrailStopPrice = Highest(High[1],StopLength) * 1.01;
If(MarketPosition <> 1 And MAEFast[1]<MAESlow[1] and High >= Opint1)
{
Buy(PostionLots, Max(Open, Opint1));
MyEntryPrice = Max(Open, Opint1);
}
If(MarketPosition<>1 And Low[1]<=Opint1[1] And Close[1]>=Opint1[1] And High >= Opint1) //过滤假死叉
{
Buy(PostionLots,Max(Open,Opint1));
}
If(MarketPosition == 1 And BarsSinceEntry > 0 And Low <= ProtectStopPrice)
{
Sell(PostionLots, ProtectStopPrice);
}
If(MarketPosition == 1 And BarsSinceEntry > 0 And High[1]>=Opint1[1] And Close[1]<=Opint1[1] And Low <= Opint1) //过滤假金叉
{
Sell(PostionLots, Min(Open, opint1));
}
If(MarketPosition == 1 And BarsSinceEntry > 0 And MAEFast[1]> MAESlow[1] And Low<Opint1)
{
Sell(PostionLots,Min(Open,Opint1));
}
Range[0:DataSourceSize() - 1]
{
PlotNumeric("MAEFast", MAEFast);
PlotNumeric("MAESlow", MAESlow);
}
回复:Params
Numeric EFast(5); //短均线周期参数
Numeric ESlow(10); //长均线周期参数
Numeric StopLength(5); //止损统计周期数
Numeric PostionLots(1);//头寸
Vars
Series<Numeric> MAEFast; //短均线
Series<Numeric> MAESlow; //长均线
Series<Numeric> Opint1; // 逆解交叉点值
Series<Numeric> AvgTR;
Numeric ProtectStopPrice; //保护性止损价
Numeric TrailStopPrice; //跟踪性止损价
Series<Numeric> MyEntryPrice; // 开仓价格
Events
OnBar(ArrayRef<Integer> indexs)
{
MAEFast = Average(Close, EFast); //短均线
MAESlow = Average(Close, ESlow); //长均线
Opint1 = ((ESlow - 1) * Average(Close[1], ESlow - 1) * EFast - (EFast - 1) * Average(Close[1], EFast - 1) * ESlow) / (ESlow - EFast);
ProtectStopPrice = Lowest(Low[1],StopLength) * 0.99;
TrailStopPrice = Highest(High[1],StopLength) * 1.01;
If(MarketPosition <> 1 And MAEFast[1]<MAESlow[1] and High >= Opint1)
{
Buy(PostionLots, Max(Open, Opint1));
MyEntryPrice = Max(Open, Opint1);
}
If(MarketPosition<>1 And Low[1]<=Opint1[1] And Close[1]>=Opint1[1] And High >= Opint1) //过滤假死叉
{
Buy(PostionLots,Max(Open,Opint1));
}
If(MarketPosition == 1 And BarsSinceEntry > 0 And Low <= ProtectStopPrice)
{
Sell(PostionLots, ProtectStopPrice);
}
If(MarketPosition == 1 And BarsSinceEntry > 0 And High[1]>=Opint1[1] And Close[1]<=Opint1[1] And Low <= Opint1) //过滤假金叉
{
Sell(PostionLots, Min(Open, opint1));
}
If(MarketPosition == 1 And BarsSinceEntry > 0 And MAEFast[1]> MAESlow[1] And Low<Opint1)
{
Sell(PostionLots,Min(Open,Opint1));
}
Range[0:DataSourceSize() - 1]
{
PlotNumeric("MAEFast", MAEFast);
PlotNumeric("MAESlow", MAESlow);
}
回复:设置了sell前5周期最低点,但是体现在k线上,没有平掉
回复:设置了sell前5周期最低点,但是体现在k线上,没有平掉