Is my ATR stop being calculated wrong, or plotted wrong?

I was unable to fully grasp this by reading the AFL documentation.

Here's what I have.

Equity( 1, 0 );
InTrade = Flip( Buy, Sell );
SetOption( "EveryBarNullCheck", True );
AtrLength = ATR( 14 ) * 1;
AtrStopSize = H - AtrLength;
AtrStopInTrade = IIf( InTrade, HighestSince( Buy, AtrStopSize ), Null );
Plot( AtrStopInTrade, "AtrStopInTrade", colorRed, styleDots );

I was watching this tutorial where the stop has been setup like this...

ApplyStop( stopTypeTrailing, stopModePoint, AtrLength, 2 );

... which I took to mean that the ApplyStop function calculates the AtrStopSize itself, which would mean that the following...

ApplyStop( stopTypeTrailing, stopModePoint, AtrStopSize, 2 );

... is the wrong way to do it.

Basically: I want to be 100% sure that the Plot on my chart actually reflects the stops executed in the backtester through ApplyStop.

PS! I apologize if there is an answer somewhere, but I could not find it searching here, or on Google.

You need to read the official tutorial, not some videos on the net

http://www.amibroker.com/guide/h_backtest.html

As explained in the manual by default ApplyStops "samples and holds" the amount of stop at the entry bar. Quote from manual:

Please note that 3rd parameter of ApplyStop function (the amount) is sampled at the trade entry and held troughout the trade. So in the example above it uses ATR(10) value from the date of the entry. Further changes of ATR do not affect the stop level.

Your code is doing something else. For Chandeliers stop (where amount changes bar by bar) you need to use "volatile" option as explained in the manual AFL Function Reference - APPLYSTOP

For proper plotting code see:

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