Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
StopMarket cancelled by stoploss before entry
Collapse
X
-
StopMarket cancelled by stoploss before entry
Hi I am trying to make a strategy where when it reaches a certain price, it would enter a trade. So in my approach, I am using a stop market for entering trades based on the specific price. But when I'm backtesting, I realized that my entry are stopped out by the stop loss before even entering. In my case, I only want stop loss to work after the trade is entered, not when a stopmarket order is submitted. Check the picture that I have attached for references. ThanksTags: None
-
Hello horace chow,
Thanks for posting.
To assist we will need more information about your strategy.
Please post the entry order code you are using as well as the stoploss coding you are using.
If you are using the Strategy Builder, please post the screenshots of the sets with the entry order and the stop and profit window (if you are using those methods).
-
Ignore the print statements, they are for debugging
SetProfitTarget(CalculationMode.Price, Instrument.MasterInstrument.RoundToTickSize(EntryL ine-1.5*(ShortLimitLine-EntryLine)));
SetStopLoss(CalculationMode.Price, ShortLimitLine);
EnterShortStopMarket((int)Math.Round(quantity),Ent ryLine, "Short Entry");
In this section of code, first I set the profit target, then I set the stop loss. lastly, I submitted a shortstopmarket order. However, before the order is entered(submitted an order but hasn't entered the trade), assuming the price continues to approach and touched my stop loss, the shortstopmarket order will be canceled. I was wondering would there be any better way to approach it. Would it be possible for me to remove my stoploss and set it within OnOrderUpdate() when it's entered into the trade?
Comment
-
the code that I have provided is for entering short, in the example I provided is entering long, it has almost the same layout.
Comment
-
From the example in first comment, I have printed the profit target, entry price, and stop loss
Quantity = 5.45454545454545 = 1500 / -5.5*50
Profit target = 3093.75
Entry price = 3085.5
Stop loss = 3080
Comment
-
I have watched the playback very slowly, it seems like after the order has been submitted with EnterShortStopMarket(), once the next bar has been formed, the order was canceled. By any chance this is an error?
Comment
-
Hello horace chow,
Thanks for your reply.
When you run your strategy, do you see any related error messages in the "log" tab of the control center?
Limit type entry orders will be automatically canceled if not filled in the bar they are submitted. Please see the "managed approach" information here: https://ninjatrader.com/support/help...d_approach.htm
To keep the order in play, you would need to resubmit the order on each new bar or use the bool IsLiveUntilCanceled in the entry order method.
Reference: https://ninjatrader.com/support/help...stopmarket.htm
This is the overload: EnterShortStopMarket(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double stopPrice, string signalName)
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Today, 05:17 AM
|
0 responses
52 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
130 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
70 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
44 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
49 views
0 likes
|
Last Post
|

Comment