COCO研究院

 找回密碼
 註冊
搜索
查看: 2114|回復: 8

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

[複製鏈接]
發表於 14-4-30 01:13 | 顯示全部樓層 |閱讀模式
例如我有一策略, 而交易的是期貨A
期貨A符合條件後買入
但如果我想待另外一個期貨B也同時符合買入條件後
這時期貨A才買入
AFL裡應怎寫?  我只知道是用Foreign這個AFL去找取期貨B的價格
但具體怎寫仍不明白
發表於 14-4-30 16:18 | 顯示全部樓層
寫兩個AFL分別跑A和B商品,再個別把訊號丟出來給下單機下單

建議不要跑同一個圖表

參考看看了

評分

參與人數 1金錢 +1 收起 理由
jacklcl + 1 謝謝指導

查看全部評分

發表於 14-4-30 17:11 | 顯示全部樓層
AB好像还是比较支持单品种单策略,多了容易乱
發表於 14-4-30 21:09 | 顯示全部樓層
DumbMoney 發表於 14-4-30 17:11
AB好像还是比较支持单品种单策略,多了容易乱

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

Huh?

發表於 14-4-30 23:18 | 顯示全部樓層
joshsmi 發表於 14-4-30 21:09
DumbMoney: "AB seems more in favour of single species and single strategy much easier"

Huh?

哈哈哈,是的,我就是说的这句。
發表於 14-5-2 07:16 | 顯示全部樓層
本帖最後由 joshsmi 於 14-5-2 07:20 編輯
DumbMoney 發表於 14-4-30 23:18
哈哈哈,是的,我就是说的这句。

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 );
發表於 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.....
發表於 14-5-2 18:12 | 顯示全部樓層
If you want to use loop then use loop.
發表於 14-5-3 13:36 | 顯示全部樓層
joshsmi 發表於 14-5-2 07:16
I don't know what you mean but as for multiple strategies ...

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

谢谢分享。。。。
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

手機版|Archiver|站長信箱|廣告洽詢|COCO研究院

GMT+8, 24-5-14 01:52

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回復 返回頂部 返回列表
理財討論網站 | AI繪圖AI超擬真美女AI beauty AI Stable DiffusionAI正妹AI Lookbook