Meaning of "true" in nbar stop

in one of my old formulas i found these lines:

bars = IIf( Close < Ref( Close, -15), 15, 100000);
ApplyStop(stopTypeNBar, stopModeBars, bars, 0, True);

if i remember correctly, my intention was that amibroker will check if current close is lower than close of 15 bars ago, and if so will exit 15 bars after "buy" signal.
my question concerns the "true" in the "applystop" command: i understand, if i am correct, that the "true" means the Amibroker exit according to some measure of volatility of the stock. If so - is there any meaning left to the "nbar" exit? do the 15 bars i chose differ than any other number, if "true" is chosen? and another question: when i put the stop order as written above, i get sell "n bar" orders. but if i choose "false", under the same two propositions, no exit is taken with the nbar stop. i can see on the chart numerous cases where a bought security's close is lower than the 15 periods close, and no stop order is being activated. what is wrong?
btw: the results of the above system are good. i just refuse to use a system i can't fully understand.
thanks a lot in advance.

It has no meaning for n-bar stop.

1 Like

can you explain, then, how i get many "Nbar exits" under my formula when i include "true" in it, and none when i put "false" instead of "true"?

the formula is:
bars = IIf( Close < Ref( Close, -15), 15, 100000);
ApplyStop(stopTypeNBar, stopModeBars, bars, 2, True);

WriteIf( Sell == 1, "Regular exit",
WriteIf( Sell == 5, "N Bar stop", "" ) );

and in the backtest results i get many lines like the following, labeled "Long (n-bar)":

Symbol Trade Date Price Ex. date Ex. Price % chg Profit % Profit Shares Position value Cum. Profit # bars Profit/bar MAE MFE Scale In/O

HSP Long (n-bar) 08-01-2010 51.47 04-06-2010 51.45 -0.04% -8.88 -0.09% 194 9985.18 -7044.48 104 -0.09 -7.75% 12.94% 0/0

again, when "false" or nothing is put instead of "true" i get only ordinary exits, without "n bar" .

thanks again.

Your code is incorrect. ExitAtStop is 4th parameter, not 5th.

My reply was about ExitAtStop parameter, not about volatile.

There is huge difference between two, even though both can be "true" or "false", hence your original query was unclear. Please read the manual about ApplyStop
that describes what "volatile" does:

BTW: WriteIf returns single string (selected value), not what you assumed it does.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.