Basics: Scan shows signals, Backtest shows trades, was: How to get correct signals

Scanning Shows 10 trades but back-testing shows only 8.

Also Old Automatic Analysis gives correct number of trades, but the new analysis gives wrong number of trades. Why is it happening @Tomasz

@Manoj.Dalmia You have provided zero information regarding your specific case, so how can you expect precise answer? Besides you should do some research before asking Tomasz about such things. Tomasz has already described almost everything in the documentation.

1 Like

Scan is not backtest.

Scan shows raw signals. Backtest shows actual simulated trades.

Signals are merely points in time when your Buy/Sell/Short/Cover arrays were set to true. There is no processing of any kind in case of raw signals (scan results).

Trades are different. Trades are produced by trading simulation (backtest) and are subject to account limitations, including limited amount of cash in your account. Unless you specify fractional amount of available cash to be used, the backtest would put all cash in a trade, so you won't have money to open another trade. You need to start with reading the manual where it is explained how to control position sizing and how signals are acted upon.

1 Like

So whenever I do a scan based on my afl, it picks up my signals. I cross check these signals with the charts and it's right. However, when I backtest with the same afl for the same time period, the exit prices are considerably higher on the backtest than the scan signals, and I am finding that the exit prices do not correlate with the charts. Is there any reason why this could be happening? Cheers

1 Like

Scan is not backtest. Scan outputs raw signals. backtestRegular which is default backtest mode removes redundant signals.

For example

period = 20; 
m = MA( Close, period );
Buy = Close > m; 
Sell = m > Close; 
Short = Cover = 0;

Also Scan does not include position sizing and all those other existing dozens of backtest settings.

Also check periodicity setting of analysis (last paragraph) being in line with the ones of the other result environments being compared with.

(Related topic regarding changing backtest results in case you might ask yourself some time in the future.)

1 Like

Thanks for your answer, I have a couple of follow up questions.

Firstly, in my code I have specified that I should only have 20 positions open at any time which is good when i backtest, but when I scan sometimes i can get around 40-50 buy signals. Is there a way to limit the number of buy signals in a scan to 20, and if not how would one usually decide which signals to trade?

My second question is similar to the original question. Because I trade on a weekly basis, redundant signals dont seem to be a problem. It's just that in the majority of my trades in the backtests, the exit signals dont make sense, and aren't correlating to the code and hence sell signals from the scan. Are there any specific backtest setting that you know of that would affect this?


All answers to the questions that you asked are in the manual:

esp. how one decides which signals to trade - it is ALL explained in GREAT DETAIL in the manual.

1 Like