citrix 發表於 15-3-11 12:55

AFL掃描AB數據

各位大大,我有實時Tick數據通過real time feed保存到AB中,如何用AFL自動把Tick數據規整成1分鐘HLOC和5分鐘HLOC數據,AB的Charting裡面可以選擇1,5,15,30分鐘,AFL有現成的函數幹這個嗎?

zaqimon 發表於 15-3-11 19:13

可以用fopen, fputs匯出成文字檔

kilroy 發表於 15-3-11 19:45

小弟是用這個 AFL 參考看看

/*
Export intraday and EOD data to TXT files
One file for each stock
In the first line insert the directory you want to save them to, make sure the
directory exists
Select your charts to export with the "Apply to" filter in AA window
Select the timeframe period you want to save as using the AA "Settings"
Press Scan button
by Graham Kavanagh 05 Feb 2004
*/

fh = fopen( "c://RPT/"+Name()+".txt", "w");
if( fh )
{
   fputs( "Date,Time,Open,High,Low,Close,Volume \n", fh );
   y = Year();
   m = Month();
   d = Day();
   r = Hour();
   e = Minute();
   n = Second();

   for( i = 0; i < BarCount; i++ )
   {
      //fputs( Name() + "," , fh );
      ds = StrFormat("%02.0f-%02.0f-%02.0f,",
                     y[ i ], m[ i ], d[ i ] );
      fputs( ds, fh );

      ts = StrFormat("%02.0f:%02.0f:%02.0f,",
                     r[ i ],e[ i ],n[ i ] );
      fputs( ts, fh );

      qs = StrFormat("%.4f,%.4f,%.4f,%.4f,%.0f\n",
                     O[ i ],H[ i ],L[ i ],C[ i ],V[ i ] );
      fputs( qs, fh );
   }

   fclose( fh );
}

Buy = 1;

joshsmi 發表於 15-3-11 22:47

If you wanna convert tickdata to other intervals and wanna keep it in the AmiBroker database then you don't need to export the data. You may use AddToComposite to convert tickdata into other intervals. It is much faster than export of data and re-importing it again.

Secondly you are not limited to 1,5,15,30 intervals. You can customize any other interval. Besides in the toolbar you can insert any interval to be charted.

In backtester you have to go to backtest settings > periodicity. In order to make custom interval being visible there you have to define those custom intervals in Tools - Preferences - Intraday.

Chart time frame and analysis time frame settings are independent from each other!
But both are dependent on File - Database settings - Base time interval!

lwhuang 發表於 15-3-19 19:53

我發現MC有個週期AB辦不到,就是變動數
例如價格變動20次就畫一根k棒

draw a k line when price changed every 20 times

joshsmi 發表於 15-3-20 18:55

lwhuang 發表於 15-3-19 19:53 static/image/common/back.gif
我發現MC有個週期AB辦不到,就是變動數
例如價格變動20次就畫一根k棒



Mate, what are you talking about?
Do you mean 20-Range bars or 20-tick charts or what do you mean?

http://www.amibroker.com/kb/2014/09/19/how-to-display-range-bars/

See Interval Selector combo-box of the tool bar
to get 20 tick range bar you insert 20R or 20r,
to get 20-tick interval you insert 20T or 20t

fix interval settings i.e. for creating tool bar buttons can be set inTools – Preferences - Intraday
http://www.amibroker.com/kb/2014/10/28/how-to-create-toolbar-button-for-custom-interval/


zaqimon 發表於 15-3-20 21:59

除了N-tick, N-Range外還有N-volume chart
不知道這邊有沒有人真的使用這些chart做交易呢?

lwhuang 發表於 15-3-22 08:11

joshsmi 發表於 15-3-20 18:55 static/image/common/back.gif
Mate, what are you talking about?
Do you mean 20-Range bars or 20-tick charts or what do you mean? ...

N-range is the same as N-changed?

joshsmi 發表於 15-3-22 22:06

lwhuang 發表於 15-3-22 08:11 static/image/common/back.gif
N-range is the same as N-changed?

Range bars refer to High-Low range.

So do you mean Open-Close change?

http://i.imgur.com/o3ZuETm.png

lwhuang 發表於 15-3-23 08:19

I mean price change
for example, there are tick such as
10, 11, 10, 10, 10, 9
there are 6 ticks but only 3 price changed, so if I specify 3 changed to form a k bar, this is a k bar, not relevant to range

joshsmi 發表於 15-3-23 20:20

本帖最後由 joshsmi 於 15-3-23 20:21 編輯

lwhuang 發表於 15-3-23 08:19 static/image/common/back.gif
I mean price change
for example, there are tick such as
10, 11, 10, 10, 10, 9

Now I understand what you mean.

BTW, are you the one who posted #2683 in the AmiBroker feedback center?

Quote:
"need a special period
fixed change price to form a k line rather than fixed time
, for example, a k represent every 20 price changed .... "

To be honest that one is not as clear as your description you have posted here in your most recent post.
I think Tomasz & AmiBroker will not understand what you exactly mean too as your description there in the feedback center is a very, very vague one. In programming precise descriptions are needed.

If I were you I would post an additional comment in #2683 of feedback center being similar to the one you posted here.

lwhuang 發表於 15-3-24 11:04

joshsmi 發表於 15-3-23 20:20 static/image/common/back.gif
Now I understand what you mean.

BTW, are you the one who posted #2683 in the AmiBroker feedback ce ...

Ya, that's my post
I add the description here to there
頁: [1]
查看完整版本: AFL掃描AB數據