有請(qǐng)小米,網(wǎng)校老師介紹的跟蹤止損,加載后只有開(kāi)多平多 [開(kāi)拓者 TB]
- 咨詢(xún)內(nèi)容:
本帖最后由 abc123wh 于 2014-4-25 21:09 編輯
按照老師講解的跟蹤止盈的公式抄了一遍,然后加載到圖標(biāo)上發(fā)現(xiàn)只有做多和平多的信號(hào),但是公式里面有開(kāi)空的語(yǔ)句,不知道為什么不能執(zhí)行,請(qǐng)斑竹看看問(wèn)題在什么地方?
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, 下載次數(shù): 0) 2014-4-25 11:06:31 上傳 - TB技術(shù)人員:
問(wèn)題在于倒數(shù)第十行代碼里,最后邊多 了一個(gè)分號(hào)。去掉那個(gè)if( )后面的分號(hào)即可。
- TB客服:
小米 發(fā)表于 2014-4-25 13:17
問(wèn)題在于倒數(shù)第十行代碼里,最后邊多 了一個(gè)分號(hào)。去掉那個(gè)if( )后面的分號(hào)即可。 ...
3q
有思路,想編寫(xiě)各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友
可聯(lián)系技術(shù)人員 QQ: 1145508240 進(jìn)行 有償 編寫(xiě)!(不貴!點(diǎn)擊查看價(jià)格!)
相關(guān)文章
-
沒(méi)有相關(guān)內(nèi)容