Overriding Amibroker Backtester Settings - Generating Unrealistic Results

I'm trying to estimate the low on a stock that I want to go long on...

I am manipulating the BuyPrice in the following manner:

BuyPrice = max( BuyStop, EstimatedLow ); // make sure buy price not less than Low 

The problem is that if I "undershoot" the "Estimated Low" (i.e., make it too small) than AmiBroker overrides that value and inserts the "Low" for that bar thereby giving my backtest way overoptimistic (and unrealistic) results.

Is there a way to override that backtester setting? Here is documentation from AmiBroker...

From AmiBroker...https://www.amibroker.com/guide/h_backtest.html

"Please note that AmiBroker presets buyprice, sellprice, shortprice and coverprice array variables with the values defined in system test settings window (shown below), so you can but don't need to define them in your formula. If you don't define them AmiBroker works as in the old versions.

During back-testing AmiBroker will check if the values you assigned to buyprice, sellprice, shortprice, coverprice fit into high-low range of given bar. If not, AmiBroker will adjust it to high price (if price array value is higher than high) or to the low price (if price array value is lower than low)"

See numerous SetOption fields.
In your case to disable H-L price bound checking use following option.

SetOption( "PriceBoundChecking", False );
3 Likes

Thanks for your help...I'm moving in the right direction...Now I'm trying to set the BuyPrice and still sometimes the BuyPrice is less than the low...Frustrating...

Any ideas? Thanks in advance...

Buy =    
   
   Ref(C, -1) >= 2.0;

  
for ( i = 0; i < BarCount -1; i++ ) {
 
   BuyPrice[ i ] = EstimateLow[ i ];
    
	if ( BuyPrice[ i ] >= Low[ i ] ) {
		Buy[ i ] = 1;
    }
	else {
		Buy[ i ] = 0;
	}
 
}

I don't know what your BuyStop and ExitmatedLow variables consist of.

In my first response I just responded to this one:

So there you seemed to have been looking for an option for exceeding H-L price range which can be activated by

SetOption( "PriceBoundChecking", False );

As mentioned in my first response.


But now I think you seem to be looking for something similar to this one below (Buy stop order which is the opposite of this limit order example given here).

/// based on limit order example of
/// @link http://www.amibroker.com/kb/2014/11/26/handling-limit-orders-in-the-backtester/
/// responded to in this thread
/// @link https://forum.amibroker.com/t/overriding-amibroker-backtester-settings-generating-unrealistic-results/7374/4
BuySignal = Ref(C, -1) >= 2.0;

// buy on the next bar
Buy = Ref( BuySignal, -1);
BuyStopPrice = Ref( Close, -1) * 1.01;

// now we check if buystop was hit
Buy = Buy AND H > BuyStopPrice;

// if Open price is above the buystop, then we use Open for entry
BuyPrice = Max( Open, BuyStopPrice );

Just a guess of what you seem to be looking for...

Or maybe you are actually looking for Buy limit order than again look here.

3 Likes

Thank you for your answer. I had not set setting in my code and i sent almost 10 hours to find this solution. Really this is ridiculous. This type of setting a newbee like me will never know if not putting enough effort. Thanks again.

@golu_vora

Only users with License verified badge are allowed to post on this forum.