雙均線金叉開多平空,死叉開空平多,開倉間隔不小于50個bar [開拓者 TB]
- 咨詢內(nèi)容:
本帖最后由 leosu 于 2013-6-18 12:18 編輯
求編寫公式?雙均線交叉,金叉開多平空,死叉開空平多,且兩次多(空)間隔不小于50個bar。先謝謝了??! - TB技術(shù)人員:
最近 版主都忙什么 來幫幫我呀
- TB客服:
請大家?guī)蛶?
- 網(wǎng)友回復(fù):
再次頂起來 謝謝大家
- 網(wǎng)友回復(fù):
本帖最后由 rucrui 于 2013-6-25 11:15 編輯
沒人回復(fù)的話我來獻(xiàn)丑吧,雙均線交叉,金叉買死叉賣,買賣我都加了滑點(diǎn),用的次一根開盤價避免信號閃爍。唯一你說的間隔的,描述的有點(diǎn)簡單,我按我的理解寫,就是前一個時間點(diǎn)開多后50根BAR內(nèi)不再開多,開空同理,如果不一樣自己照著我寫的稍微修改代碼就行。- 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
- Params
有思路,想編寫各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友
可聯(lián)系技術(shù)人員 QQ: 1145508240 (不貴!點(diǎn)擊查看價格!)
相關(guān)文章
-
沒有相關(guān)內(nèi)容