有請小米,網校老師介紹的跟蹤止損,加載后只有開多平多 [開拓者 TB]
- 咨詢內容:
本帖最后由 abc123wh 于 2014-4-25 21:09 編輯
按照老師講解的跟蹤止盈的公式抄了一遍,然后加載到圖標上發現只有做多和平多的信號,但是公式里面有開空的語句,不知道為什么不能執行,請斑竹看看問題在什么地方?
Params
Numeric length1(10);
Numeric length2(20);
Numeric lots(1);
Numeric ATRlength(20);
Numeric trailstop(2);
Vars
NumericSeries ma1;
NumericSeries ma2;
NumericSeries ATRvalue;
NumericSeries HIAfterEnetry;
NumericSeries Loafterentry;
Numeric stopline;
BoolSeries blongstoped(False);
BoolSeries bshortstoped(false);
Begin
ATRvalue=AvgTrueRange(atrlength);
ma1=AverageFC(close,length1);
ma2=AverageFC(close,length2);
PlotNumeric ("ma1",ma1);
PlotNumeric ("ma2",ma2);
if (!blongstoped and MarketPosition<>1 and ma1[1]>ma2[1])
{
Buy(lots,open);
bshortstoped=False;
}
if (!bshortstoped And MarketPosition<>-1 and ma1[1]<ma2[1])
{
SellShort(lots,open);
blongstoped=False;
}
If(blongstoped And MarketPosition<>1 and High>=HIAfterEnetry)
{
buy(lots,Max(open,HIAfterEnetry));
blongstoped=False;
}
If (bshortstoped and MarketPosition<>-1 And low <=Loafterentry)
{
SellShort(lots,Min(open,Loafterentry));
bshortstoped=False;
}
if (MarketPosition==1 and BarsSinceEntry==0) HIAfterEnetry=High;
if (MarketPosition==1 and BarsSinceEntry>=1)HIAfterEnetry=max(HIAfterEnetry,High);
If (MarketPosition==-1 and BarsSinceEntry==0)Loafterentry=Low;
if (MarketPosition==-1 and BarsSinceEntry>=1)
Loafterentry=Min(Loafterentry,Low);
if (BarsSinceEntry>0 and MarketPosition==1)
{
stopline=HIAfterEnetry[1]-trailstop*ATRvalue[1];
If(low<=stopline)
{
Sell(0,min(open,stopline));
blongstoped=True;
}
}Else if (BarsSinceEntry>0 and MarketPosition==-1);
{
stopline=Loafterentry[1]+trailstop*ATRvalue[1];
If(high>=stopline)
{
BuyToCover(0,Max(open,stopline));
bshortstoped=True;
}
}
End
下面是截圖
222222222222222222222.jpg (98.68 KB, 下載次數: 0) 2014-4-25 11:06:31 上傳 - TB技術人員:
問題在于倒數第十行代碼里,最后邊多 了一個分號。去掉那個if( )后面的分號即可。
- TB客服:
小米 發表于 2014-4-25 13:17
問題在于倒數第十行代碼里,最后邊多 了一個分號。去掉那個if( )后面的分號即可。 ...
3q
有思路,想編寫各種指標公式,程序化交易模型,選股公式,預警公式的朋友
可聯系技術人員 QQ: 1145508240 進行 有償 編寫!(不貴!點擊查看價格!)
相關文章
-
沒有相關內容