Hi can anyone please show me to programm a 1000$ Dollar Trail from Close. This calculates a stop point from Highest close in the direction of the trade. And a 1000$ Dollar Trail from High. In this case this calculate a stop point from Highest High reached during the course of the trade.
You would need to convert the $ amount into ticks. For every instrument you know the $ value for a point and you know the tick size.
For example for ES the ticksize is 0.25 and the point value is $ 50. The number of ticks that correspond to $ 1000 are
number of ticks = $ 1000 / (point value * ticksize) = 1000 / (50 * 0.25) = 80
To use this with a trail stop you will first have to calculate the number of ticks that correspond to $ 1000 and then enter that value into SetTrailStop. The first calculation can be done in OnStartUp(), as you will only need to do it once.
This was just to explain the mechanics. If you prefer a simple solution, you can also use
The following 2 users say Thank You to Fat Tails for this post:
Thank you for the explanation. What I want to know it's difference in point of programming between Dollar Trail from Close and Dollar Trail from High. I mean to see the code in both trail stops... so I can see the difference.
According to page 188 of the book The Computer Analysis of The Futures Market a Dollar Trail from Close is calculated from highest close or lowest close in the direction of the trade.
And a Dollar Trail from High is calculated from highest high or lowest low reached during the course of the trade. What I need is the code to see the difference between both stops.
@Kush: Whether you want to calculate a trailing stop from the highest high or the highest close is your personal choice. Both is possible.
The book you are referring to dates back to 1991. Charles LeBeau and David Lucas traded futures on daily data, so they used the daily close (probably the settlement price) to trail the stops. If you look at more recent publications by Charles LeBeau, you will realize that he meanwhile trails his stops from the highest high for long and lowest low for short positions. This is what he calls the "Chandelier" exit, as he uses the high points of the candles of the chandelier.
If you run a strategy on NinjaTrader, you will probably run in safe mode, that is set to "CalculateOnBarClose = true". In that case NinjaTrader should adjust the stop price to the close and not to the high or low of the bar. In that case SetTrailStop() cannot be used to build a chandelier exit, as it does not take into account the high or low, when the strategy is set to "CalculateOnBarClose = true".
Actually I never use SetTrailStop(). Instead I use SetStopLoss() and calculate the stop price myself, either from the high, low or from the close. I don't leave that to NinjaTrader.
The following 3 users say Thank You to Fat Tails for this post: