请管理帮忙看看为什么不止损 [开拓者 TB]
- 咨询内容:
这个总是不启动止损,只是在14:55平仓。另外,要想实盘测试,应该改动哪些呢?谢谢
Begin
TrailingStop2=(HighestAfterEntry-MyEntryPrice)*0.8;
TrailingStop3=(MyEntryPrice-LowestAfterEntry)*0.45;
MidLine = AverageFC(Close,Length);
Band = StandardDev(Close,Length,2);
UpLine = MidLine + Offset * Band;
DownLine = MidLine - Offset * Band;
PlotNumeric("UpLine",UpLine);
PlotNumeric("DownLine",DownLine);
PlotNumeric("MidLine",MidLine);
MA8=XAverage(Close,L8);
MA20=XAverage(Close,L20);
PlotNumeric("MA8",MA8);
PlotNumeric("MA20",MA20);
集合竞价和小节休息过滤
If(!CallAuctionFilter()) Return;
If(Time>=0.1455){//如果要实盘测试,把Time改为CurrentTime
If(MarketPosition == 1)
Sell(0,Close);
If(MarketPosition == -1)
BuyToCover(0,Close);
return;
}
If(BarsSinceEntry==0) //条件满足,开仓bar
{
HighestAfterEntry=Close;
LowestAfterEntry=Close;//赋初值为新价格
If(MarketPosition<>0)//有持仓时执行如下代码
{
HighestAfterEntry=Max(HighestAfterEntry,AvgEntryPrice);//开仓bar,将开仓价和当时的收盘价的较大值保留到HighestAfterEntry
LowestAfterEntry=Min(LowestAfterEntry,AvgEntryPrice);同上,较小值保留
}
}Else //非开仓bar时进行以下运算
{
HighestAfterEntry=Max(HighestAfterEntry,High);//记录下当前bar的最高点,用于下一个bar的跟踪止损判断
LowestAfterEntry=Min(LowestAfterEntry,Low);//同上,最低点
}
Commentary("HighestAfterEntry="+Text(HighestAfterEntry));
Commentary("LowestAfterEntry="+Text(LowestAfterEntry));
MinPoint=MinMove*PriceScale;
MyEntryPrice=AvgEntryPrice;
If(MarketPosition==1 And BarsSinceEntry>=1)//有多仓的情况
{
If(HighestAfterEntry[1]>=MyEntryPrice + TrailingStart2*minpoint)//第二级跟踪止损
{
If(Low<=HighestAfterEntry[1]-TrailingStop2);
{
MyExitPrice=HighestAfterEntry[1]-TrailingStop2);
If(Open<MyExitPrice)MyExitPrice=Open;//如果该bar跳空触发,则用开盘价代替
Sell(0,MyExitPrice);
Return;
}
}Else If(HighestAfterEntry[1]>=MyEntryPrice + TrailingStart1*minpoint)//第一级跟踪止损的条件
{
If(Low<=HighestAfterEntry[1]-TrailingStop1*MinPoint);
{
MyExitPrice=HighestAfterEntry[1]-TrailingStop1*minpoint;
If(Open<MyExitPrice)MyExitPrice=Open;//如果该bar跳空,则用开盘价代替
Sell(0,myexitprice);
Return;
}
}Else If(Low<=MyEntryPrice-StopLossSet*MinPoint)//初始止损设置
{
MyExitPrice=MyEntryPrice-StopLossSet*MinPoint;
if(Open<MyExitPrice)MyExitPrice=Open; //如果该bar跳空,则用开盘价代替
Sell(0,MyExitPrice);
return;
}
}Else If(MarketPosition==-1 And BarsSinceEntry>=1)//有空仓的情况
{
If(LowestAfterEntry[1]<=MyEntryPrice-TrailingStart2*MinPoint) //第二级跟踪止损
{
If(High>=LowestAfterEntry[1]+TrailingStop3)
{
MyExitPrice=LowestAfterEntry[1]+TrailingStop3);
If(Open>MyExitPrice)MyExitPrice=Open;//跳空,开盘价代替
BuyToCover(0,MyExitPrice);
return;
}
}Else If(LowestAfterEntry[1]<=MyEntryPrice-TrailingStart1*MinPoint)//第一级跟踪止损条件
{
If(High>=LowestAfterEntry[1]+TrailingStop1*MinPoint)
{
MyExitPrice=LowestAfterEntry[1]+TrailingStop1*MinPoint;
If(Open>MyExitPrice)MyExitPrice=Open; //跳空,开盘价代替
BuyToCover(0,MyExitPrice);
return;
}
}Else If(High>=MyEntryPrice + StopLossSet*MinPoint)
{
MyExitPrice=MyEntryPrice + StopLossSet*MinPoint;
If(Open>MyExitPrice)MyExitPrice=Open; //跳空,开盘价代替
BuyToCover(0,MyExitPrice);
return;
}
}
Con1=CrossOver(MA8,MidLine);
Con2=Crossunder(MA8,MidLine);
If (Con1 && High>MA8 && High>MA20 && MarketPosition == 0 && Vol > 0)//满足买入准备条件后ENTRYBAR数目内,且大于等于买入多头触发价,多单入场
Buy(0,Close);
Else If (Con2 && Low<MA8 && LOW<MA20 && MarketPosition == 0 && Vol > 0) //如果T为1,发一次空单
SellShort(0,Close);
End
- TB技术人员:
Begin
TrailingStop2=(HighestAfterEntry-MyEntryPrice)*0.8;
TrailingStop3=(MyEntryPrice-LowestAfterEntry)*0.45;
MidLine = AverageFC(Close,Length);
Band = StandardDev(Close,Length,2);
UpLine = MidLine + Offset * Band;
DownLine = MidLine - Offset * Band;
PlotNumeric("UpLine",UpLine);
PlotNumeric("DownLine",DownLine);
PlotNumeric("MidLine",MidLine);
MA8=XAverage(Close,L8);
MA20=XAverage(Close,L20);
PlotNumeric("MA8",MA8);
PlotNumeric("MA20",MA20);
集合竞价和小节休息过滤
If(!CallAuctionFilter()) Return;
If(Time>=0.1455){//如果要实盘测试,把Time改为CurrentTime
If(MarketPosition == 1)
Sell(0,Close);
If(MarketPosition == -1)
BuyToCover(0,Close);
return;
}
If(BarsSinceEntry==0) //条件满足,开仓bar
{
HighestAfterEntry=Close;
LowestAfterEntry=Close;//赋初值为新价格
If(MarketPosition<>0)//有持仓时执行如下代码
{
HighestAfterEntry=Max(HighestAfterEntry,AvgEntryPrice);//开仓bar,将开仓价和当时的收盘价的较大值保留到HighestAfterEntry
LowestAfterEntry=Min(LowestAfterEntry,AvgEntryPrice);同上,较小值保留
}
}Else //非开仓bar时进行以下运算
{
HighestAfterEntry=Max(HighestAfterEntry,High);//记录下当前bar的最高点,用于下一个bar的跟踪止损判断
LowestAfterEntry=Min(LowestAfterEntry,Low);//同上,最低点
}
Commentary("HighestAfterEntry="+Text(HighestAfterEntry));
Commentary("LowestAfterEntry="+Text(LowestAfterEntry));
MinPoint=MinMove*PriceScale;
MyEntryPrice=AvgEntryPrice;
If(MarketPosition==1 And BarsSinceEntry>=1)//有多仓的情况
{
If(HighestAfterEntry[1]>=MyEntryPrice + TrailingStart2*minpoint)//第二级跟踪止损
{
If(Low<=HighestAfterEntry[1]-TrailingStop2);
看到这里发现有个分号,不知道是啥意思。
有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友
可联系技术人员 QQ: 511411198 进行 有偿 编写!(不贵!点击查看价格!)
相关文章
-
没有相关内容