Or, to put it another way, what am I doing wrong?
Say I want to buy or short when price moves a given multiple of the ATR away from the moving average. The obvious approach (to someone with my limited skill) is:
K=Const * Ref(ATR(N),-1);
Av=Ref(EMA(C,AvLen),-1);
Buy=H > Av + K;
BuyPrice=Max(O,Av + K);
(Assuming that the Buy order won't necessarily be filled if H merely touches the stop price.)
Doing it this way throws the entry price off, because K will not be an even multiple of TickSize. So:
K=roundTick(K);
using the function someone kindly provided here long ago:
function roundTick(aValue)
{
TickInv=1/TickSize;
return (round(aValue * TickInv) / TickInv);
}
This appears to work just fine in system tests. However, if I want to plot
Ref(EMA(C,N),-1) + K
on a chart, the line appears if it is plotted before using the roundTick function but not after using it. The same is true of the floor and ceil versions used to round down or up. The line plots successfully before rounding but not after.
(No clue why we need to take the inverse of TickSize, by the way. The floor and ceil versions don't bother.)
No doubt this doesn't make much practical difference when eyeballing a chart, but it annoys and baffles me. Can anyone provide an explanation and, ideally, a fix?
In case it matters: I am still using AB 5.20. I keep meaning to upgrade, but the old version has always done what I needed.
Thanks.
Owen
Posted by: owen5819@comcast.net
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (1) |
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
EmoticonEmoticon