jacklcl 發表於 14-4-30 01:13

請問在AFL裡如何使用另一個交易標

例如我有一策略, 而交易的是期貨A
期貨A符合條件後買入
但如果我想待另外一個期貨B也同時符合買入條件後
這時期貨A才買入
AFL裡應怎寫?我只知道是用Foreign這個AFL去找取期貨B的價格
但具體怎寫仍不明白{:4_161:}

kilroy 發表於 14-4-30 16:18

寫兩個AFL分別跑A和B商品,再個別把訊號丟出來給下單機下單

建議不要跑同一個圖表

參考看看了

DumbMoney 發表於 14-4-30 17:11

AB好像还是比较支持单品种单策略,多了容易乱

joshsmi 發表於 14-4-30 21:09

DumbMoney 發表於 14-4-30 17:11 static/image/common/back.gif
AB好像还是比较支持单品种单策略,多了容易乱

DumbMoney: "AB seems more in favour of single species and single strategy much easier"

Huh?

DumbMoney 發表於 14-4-30 23:18

joshsmi 發表於 14-4-30 21:09 static/image/common/back.gif
DumbMoney: "AB seems more in favour of single species and single strategy much easier"

Huh?

哈哈哈,是的,我就是说的这句。

joshsmi 發表於 14-5-2 07:16

本帖最後由 joshsmi 於 14-5-2 07:20 編輯

DumbMoney 發表於 14-4-30 23:18 static/image/common/back.gif
哈哈哈,是的,我就是说的这句。
I don't know what you mean but as for multiple strategies ...

BuyA = Cross( CCI( 20 ), 100 );
SellA = Cross( 100, CCI( 20 ) );

BuyB = Cross( MACD(), Signal() );
SellB = Cross( Signal(), MACD() );

A = B = 0;
Buy = Sell = 0;
for ( i = 0; i <BarCount; i ++ )
{
    if ( BuyA[ i ])
    {
      Buy[ i ] = 1;
      B = 0;
      A = 1;
    }   
    if ( BuyB[ i ] )
    {
      Buy[ i ]= 1;
      B = 1;
      A = 0;
    }
    if ( SellA[i] )
    {
      Sell[i] = 1;
    }
    if ( SellB[i] )
    {
      Sell[i] = 1;
    }
}

Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );

BuyPrice = SellPrice = Close;

_N( Title = StrFormat( "{{NAME}} - {{INTERVAL}} - {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%), Vol %g {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ), V ) );
Plot( C, "Close", ParamColor( "Color", colorDefault ), styleNoTitle | ParamStyle( "Style" ) | GetPriceStyle(), null, null, 0, 0, 1 );

PlotShapes( Buy*shapeSmallUpTriangle, colorGreen, 0, L, -15 );
PlotShapes( Buy*shapeHollowSmallUpTriangle, colorLightGrey, 0, L, -15 );
PlotShapes( Buy*shapeHollowSmallCircle, colorGreen, 0, BuyPrice, 0 );

PlotShapes( Sell*shapeDownArrow, colorRed, 0, H, -15 );
PlotShapes( Sell*shapeHollowDownArrow, colorLightGrey, 0, H, -15 );
PlotShapes( Sell*shapeHollowSmallCircle, colorRed, 0, SellPrice, 0 );

osdak 發表於 14-5-2 09:17

joshsmi 發表於 14-5-2 07:16
I don't know what you mean but as for multiple strategies ...

BuyA = Cross( CCI( 20 ), 100 );


Just wonder, for real time trading instead of backtesting, is it also "ok" to use for-loop? i haven't tried it, just wonder.....to me, for-loop is more easy to understand and manipulate.....

joshsmi 發表於 14-5-2 18:12

If you want to use loop then use loop.

DumbMoney 發表於 14-5-3 13:36

joshsmi 發表於 14-5-2 07:16 static/image/common/back.gif
I don't know what you mean but as for multiple strategies ...

BuyA = Cross( CCI( 20 ), 100 );


谢谢分享。。。。
頁: [1]
查看完整版本: 請問在AFL裡如何使用另一個交易標