Funny! I got the same negative prices error while exploring with a
formula that did not have ATR. Negative prices were limited to 5
securities only and for a few Saturdays & Sundays (!) of February 2003.
I checked my MetaStock detabase, which is the source for my AB database.
It was fine. Went back to AB and tried to find what may have caused the
error. Did not find anything. So deleted the securities and all the
qoutes from AB. Performed a fresh Import from MetaStock. All is fine
now. Strange.
On 8/26/2010 2:37 AM, radmobile_radmobile wrote:
just a follow up so others can know solution to this problem i was having.
support finally got back to me, it turns out that if you use atr
inside of an applystop, you must specify within the relevant
buy/sell/short/cover commands to wait for the length of the specified
atr, so in my case i had to add: barindex()>173 in to my short command
-rm
--- In [email protected] <mailto:amibroker%40yahoogroups.com>,
"radmobile_radmobile" <dan...@...> wrote:
>
> I am running the latest build of AB, and am noticing a strange
problem where AA shows certain exit prices as negative.
>
> Please see this screen shot.
http://easycaptures.com/fs/uploaded/420/4977805058.png
> Clearly there was no negative price for the bar showing.
>
> This appears to have something to do with how I am implementing stops.
> I am using ATR inside my stops code in a short only system based on
daily OHLC data. The system trades on the open and exits same day on
close. When I put a fixed value such as 1.50 the problem does not happen.
>
> SetTradeDelays(0,0,1,0);
> SetOption("ActivateStopsImmediately",1); // used when trading next
day at open and want stops to be hit immediately as in intraday
> SetOption("AllowSameBarExit",1);
> ShortPrice=Open;
> CoverPrice=Close;
> Maxp=3;//3
> SetOption("MaxOpenPositions", Maxp);
>
> Short = rsi(2)>=90;//just for example
> Cover = 1;
>
> //uses ref-1 for stops and score to avoid look-ahead bias
> ApplyStop(0,2,ref(1.09 *ATR(173),-1) ,1); // the culprit, negative
price problem disappears if I replace ATR with a fixed value
>
> PositionScore = Ref(rsi(10),-1) -100 ;
> SetPositionSize(150/Maxp,spsPercentOfEquity);
>
>
>
> For some reason I am getting stopped out on phantom prices... Very
strange. I have double checked my price data through an exploration of
all data(there are no negative prices), re-downloaded everything from
yahoo through amiquote, and switched between several different
databases but the problem persists.
>
> I need some help trouble shooting this.
> Thanks for your time and consideration.
> -rm
>