雙均線金叉開(kāi)多平空,死叉開(kāi)空平多,開(kāi)倉(cāng)間隔不小于50個(gè)bar
作者:開(kāi)拓者 TB 來(lái)源:cxh99.com 發(fā)布時(shí)間:2013年06月28日
- 咨詢內(nèi)容:
本帖最后由 leosu 于 2013-6-18 12:18 編輯
求編寫(xiě)公式?雙均線交叉,金叉開(kāi)多平空,死叉開(kāi)空平多,且兩次多(空)間隔不小于50個(gè)bar。先謝謝了!!
- TB技術(shù)人員:
最近 版主都忙什么 來(lái)幫幫我呀
- TB客服:
請(qǐng)大家?guī)蛶?
- 網(wǎng)友回復(fù):
再次頂起來(lái) 謝謝大家
- 網(wǎng)友回復(fù):
本帖最后由 rucrui 于 2013-6-25 11:15 編輯
沒(méi)人回復(fù)的話我來(lái)獻(xiàn)丑吧,雙均線交叉,金叉買死叉賣,買賣我都加了滑點(diǎn),用的次一根開(kāi)盤(pán)價(jià)避免信號(hào)閃爍。唯一你說(shuō)的間隔的,描述的有點(diǎn)簡(jiǎn)單,我按我的理解寫(xiě),就是前一個(gè)時(shí)間點(diǎn)開(kāi)多后50根BAR內(nèi)不再開(kāi)多,開(kāi)空同理,如果不一樣自己照著我寫(xiě)的稍微修改代碼就行。- Params
- Numeric n1(20);
- Numeric n2(60);
- Numeric lots(1);
- Numeric coverTime(50);
- Numeric splitRate(3);
-
- Vars
- Numeric splitDot; //交易滑點(diǎn)
- NumericSeries E1(0);
- NumericSeries E2(0);
- Numeric myprice;
- NumericSeries bCountTime(0);
- NumericSeries sCountTime(0);
-
- Begin
- splitDot=splitRate*MinMove()*PriceScale();
- E1=XAverage(C,n1);
- E2=XAverage(C,n2);
- PlotNumeric("E1",E1,0,Red);
- PlotNumeric("E2",E2,0,Green);
-
- bCountTime=bCountTime[1]+1;
- sCountTime=sCountTime[1]+1;
-
- If(MarketPosition==0)
- {
- If(E1[1]>E2[1] && bCountTime>coverTime)
- {
- myprice=Open+splitDot;
- Buy(lots, myprice);
- bCountTime=0;
- }
- else If(E1[1]<E2[1] && sCountTime>coverTime)
- {
- myprice=Open-splitDot;
- Sellshort(lots, myprice);
- sCountTime=0;
- }
- }
- else If(MarketPosition==1)
- {
- If(E1[1]<E2[1])
- {
- myprice=Open-splitDot;
- Sell(lots,myprice);
- If(sCountTime>coverTime)
- {
- Sellshort(lots, myprice);
- sCountTime=0;
- }
- }
- }
- else If(MarketPosition==-1)
- {
- If(E1[1]>E2[1])
- {
- myprice=Open+splitDot;
- BuyToCover(lots,myprice);
- If(bCountTime>coverTime)
- {
- Buy(lots, myprice);
- bCountTime=0;
- }
- }
- }
-
- Commentary("bCountTime:"+Text(bCountTime));
- Commentary("sCountTime:"+Text(sCountTime));
- End
-
復(fù)制代碼 |