Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Orders Cancelling
Collapse
X
-
Orders Cancelling
I have a simple stategy that waits for the price to fall below a certain figure before then entering a buy stop order at a higher level. If I apply this to a 1 minute chart, if the order is not filled in the same bar that the order was placed then it appears that the order is cancelled (at least in simulation mode this is the case). Is there a way I can stop the order from being cancelled?Tags: None
-
Back to bukkan's very helpful post if the order does not cancel what is to stop another order from being placed at each subsequent bar? The strategy specifies one entry only but will that be one per bar or one in total if I am specifying 1 minute bars for example?Originally posted by bukkan View Postuse the overload
set liveUntilCancelled to true.Code:EnterLongLimit(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double limitPrice, string signalName)
Comment
-
Shanghai,
just create the strategy with the wizard and when you are done unlock the same and just replace the EnterLongLimit and EnterShortLimit with the overload as i mentioned.
the -ive is that you wont be able to edit the strategy later but you could always create a new strategy (with similar conditions) anytime later.
Comment
-
Shanghai, can you please attach the script so we can have a look why it would not compile for you? Also: ensure the error are not found in another script - as NT compiles all scripts into one DLL for runtime use all scripts currently installed have to 'error free' and in so called compilable state.
Thanks,
Comment
-
Bertrand, the code as it standsbefore I make bukkan's replacement is shown below. From his instructions it seems that I should simply replace the entire highlighted blue text with his overload. He included a long limit order rather than a long stop but that is simple to change.
Apologies for the dumb nature of my posts. I thought this would be an easy strategy to produce and I have never even had to unlock the NinjaTrader code until this week.
Code:// This namespace holds all strategies and is required. Do not change it. namespace NinjaTrader.Strategy { /// <summary> /// Daily trend trading trigger /// </summary> [Description("Daily trend trading trigger")] public class Trigger : Strategy { #region Variables // Wizard generated variables private double trigger = 1; // Default setting for Trigger private double entry = 1; // Default setting for Entry private int shares = 1; // Default setting for Shares private double scratch = 1; // Default setting for Scratch // User defined variables (add any user defined variables below) #endregion /// <summary> /// This method is used to configure the strategy and is called once before any strategy method is called. /// </summary> protected override void Initialize() { CalculateOnBarClose = false; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Condition set 1 if (GetCurrentBid() <= Trigger && ToTime(DateTime.Now) >= ToTime(13, 45, 0)) { [COLOR=blue]EnterLongStop(Shares, Entry, "");[/COLOR] } // Condition set 2 if (GetCurrentBid() <= Scratch) { ExitLong("", ""); } // Condition set 3 if (GetCurrentBid() < Entry && ToTime(DateTime.Now) > ToTime(20, 55, 0)) { ExitLong("", ""); } } #region Properties [Description("Level at which entry order will trigger")] [GridCategory("Parameters")] public double Trigger { get { return trigger; } set { trigger = Math.Max(1, value); } } [Description("Level at which trade should be entered")] [GridCategory("Parameters")] public double Entry { get { return entry; } set { entry = Math.Max(1, value); } } [Description("Number of shares")] [GridCategory("Parameters")] public int Shares { get { return shares; } set { shares = Math.Max(1, value); } } [Description("Intraday scratch level ")] [GridCategory("Parameters")] public double Scratch { get { return scratch; } set { scratch = Math.Max(1, value); } } #endregion } }
Comment
-
Shanghai, try replacing the blue snippet with this below -
EnterLongStop(0, true, Shares, Entry, "");
The overload bukkan posted was the one to use correct, as it would offer setting the liveUntilCancelled bool so the expiring order does not have to be resubmitted on each bar, however the parameters it has still all need to be filled in accordingly like in my snippet above.
Thanks,
Comment
-
Backtest Strategy on a continious futures contract
Hello,
I want to backtest a strategy on the Crude Oil futures continious contract
from Jan 17 2011 to Apr 17 2011.
How do I do that?
Thx
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
77 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
45 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
27 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
32 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
62 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment