Hi, A couple of thoughts for you:
1. Why not use the ApplyStop function native to AmiBroker? e.g. applyStop(stopTypeTrailing, ...); http://www.amibroker.com/guide/afl/afl_view.php?applystop 2. You probably want to check if Low < Ref(stop, -1), not Close, since a drop at any point in the period would trigger your stop even if the period eventually closed higher than the Low. 3. You can disable the validation using SetOption. e.g. SetOption ("PriceBoundChecking", False); http://www.amibroker.com/f?setoption --- In [email protected], "chorlton_c_hardy" <chorlton-c- [EMAIL PROTECTED]> wrote: > > Hi All, > > After re-reading through the AB Manual, I found this comment with > regard to Controlling Trade Price. > > "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)..." > > I think this is what is causing me the problem!!! In my situation, > if the High of the price bar which creates the sell signal is below > the trailing stop line, then the sellprice becomes the high of that > bar instead of the previous bar's of the Trailing Stop value. > > Is there anyway to override this???? > > > --- In [email protected], "chorlton_c_hardy" <chorlton-c- > hardy@> wrote: > > > > Hello All (again....) > > > > I'm struggling to solve a coding problem with regard to exits and > would > > very much welcome some advice. > > > > I'm using a trailing stop and currently wait for price to fall > below it > > to signal the exit to a long position. My code is: > > > > Sell = C < Ref(stop, -1); > > > > At the moment the sell price is defined as the open for the > following > > period. I have not added any additional code for this so assume > this is > > the default setting. > > > > However, what I actually want to do is to use the value of the > trailing > > stop on the period BEFORE the exit was signalled. > > > > As this is a weekly system, my logic behind this is that I will set > the > > exit price based on the trailing stop once a week in advance. As > soon > > as this level is breached my position will be closed at this value > > (give or take some slippage). > > > > I accept that this idea could result in the price dipping below the > > trailing stop value and then rising again causing me to be stopped > out > > of the trade prematurely, but I am willing to accept that risk. > > > > My question is how can I code this? I have tried a few ideas > including > > SellPrice = Ref(stop, -1); but nothing seems to work. > > > > Any ideas??? > > > > Thanks in advance, > > > > Chorlton > > >
