Australian (ASX) Stock Market Forum

Different Amibroker Backtest Price and Scan Price

Joined
5 January 2016
Posts
2
Reactions
0
Hello,

I'm facing some weird issue in Amibroker backtest and need expert advise.


Amibroker Backtest pan.jpg

While backtesting my AFL I'm getting some difference in Trigger (Signal) price in Scan and Backtest.

Scan menu shows (mentioned in above image) closing price of candle while for same signal Backtest menu (mentioned in above image) showing Low price (for both long and short call).

I've also tried to use below code in AFL but still it is showing Low price in backtest.

BuyPrice = ValueWhen(Buy, Close);
ShortPrice = ValueWhen(Short, Close);
CoverPrice = ValueWhen(Cover, Close);
SellPrice = ValueWhen(Sell, Close);

Can you please help me showing Closing price of Trigger candle both places ? I'll appreciate your help here.
 
It shows low because your program told AmiBroker to do so.

Anyway no one is able to see your code so there could be anything going on in there.

Secondly Scan outputs raw signals if nothing is added to prevent it from doing it while default backtest mode is backtestRegular (see other modes at SetBacktestMode function reference in the help).

As for raw signal example ...
For example this small sample code will show all raw Buy and Sell signals in Scan while in default Backtest mode excessive signals are removed.

Code:
period = 20; // number of averaging periods 
m = MA( Close, period ); // simple moving average

Buy = Close > m; // buy when close is ABOVE moving average
Sell = m > Close; // sell when close is BELOW moving average

Short = Cover = 0;

Now for example if you would add ExRem in the scan code then it would remove excessive signals too.

Code:
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );
Short = ExRem( Short, Cover );
Cover = ExRem( Cover, Short );

Again no one can see or reproduce your code (it may have 10 lines or 1000 lines) so anything (right or wrong or things being misunderstood or ... ) can happen in there.

Reduce your code to the core or make some other reproducible code doing the same and post it.

Do you wanna make some PFT/SL target stops??
 
It shows low because your program told AmiBroker to do so.

Anyway no one is able to see your code so there could be anything going on in there.

Secondly Scan outputs raw signals if nothing is added to prevent it from doing it while default backtest mode is backtestRegular (see other modes at SetBacktestMode function reference in the help).

As for raw signal example ...
For example this small sample code will show all raw Buy and Sell signals in Scan while in default Backtest mode excessive signals are removed.

Code:
period = 20; // number of averaging periods 
m = MA( Close, period ); // simple moving average

Buy = Close > m; // buy when close is ABOVE moving average
Sell = m > Close; // sell when close is BELOW moving average

Short = Cover = 0;

Now for example if you would add ExRem in the scan code then it would remove excessive signals too.

Code:
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );
Short = ExRem( Short, Cover );
Cover = ExRem( Cover, Short );

Again no one can see or reproduce your code (it may have 10 lines or 1000 lines) so anything (right or wrong or things being misunderstood or ... ) can happen in there.

Reduce your code to the core or make some other reproducible code doing the same and post it.

Do you wanna make some PFT/SL target stops??


Thanks Trash for looking into my concern.

I had reduced my code and then started review by adding one by one condition and finally I got where I made mistake. I'd made two condition with same name which was causing this issue.

Thanks,
 
Top