![]() |
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
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Senior Member
Join Date: Dec 2009
Posts: 135
Thanks: 2
Thanked 1 time in 1 post
|
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 |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
|
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
}
Austin
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Dec 2009
Posts: 135
Thanks: 2
Thanked 1 time in 1 post
|
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); |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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")
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Dec 2009
Posts: 135
Thanks: 2
Thanked 1 time in 1 post
|
thanks, this helped
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |