View Full Version : Question about SetTrailStop (CalculationMode.Percent, "#")
Edgar V.
05-17-2008, 07:17 AM
How does the SetTrailStop CalculationMode.Percent works? I couldn't find anything specific for Percent in the help Section.
Let say that I have a Trailing stop with a calculation mode of 50%. How does the system know where to place the Trailing stop? Based on what? The opening price of the Bar? The price with which I entered?
Thanks.
NinjaTrader_Ray
05-17-2008, 07:52 AM
Avg entry offset by 50% of that price. Then it will use the high or low of a bar less the original offset amount.
Edgar V.
05-17-2008, 12:13 PM
Would it be correct to say that the original offset amount = original entry price?
NinjaTrader_Josh
05-17-2008, 01:32 PM
Original entry price can be found by Position.AvgPrice the moment you acquire your position. If you don't want to store that value then you can do calculations based on your SetTrailStop but that is just more work in my opinion.
brooksrimes
09-14-2010, 10:14 AM
Well I think I found out why SetTrailStop() with the Percent mode doesn't work with YM. I'm trying to use a 10% trailing stop with YM. Apparently, NT is multiplying YM's entry price (i.e. 10500) by 10% and coming up with 1050 ticks/points and using that as an offset. No offense, but that is not a good way for that to work.
A percent trailing stop should answer the question: "As a trade moves in my favor, what percent of the open profit am I willing to give back?".
Example: I enter on the close of this bar. The next bar moves to a high that is 10 ticks in my favor, but it then retreats 2 ticks to close 8 ticks in my favor. If SetTrailStop() is set to 10%, it should exit on that bar with 9 ticks of profit.
So what is the easiest way to get this to work in the manner described?
Thx.
Avg entry offset by 50% of that price. Then it will use the high or low of a bar less the original offset amount.
NinjaTrader_RyanM
09-14-2010, 10:50 AM
Brooksrimes,
To clarify: There is different behavior here depending on running real time versus using this statement in a backtest.
SetTrailStop when used in real time will trail the last traded price by the specified percentage. If price retreats, it won't lower the value of your order to fit this. It will remain at the highest value prior to retreating.
You can use the print statement below to get a similar value to your trail stop. This will match closely with the price for your stop order unless the market starts moving in the direction of your order.
For Long Positions:
Print (Instrument.MasterInstrument.Round2TickSize (Close[0] * (1 - .trailStopPercentage)));
brooksrimes
09-14-2010, 11:05 AM
Right now I'm backtesting so I need this to work for that.
<SetTrailStop when used in real time will trail the last traded price by the specified percentage.>
I still contend that is not a good way for it to work. It should be a percent of the maximum open profit. The percentage should NOT be multiplied by price. That makes a huge difference if you are dealing with a symbol that trades at $5 vs $500. It also gets into volatility considerations. The trailing percentage should be the percent of the open profit you are willing to give up.
<Print (Instrument.MasterInstrument.Round2TickSize (Close[0] * (1 - .trailStopPercentage)));>
Appreciate the suggestion but it won't work for the reasons above. Plus for longs it would have to use High not Close. And it can't just be on a standalone bar basis. If the last bar was a long up bar that closed at the high and the next bar starts retreating and hits the trailing percentage, then it would need to exit at that price.
Brooksrimes,
To clarify: There is different behavior here depending on running real time versus using this statement in a backtest.
SetTrailStop when used in real time will trail the last traded price by the specified percentage. If price retreats, it won't lower the value of your order to fit this. It will remain at the highest value prior to retreating.
You can use the print statement below to get a similar value to your trail stop. This will match closely with the price for your stop order unless the market starts moving in the direction of your order.
Print (Instrument.MasterInstrument.Round2TickSize (Close[0] * (1 - .trailStopPercentage)));
NinjaTrader_RyanM
09-14-2010, 11:13 AM
Thanks. I've clarified my post to indicate it would only apply to long positions.
Thank you for the suggestions. You may want to consider submitting order methods with ExitLongStop() and ExitShortStop(), and custom program the price level and trailing behavior you're after.