![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Nov 2009
Posts: 205
Thanks: 0
Thanked 0 times in 0 posts
|
I have an initial StopLoss
protected override void Initialize() { CalculateOnBarClose = true; Add(PeriodType.Minute, 5); SetStopLoss(450); MP = new DataSeries(this); TT = new DataSeries(this); PosLow = new DataSeries(this); } and I have a trailing stop (highlighted in orange) but the Trailing Stop does not work? Cant figure out why? // /////////////////////// // Trailing Stop Long // /////////////////////// if (Position.MarketPosition == MarketPosition.Long) { MyATRCalc = ATR(14)[0]*atr5min_trail_mult_long; if ((TT[0] != TT[1]) || (MP[1] != 1)) { PosLow[0] = Low[0] - MyATRCalc; } PosLow[0] = Math.Max(PosLow[1], (Low[0]-MyATRCalc)); DrawDot("TStop_Long"+ CurrentBar, true, 0, PosLow[0], Color.Orange); } ExitLongStop(PosLow[0]); |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Nov 2009
Posts: 205
Thanks: 0
Thanked 0 times in 0 posts
|
Seems to be getting stopped out by the StopLoss and not by the Trailing Stop (orange dots)?
|
|
|
|
|
|
#3 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
|
mefTrader, please work with TraceOrders = true in your Initialize() to debug your order behavior, likely you're running into the Internal Order Handling Rules here -
http://www.ninjatrader-support.com/H...verview36.html (botton section). http://www.ninjatrader.com/support/f...ead.php?t=3627
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Nov 2009
Posts: 205
Thanks: 0
Thanked 0 times in 0 posts
|
Methods that generate orders to exit a position will be ignored if a strategy position is open and:
I am trying to use an ExitLong in parallel with a StopLoss... I am bring ing code over from Tradestation where this worked and I dont understand why these could not co-exist? The stop that is closer to the price action should be active - strategy calculations should know this ahead if there is a clear distinction?? Whats the workaround here? |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Nov 2009
Posts: 205
Thanks: 0
Thanked 0 times in 0 posts
|
How can I integrate a Currency StopLoss and a Price Stop into StopLoss() ? Any examples out there?
|
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
|
mefTrader, the order handling rules are there to protect you and your strategy of unwanted positions / inflight executions - thus if the SetStopLoss is active other Exit's will be ignored.
You could work here by adjusting the price level of your stop order as needed. Unfortunately you can't have a currency and price based stop running on the same position with SetStopLoss(). With NinjaTrader 7 we also offer a new unmanaged order submission mode, which gives you the freedom to manage / code all on your own and 'neutralizing' the order entry rules discussed.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Nov 2009
Posts: 205
Thanks: 0
Thanked 0 times in 0 posts
|
ok how do I get more information about "a new unmanaged order submission mode, which gives you the freedom to manage / code all on your own and 'neutralizing' the order entry rules discussed." ?
|
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Nov 2009
Posts: 205
Thanks: 0
Thanked 0 times in 0 posts
|
ok read http://www.ninjatrader.com/support/h...d_approach.htm
Sounds like using a sledgehammer to something that should be available a SetStopLoss() to work in parallel to TrailingStop() . Since NT7 ins still in beta could this be addressed? (wrt to below)?? The SetStopLoss() method can NOT be used concurrently with the SetTrailStop() method for the same position, if both methods are called for the same position (fromEntrySignal) the SetStopLoss() will always take precedence. You can however, use both methods in the same strategy if they reference different signal names. |
|
|
|
|
|
#9 |
|
Senior Member
Join Date: Nov 2009
Posts: 205
Thanks: 0
Thanked 0 times in 0 posts
|
Ok this works folks for future reference
// /////////////////////// // Trailing Stop Long // /////////////////////// if (Position.MarketPosition == MarketPosition.Flat) { SetStopLoss(450); } if (Position.MarketPosition == MarketPosition.Long) { MyATRCalc = ATR(14)[0]*atr5min_trail_mult_long; if ((TT[0] != TT[1]) || (MP[1] != 1)) { PosLow[0] = Low[0] - MyATRCalc; } PosLow[0] = Math.Max(PosLow[1], (Low[0]-MyATRCalc)); DrawDot("TStop_Long"+ CurrentBar, true, 0, PosLow[0], Color.Orange); if ((Position.AvgPrice - PosLow[0]) * 10 < 450) { SetStopLoss(CalculationMode.Price, PosLow[0]); } } |
|
|
|
|
|
#10 |
|
Senior Member
Join Date: Nov 2009
Posts: 205
Thanks: 0
Thanked 0 times in 0 posts
|
*10 multiplier is because I am tradin the Russell (@TF)
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ExitLongStop | madhav_ab | Strategy Development | 1 | 05-22-2010 05:25 AM |
| ExitLongStop and ExitShortStop not working properly | suresh | Strategy Development | 2 | 05-14-2010 11:09 PM |
| Confusion about ExitLongStop() | AnotherTrader | Automated Trading | 6 | 04-27-2010 10:19 AM |
| ExitLongStop() getting cancelled | cheeky123 | Strategy Development | 5 | 09-18-2009 04:26 AM |
| ExitLongStop not executed! | sammano | Strategy Development | 5 | 11-23-2008 01:08 PM |