How to export signals (scan results) using AFL?

Hi,

I am able to export signals to csv by (ab)using custom backtester (see here How to convert boolean to string (in order to export it to csv)?). But the export only has signals that resulted in trades.

I am looking at result of Scan and would like to export this to csv. I know how to do this using Amibroker GUI. I would like to do this in some automated way not involving clicking in Amibroker user interface. Is there a way how to (create and) export Scan results (signals) to csv using AFL?

Thanks.

Here are the differences between the two exports:

  1. Export from Scan result window has all the signals:
Symbol,Trade,Date,Close
TLT,Buy,30/07/2002,  81.5200
TLT,Sell,31/07/2002,  82.5300
TLT,Sell,01/08/2002,  83.0000
TLT,Sell,02/08/2002,  83.8500
TLT,Sell,05/08/2002,  84.2200
TLT,Sell,09/08/2002,  84.8800
TLT,Sell,12/08/2002,  85.4000
TLT,Sell,13/08/2002,  86.4500
TLT,Sell,14/08/2002,  86.7800
TLT,Sell,20/08/2002,  86.2700
TLT,Buy,22/08/2002,  85.0600
TLT,Sell,23/08/2002,  85.9000
TLT,Sell,26/08/2002,  85.9800
TLT,Buy,28/08/2002,  85.8700
...
  1. Export generated from (ab)using custom backtester (How to convert boolean to string (in order to export it to csv)?) has much les signals:
DateTime,Symbol,Price,IsEntry,IsExit,IsLong,IsScale,Reason,Type
30/07/2002,TLT,81.52000,-1,0,-1,0,0,1
31/07/2002,TLT,82.53000,0,-1,-1,0,1,2
22/08/2002,TLT,85.06000,-1,0,-1,0,0,1
23/08/2002,TLT,85.90000,0,-1,-1,0,1,2
28/08/2002,TLT,85.87000,-1,0,-1,0,0,1
...

@kktrader since you already ab(used) the CBT, maybe you can see what happens using different backtester working modes (especially the ones discouraged here).
Just a random idea...not tested nor recommended!

@beppe Thanks. Makes sense. Will test. I guess there is no other programmatic/"AFL" way to export signals than using CBT like I have tried (just adding SetBacktestMode(mode=backtestRegularRaw))?

First please read the manual. It is really ALL COVERED in the manual.
https://www.amibroker.com/guide/h_portfolio.html

There is a picture in that page that shows how Buy-Sell signals are matched against each other, so backtester won't see excess duplicates.

Scan on the other hand shows RAW UNFILTERED signals, you can export them easily using File->Export. Again covered in the manual:

https://www.amibroker.com/guide/h_newanalysis.html

You can also export them programmatically by simply adding fopen/fputs/fclose to formula
(outside CBT) inside the loop that goes thru bars.

Backtest would see less BUY signals because obviously there is no need to keep all signals when you are limited to MaxOpenPositions. So backtester only ranks TOP-N signals to conserve memory. And in CBT you would only see TOP-N ranked signals. You guys have no idea what kind of systems people run with AmiBroker and really it needs to be able to keep track of billions of signals.

I STRONGLY ADVISE TO READ THE MANUAL

I spent years writing over 1000+ of pages worth of documentation for a reason - so people READ it, so I don't need to repeat basics over and over to each and every one. Over last 20+ years each and every day I have to repeat the same information that is present in the manual over and over because people don't check the manual and after doing for such a long time, I am tired now.

Tutorial is absolute MUST-READ

Also, if you have such basic support question please write to support. Support has AI that would answer such basics automatically.

6 Likes

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.