NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 11-06-2010, 06:10 AM   #1
Beauregard
Senior Member
 
Join Date: Dec 2009
Posts: 135
Thanks: 2
Thanked 1 time in 1 post
Default Current value of a trailing stop

Hello

I made now several searches in the forum, but could not find an answer to my question.
I would like to know in my strategy at each BarUpdate() what is the current value of the trailingstop. How can I retrieve that value?

Thanks
Andre
Beauregard is offline  
Reply With Quote
Old 11-06-2010, 11:49 AM   #2
NinjaTrader_Austin
NinjaTrader Customer Service
 
NinjaTrader_Austin's Avatar
 
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
Default

Andre, how are you setting the trailing stop? With the SetTrailStop() method? If so, you'll have to monitor OnOrderUpdate() for changes to the trailing stop order in a variable and then check that variable every OnBarUpdate(). If you are using IOrders, then you can just check the stop price of the order directly, like this:
Code:
// in variables
private IOrder myOrder = null;

protected override void OnBarUpdate()
{
    myOrder = ExitLongStop(1300);
    Print("my order stop price: " + myOrder.StopPrice); // will print 1300
}
NinjaTrader_Austin is offline  
Reply With Quote
Old 11-18-2010, 09:31 AM   #3
Beauregard
Senior Member
 
Join Date: Dec 2009
Posts: 135
Thanks: 2
Thanked 1 time in 1 post
Default

I set the trailingstop with SetTrailStop(). Could you please be more specific and make an example how I can check the value?
I have in my code:
CurrentOrder=EnterLong(1,EnterOrderName);
SetTrailStop(EnterOrderName, CalculationMode.Percent ,.05, false);
Beauregard is offline  
Reply With Quote
Old 11-18-2010, 09:41 AM   #4
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hello Beauregard,

You can follow the techniques in this sample for tracking prices of orders submitted with Set statements.

Monitoring Stop-Loss and Profit Target Orders

The sample is pretty close to what you're looking for, except the name of trail stop orders is different than stop loss.

For checking trail stop orders:
if (order.Name == "Trail stop")
NinjaTrader_RyanM is offline  
Reply With Quote
Old 11-18-2010, 12:05 PM   #5
Beauregard
Senior Member
 
Join Date: Dec 2009
Posts: 135
Thanks: 2
Thanked 1 time in 1 post
Default

thanks, this helped
Beauregard is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trailing Profits - How to Reverse a Trailing Stop? jeremymgp Strategy Development 1 05-05-2009 10:47 AM
Trailing Stop with a fixed 20 tick stop Godzilla Strategy Development 3 03-18-2009 07:07 AM
trailing stop with single stop order mario73 ATM Strategies (Discretionary Trading) 3 01-14-2009 02:55 AM
stop loss, trailing stop modification in NT6 alfie Strategy Development 1 03-26-2008 03:46 PM
NT 6.5 - Trailing stop not trailing PocoDiablo Miscellaneous Support 3 03-19-2008 01:46 PM


All times are GMT -6. The time now is 06:30 AM.