COCO研究院

 找回密碼
 註冊
搜索
查看: 3283|回復: 15

AmiBroker 過濾器 Exploration 的問題

[複製鏈接]
發表於 13-10-19 10:30 | 顯示全部樓層 |閱讀模式
最近參看原文手冊 170 頁...提到可以用 Exploration 過濾出自己要的訊息..

於是有個點子..是想過濾出只有 Buy , Sell 信号的資料..只是不知如何撰寫..因此發帖請教大家..
發表於 13-10-20 01:34 | 顯示全部樓層
filter = buy or sell;   
發表於 13-10-20 03:34 | 顯示全部樓層
If you wanna simulate individual backtest in exploration mode then
Filter = Sell;
Filter = Cover;
or filter = Sell OR Cover; are enough

for scan in exploration you would need filter = Buy or Sell;
etc.


Here http://img854.imageshack.us/img854/2708/6bq8.png is a picture that shows simulation of individual backtest in exploration mode

評分

參與人數 1金錢 +2 收起 理由
keymaker + 2 太強了

查看全部評分

 樓主| 發表於 13-10-20 07:21 | 顯示全部樓層
本帖最後由 keymaker 於 13-10-20 07:23 編輯
joshsmi 發表於 13-10-20 03:34
If you wanna simulate individual backtest in exploration mode then
Filter = Sell;
Filter = Cover;  ...

How do you show column 'Entry date/time' & 'Entry price' with [Explore] button in Analysis window?

I mean that if you use Filter = sell or cover then
what Addcolumn code should we apply for the 'Entry date/time' & 'Entry price'?I think that sell or cover just catching the 'Exit date/time' & 'Exit price'.


發表於 13-10-20 07:49 | 顯示全部樓層
keymaker 發表於 13-10-20 07:21
How do you show column 'Entry date/time' & 'Entry price' with [Explore] button in Analysis window?
...

http://www.amibroker.com/guide/h_exploration.html

請服用上述網址~~

參考函數 AddColumn

通常用 scan 或 exploration

是掃描市場,看哪檔個股或是哪個商品有進出訊號,或符合進出場條件

而進階一點用法就是用在不開圖表自動下單 (auto trading)

送訊號給 brokerage 的 API 下單


參考看看了~

評分

參與人數 1金錢 +2 收起 理由
keymaker + 2 按一個讚

查看全部評分

發表於 13-10-20 07:53 | 顯示全部樓層
本帖最後由 kilroy 於 13-10-20 08:13 編輯

可是如果只單純要訊號出來,那其實直接用 SCAN 就可以了

設定好週期、掃描間隔,就可以一直不停的掃 (auto scan)

掃到訊號出來後送單出去完成下單

我想這是樓主你想要做的事情吧

評分

參與人數 1金錢 +2 收起 理由
keymaker + 2 目前敝人是在測試 exploration 部份.

查看全部評分

發表於 13-10-20 07:57 | 顯示全部樓層
本帖最後由 joshsmi 於 13-10-20 07:59 編輯
keymaker 發表於 13-10-20 07:21
How do you show column 'Entry date/time' & 'Entry price' with [Explore] button in Analysis window?
...

for example

dt         = DateTime();

entrydate  = IIf( /*Long*/   Sell, ValueWhen( Buy, dt ),                 
            
IIf( /*Short*/ Cover, ValueWhen( Short, dt ),
            
0 ) );

entryprice =
IIf( /*Long*/  Sell, ValueWhen( Buy, BuyPrice ),
            
IIf( /*Short*/ Cover, ValueWhen( Short, ShortPrice ),
            
0 ) );

評分

參與人數 1金錢 +2 收起 理由
keymaker + 2 太強了

查看全部評分

 樓主| 發表於 13-10-20 10:18 | 顯示全部樓層
本帖最後由 keymaker 於 13-10-20 10:29 編輯
joshsmi 發表於 13-10-20 07:57
for example

dt         = DateTime();
your code works fine,
but the entrydate becomes a number after I press [Explore] button, how do I solve it?
where
entrydate  = IIf( /*Long*/   Sell, ValueWhen( Buy, dt ),  IIf( /*Short*/ Cover, ValueWhen( Short, dt ), 0 ) );

and the other question is how do I show add a column to tell me "Buy" or "Short" on exploration?Thank you anyway!!


發表於 13-10-20 11:59 | 顯示全部樓層
keymaker 發表於 13-10-20 10:18
your code works fine,
but the entrydate becomes a number after I press [Explore] button, how do I s ...
and the other question is how do I show add a column to tell me "Buy" or "Short" on exploration?Thank you anyway!!


J大上一篇不是有寫一個 sample


那你要在 exploration 裡顯示某欄位就是用 AddColumn  來寫呀


e.g.

Buy=Cross(MACD(),Signal());
Sell=Cross(Signal(), MACD());
Filter=Buy OR Sell;
Short = Sell;
Cover = Buy;

entryprice = IIf(Buy, ValueWhen( Buy, BuyPrice ),
             IIf(Short, ValueWhen( Short, ShortPrice ),
             0 ) );

