为什么实盘与回测总差好几个点的价格 [开拓者 TB]
-
咨询内容:
Params Numeric lots(1); Numeric Length(6); Numeric StopLossSet(2); //Numeric TrailingStop(5); // 跟踪止损百分比 Numeric AmplitudeSet(80);
Numeric XZ(16);
Numeric Offset(4);
Vars Numeric stopPoint; NumericSeries highChannel; NumericSeries lowChannel; NumericSeries rateOfHighToLow;//收盘价到的最低价 在 最高价到最低价的比列(N个Bar) NumericSeries avgRateOfHTL; NumericSeries doubleAvgRateOfHTL; NumericSeries fastMA; NumericSeries slowMA; Bool bBuyCon; Bool bSellCon; NumericSeries tradeNum; Numeric MinPoint;//最小价格调动点 Numeric StopProfitPrice;//止盈价格 NumericSeries HigherAfterEntry;//进场后,K线走势的最高价 NumericSeries LowerAfterEntry;//进场后,K线走势的最低价 Numeric StopLine(0);//止损、止盈线 Begin If( High == Low) return ; MinPoint = MinMove*PriceScale; stopPoint = OpenD(1)*StopLossSet*0.01; If(Date != DATE[1]) { highChannel = High; lowChannel = Low; //tradeNum = 0; }Else { highChannel = Max(highChannel[1],High); lowChannel = Min(lowChannel[1],Low); } rateOfHighToLow = Abs(Close - Lowest(Low,3*Length))/(Highest(High,3*Length)-Lowest(Low,3*Length))*100;//收盘价与最低价占比整根K线的比例 avgRateOfHTL = SMA(rateOfHighToLow,Length,1); // 比例再平均 doubleAvgRateOfHTL = SMA(avgRateOfHTL,Length,1);// 比例再平均 //PlotNumeric("rateOfHighToLow",rateOfHighToLow); //PlotNumeric("avgRateOfHTL",avgRateOfHTL); //PlotNumeric("doubleAvgRateOfHTL",doubleAvgRateOfHTL); fastMA = Average(Close,Length/2); slowMA = Average(Close,Length); bBuyCon = avgRateOfHTL[1] > AmplitudeSet //占比大于80% 多是阳线或者上涨情况 And fastMA[1] > slowMA[1] And Close[1] > fastMA[1] //两重均线判断是否是多头排列情况 And highChannel[1]/lowChannel[1] < 1+0.001*XZ And MarketPosition != 1; //当日振幅不大于 千XZ的值 防止突破价位已经不好 bSellCon = avgRateOfHTL[1] < 100 - AmplitudeSet //占比小于20% And fastMA[1] < slowMA[1] And Close[1] < fastMA[1] //两重均线判断是否是空头排列情况 And highChannel[1]/lowChannel[1] < 1+0.001*XZ And MarketPosition != -1; //当日振幅不大于 千XZ的值 防止突破价位已经不好 If(bBuyCon == True) { //PlotString("bBuy","bBuy",Low,Red);
Buy(lots,Open -Offset*MinPoint); Return; } If(bSellCon == True) { //PlotString("bSell","bSell",High,Green); SellShort(lots,Open+Offset*MinPoint); Return; } //Commentary("bBuyCon = "+IIFString(bBuyCon,"True","false")); //Commentary("bSellCon = "+IIFString(bSellCon,"True","false")); //Commentary("(avgRateOfHTL) "+Text(avgRateOfHTL)); If(MarketPosition == 1 And Low <= AvgEntryPrice - stopPoint) { Sell(0,Min(Open,AvgEntryPrice - stopPoint)+Offset*MinPoint); Return; }
If(MarketPosition == -1 And High >= AvgEntryPrice + stopPoint) { BuyToCover(0,Max(Open,AvgEntryPrice + stopPoint)-Offset*MinPoint); Return; } End来源:CXH99.COM
-
TB技术人员:
这代码没法看吧?
可以先看一下信号发生的时间所在的价格与实盘委托价格是否接近?
若不接近,原因是什么?公式的价格写得不合理?信号所在合约是指数而下单是主力?等等原因 -
TB客服:
复制到软件下看看,价格怎么调成合理?
-
网友回复:
Params
Numeric lots(1);
Numeric Length(6);
Numeric StopLossSet(2); Numeric TrailingStop(5); // 跟踪止损百分比
Numeric AmplitudeSet(80);
Numeric XZ(16);
Numeric Offset(4);
Vars
Numeric stopPoint; NumericSeries highChannel; NumericSeries lowChannel; NumericSeries rateOfHighToLow;//收盘价到的最低价 在 最高价到最低价的比列(N个Bar)
NumericSeries avgRateOfHTL; NumericSeries doubleAvgRateOfHTL; NumericSeries fastMA; NumericSeries slowMA; Bool bBuyCon;
Bool bSellCon; NumericSeries tradeNum; Numeric MinPoint;//最小价格调动点 Numeric StopProfitPrice;//止盈价格 NumericSeries HigherAfterEntry;//进场后,K线走势的最高价 NumericSeries LowerAfterEntry;//进场后,K线走势的最低价
Numeric StopLine(0);//止损、止盈线 Begin
If( High == Low) return ; MinPoint = MinMove*PriceScale; stopPoint = OpenD(1)*StopLossSet*0.01; If(Date != DATE[1])
{ highChannel = High; lowChannel = Low; //tradeNum = 0; }Else
{ highChannel = Max(highChannel[1],High); lowChannel = Min(lowChannel[1],Low); } rateOfHighToLow = Abs(Close - Lowest(Low,3*Length))/(Highest(High,3*Length)-Lowest(Low,3*Length))*100;//收盘价与最低价占比整根K线的比例 avgRateOfHTL = SMA(rateOfHighToLow,Length,1); // 比例再平均 doubleAvgRateOfHTL = SMA(avgRateOfHTL,Length,1);// 比例再平均 //PlotNumeric("rateOfHighToLow",rateOfHighToLow); //PlotNumeric("avgRateOfHTL",avgRateOfHTL); //PlotNumeric("doubleAvgRateOfHTL",doubleAvgRateOfHTL); fastMA = Average(Close,Length/2); slowMA = Average(Close,Length); bBuyCon = avgRateOfHTL[1] > AmplitudeSet //占比大于80% 多是阳线或者上涨情况 And fastMA[1] > slowMA[1] And Close[1] > fastMA[1] //两重均线判断是否是多头排列情况 And highChannel[1]/lowChannel[1] < 1+0.001*XZ And MarketPosition != 1; //当日振幅不大于 千XZ的值 防止突破价位已经不好
bSellCon = avgRateOfHTL[1] < 100 - AmplitudeSet //占比小于20% And fastMA[1] < slowMA[1] And Close[1] < fastMA[1] //两重均线判断是否是空头排列情况 And highChannel[1]/lowChannel[1] < 1+0.001*XZ And MarketPosition != -1; //当日振幅不大于 千XZ的值 防止突破价位已经不好
If(bBuyCon == True) { //PlotString("bBuy","bBuy",Low,Red);
Buy(lots,Open -Offset*MinPoint); Return; } If(bSellCon == True) { //PlotString("bSell","bSell",High,Green); SellShort(lots,Open+Offset*MinPoint); Return; } //Commentary("bBuyCon = "+IIFString(bBuyCon,"True","false")); //Commentary("bSellCon = "+IIFString(bSellCon,"True","false")); //Commentary("(avgRateOfHTL) "+Text(avgRateOfHTL)); If(MarketPosition == 1 And Low <= AvgEntryPrice - stopPoint) { Sell(0,Min(Open,AvgEntryPrice - stopPoint)+Offset*MinPoint); Return; }
If(MarketPosition == -1 And High >= AvgEntryPrice + stopPoint) { BuyToCover(0,Max(Open,AvgEntryPrice + stopPoint)-Offset*MinPoint); Return; }
End
有思路,想编写各种指标公式,交易模型,选股公式,还原公式的朋友
可联系技术人员 QQ: 262069696 或微信号:cxh99cxh99 进行 有偿收费 编写!
(注:由于人数限制,QQ或微信请选择方便的一个联系我们就行,加好友时请简单备注下您的需求,否则无法通过。谢谢您!)
相关文章
-
没有相关内容