是否偷價?
作者:開拓者 TB 來源:cxh99.com 發布時間:2016年09月16日
- 咨詢內容:
你好!下面的代碼實盤的時候有問題嗎?存在偷價嗎?
if ( MarketPosition==0 and c[1]>uprange and Time>0.0900000 and time<0.143000 and h>Highest(h[1],5) and c[2]>uprange and c[3]>uprange )
{
Buy(lots,Max(open,Highest(h[1],5))+minpoint);
}
在描述哪里出現 警告語句:FOR,WHILE,IF,ELSE中包含序列函數,可能存在潛在的邏輯錯誤。請確認代碼無誤。這樣的提示
- TB技術人員:
uprange是一個變量還是一個固定的參數?
使用一個中間變量將Highest(h[1],5)來進行賦值 后,將該變量來替換原文中使用了Highest(h[1],5)的地方
- TB客服:
小米 發表于 2016-5-4 09:06
uprange是一個變量還是一個固定的參數?
使用一個中間變量將Highest(h[1],5)來進行賦值 后,將該變量來替換 ...
是一個變量,但回溯了!這個沒有問題。我按照你下面的來做了,就是測試出來的曲線差很遠,所以想問問這是什么原因?
- 網友回復:
zsqh0250000777 發表于 2016-5-4 09:51
是一個變量,但回溯了!這個沒有問題。我按照你下面的來做了,就是測試出來的曲線差很遠,所以想問問這是 ...
代碼貼 一下啊。。
我不知道您是怎么寫的,沒法回答呢。
- 網友回復:
小米 發表于 2016-5-4 09:53
代碼貼 一下啊。。
我不知道您是怎么寫的,沒法回答呢。
Params
Numeric lots(1);
Numeric k(0.27);
Numeric stoploss(100);
Numeric stopwin(200);
Vars
NumericSeries tenclose;
NumericSeries ma12;
NumericSeries kd;
NumericSeries kk;
NumericSeries uprange;
NumericSeries downrange;
Numeric minpoint;
Begin
minpoint=MinMove*PriceScale;
if(time==0.100000 or time==0.110000 or time==0.143000 or time==0.150000 )
{
tenclose=close[1];
}Else if (time<>0.100000 or Time<>0.110000 or Time<>0.143000)
{
tenclose=tenclose[1];
}
ma12=Average(c[1],12);
//盤整
uprange=tenclose+k*abs(CloseD(1)-openD(1));
downrange=tenclose-k*abs(CloseD(1)-openD(1));
kd=Highest(h[1],5);
kk=lowest(l[1],5);
PlotNumeric("up",uprange);
PlotNumeric("down",downrange);
if ( MarketPosition==0 and c[1]>uprange and Time>0.0900000 and time<0.143000 and h>Highest(h[1],5) and c[2]>uprange and c[3]>uprange )
{
Buy(lots,Max(open,Highest(h[1],5))+minpoint);
}
if ( MarketPosition==0 and c[1]<downrange and time>0.090000 and time<0.143000 and l<lowest(l[1],5) and c[2]<downrange and c[3]<downrange )
{
SellShort(lots,Min(open,lowest(l[1],5))-minpoint);
}
if ( h[1]<downrange and h[1]<ma12 and BarsSinceEntry>5)
{
Sell(lots,open-minpoint);
}
if (l[1]>uprange and l[1]>ma12 and BarsSinceEntry>5)
{
BuyToCover(lots,open+minpoint);
}
if (c[1]-EntryPrice>stoploss and MarketPosition<0)
{
BuyToCover(lots,open+minpoint);
}
if (EntryPrice-c[1]>stoploss and MarketPosition>0)
{
sell(lots,open-minpoint);
}
if (c[1]-EntryPrice>stopwin and MarketPosition>0)
{
sell(lots,open-minpoint);
}
if (EntryPrice-c[1]>stopwin and MarketPosition<0)
{
BuyToCover(lots,open+minpoint);
}
if (c[1]-EntryPrice>100 and MarketPosition>0 and BarsSinceEntry<5 )
{
sell(lots,open-minpoint);
}
if (EntryPrice-c[1]>100 and MarketPosition<0 and BarsSinceEntry>5)
{
BuyToCover(lots,open+minpoint);
}
if (time>=0.145500 and MarketPosition<>0 )
{
sell(lots,open-minpoint);
BuyToCover(lots,open+minpoint);
}
end
|