AddColumn( IIf( Buy, 66, 83 ), "Signal", formatChar );
AddColumn( entryprice , "EntryPrice" );



這樣就可以搞啦~ 玩玩看吧


評分

參與人數 1金錢 +2 收起 理由
keymaker + 2 太強了

查看全部評分

發表於 13-10-20 17:15 | 顯示全部樓層
keymaker 發表於 13-10-20 10:18
your code works fine,
but the entrydate becomes a number after I press [Explore] button, how do I s ...

Dates need formatDateTime in AddColumn function. Just take a look in the help file.

發表於 13-10-20 17:22 | 顯示全部樓層
本帖最後由 joshsmi 於 13-10-20 19:17 編輯
keymaker 發表於 13-10-20 10:18
your code works fine,
but the entrydate becomes a number after I press [Explore] button, how do I s ...

As for formatChar ...
If you use Filter = Sell || Cover;
then for example,

AddColumn( IIf (Sell, 66, IIf( Cover, 83, 32 ) ), "Trade", formatChar,......... );

http://www.asciitable.com/



發表於 13-10-20 17:37 | 顯示全部樓層
本帖最後由 joshsmi 於 13-10-20 19:14 編輯

Here is a simple example

tradedelay = 0;
SetTradeDelays( tradedelay, tradedelay, tradedelay, tradedelay );  

SetBacktestMode( backtestRegular );
SetOption( "FuturesMode", False );
SetOption( "InitialEquity", 100000);
// add other setoptions here or see backtest settings

Buy = Cross( MACD(), Signal() );
Sell = Cross( Signal(), MACD() );

Short = Sell;
Cover = Buy;

if ( tradedelay > 0 )
{
    array  =
Open;
    equityflag =
2;
}
else
{
    array  =
Close;
    equityflag =
1;
}

BuyPrice   = SellPrice = array;
ShortPrice = CoverPrice = array;

if ( Status( "action" ) == actionExplore )
{
    eq         =
Equity( equityflag, -1 );

    dt         =
DateTime();

    entrydate  =
IIf( /*Long*/   Sell, ValueWhen( Buy, dt ),                 
                 
IIf( /*Short*/ Cover, ValueWhen( Short, dt ),
                 
0 ) );

    entryprice =
IIf( /*Long*/   Sell, ValueWhen( Buy, BuyPrice ),
                 
IIf( /*Short*/ Cover, ValueWhen( Short, ShortPrice ),
                 
0 ) );

    exitprice  =
IIf( /*Long*/   Sell, SellPrice,
                 
IIf( /*Short*/ Cover, CoverPrice,
                 
0 ) );

    Filter = Sell || Cover;

   SetOption( "NoDefaultColumns", True );
   
AddTextColumn( Name(), "Ticker", 1.0, colorDefault, colorDefault, 70 );
   
AddColumn( IIf (Sell, 66, IIf( Cover, 83, 32 ) ), "Trade", formatChar );
   
AddColumn( entrydate, "Entry Date/Time", formatDateTime, colorDefault, colorDefault, 120 );
   
AddColumn( entryprice , "EntryPrice", 1.5 );
   
AddColumn( dt, "Exit Date/Time", formatDateTime, colorDefault, colorDefault, 120 );
   
AddColumn( exitprice , "ExitPrice", 1.5 );
}


評分

參與人數 1金錢 +2 收起 理由
keymaker + 2 化腐朽為神奇....

查看全部評分

 樓主| 發表於 13-10-20 18:14 | 顯示全部樓層
joshsmi 發表於 13-10-20 17:37
Here is a simple example

tradedelay = 0;
joshsmi ... you are awesome!!
after my testing of your code,
I found that first row of "Exit Date/Time" will be "Date Time 不正確",
but the other rows of "Exit Date/Time" will be fine,
I don't know how to modify this, could you please give a suggestion?







評分

參與人數 1金錢 +1 收起 理由
joshsmi + 1

查看全部評分

發表於 13-10-20 18:57 | 顯示全部樓層
keymaker 發表於 13-10-20 18:14
joshsmi ... you are awesome!!
after my testing of your code,
I found that first row of "Exit Date/T ...

Yeah, you are right. I have corrected the code. Filter variable must be below of Equity() function. In my original code on my hard drive it was correct but because I have used copy&paste here it was still above of equity(). Now it is correct. Re-copy the whole code.

評分

參與人數 1金錢 +2 收起 理由
keymaker + 2 按一個讚

查看全部評分

 樓主| 發表於 13-10-20 19:17 | 顯示全部樓層
本帖最後由 keymaker 於 13-10-20 19:19 編輯
joshsmi 發表於 13-10-20 18:57
Yeah, you are right. I have corrected the code. Filter variable must be below of Equity() function. ...

Thank you so much!
Everything is correct here,
but I don't know the purpose of variables SetTradeDelays, tradedelay,  equityflag.
Would you like to explain these for me?
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

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

GMT+8, 24-5-17 13:13

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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