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!