keymaker 發表於 13-10-19 10:30

AmiBroker 過濾器 Exploration 的問題

最近參看原文手冊 170 頁...提到可以用 Exploration 過濾出自己要的訊息..

於是有個點子..是想過濾出只有 Buy , Sell 信号的資料..只是不知如何撰寫..因此發帖請教大家..

勞倫斯 發表於 13-10-20 01:34

filter = buy or sell;   

joshsmi 發表於 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

keymaker 發表於 13-10-20 07:21

本帖最後由 keymaker 於 13-10-20 07:23 編輯

joshsmi 發表於 13-10-20 03:34 static/image/common/back.gif
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 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'.


kilroy 發表於 13-10-20 07:49

keymaker 發表於 13-10-20 07:21 static/image/common/back.gif
How do you show column 'Entry date/time' & 'Entry price' with button in Analysis window?
...

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

請服用上述網址~~

參考函數 AddColumn

通常用 scan 或 exploration

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

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

送訊號給 brokerage 的 API 下單


參考看看了~

kilroy 發表於 13-10-20 07:53

本帖最後由 kilroy 於 13-10-20 08:13 編輯

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

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

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

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

joshsmi 發表於 13-10-20 07:57

本帖最後由 joshsmi 於 13-10-20 07:59 編輯

keymaker 發表於 13-10-20 07:21 static/image/common/back.gif
How do you show column 'Entry date/time' & 'Entry price' with 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 ) );

keymaker 發表於 13-10-20 10:18

本帖最後由 keymaker 於 13-10-20 10:29 編輯

joshsmi 發表於 13-10-20 07:57 static/image/common/back.gif
for example

dt         = DateTime();
your code works fine,
but the entrydate becomes a number after I press 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!!


kilroy 發表於 13-10-20 11:59

keymaker 發表於 13-10-20 10:18 static/image/common/back.gif
your code works fine,
but the entrydate becomes a number after I press 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" );



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


joshsmi 發表於 13-10-20 17:15

keymaker 發表於 13-10-20 10:18 static/image/common/back.gif
your code works fine,
but the entrydate becomes a number after I press button, how do I s ...

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

joshsmi 發表於 13-10-20 17:22

本帖最後由 joshsmi 於 13-10-20 19:17 編輯

keymaker 發表於 13-10-20 10:18 static/image/common/back.gif
your code works fine,
but the entrydate becomes a number after I press 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/



joshsmi 發表於 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 );
}

keymaker 發表於 13-10-20 18:14

joshsmi 發表於 13-10-20 17:37 static/image/common/back.gif
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?







joshsmi 發表於 13-10-20 18:57

keymaker 發表於 13-10-20 18:14 static/image/common/back.gif
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.

keymaker 發表於 13-10-20 19:17

本帖最後由 keymaker 於 13-10-20 19:19 編輯

joshsmi 發表於 13-10-20 18:57 static/image/common/back.gif
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?
頁: [1] 2
查看完整版本: AmiBroker 過濾器 Exploration 的問題