TickSize for BuyPrice and SellPrice instead of ApplyStop

I am backtesting a custom ticker which has a Tick Size of 0.5. The prices that I have imported look like 10.0, 10.5, 11.0, 11.5 and so on. However, my indicator gives calculates values sometimes that gives values up to 2 decimal places like 9.72, 10.78, 11.31 and so on.

Currently to simulate the BuySize and SellPrice correctly, I am doing it manually in my backtest by rounding up or rounding down using a modified version of a function provided by @fxshrat on this forum, which looks like follows:

function RoundUpToTick(price, tick) {
    result = ceil(price / tick) * tick;
    return result;
}

function RoundDownToTick(price, tick) {
    result = floor(price / tick) * tick;
    return result;
}

BuyPrice = RoundUpToTick(shortStop);
SellPrice = RoundDownToTick(longStop);

However, I am wondering why Amibroker's in-built Tick Size functionality only works for ApplyStop (as stated here) and not for BuyPrice and SellPrice as well. Or maybe it does work like that and I am just missing it? Wanted to post here in case there was a simpler way to do it that I have not discovered.

Thanks for the help!

It is obvious - for regular exits YOU control the exit price (via SellPrice/CoverPrice).
This is most flexible and least surprising. Not rounding to TickSize automatically allows to simulate things like slippage, noise, etc.

For ApplyStop exits you don't control the price (if "extatstop" is turned ON) that's why it needs to be rounded to TickSize automatically.

1 Like

Ah okay interesting, thanks for clarifying the design and confirming that I am doing it the right way. To me intuitively, if you are providing an option to use TickSize with ApplyStop, it wouldn't harm to provide the same option to allow to use it with BuyPrice and SellPrice as well. However, I am sure you have your reasons for making these design choices! :slight_smile:

As I wrote, you have to have the way to test ROBUSTNESS of the system. One of the methods it adding noise to prices.

1 Like