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
-
Originally posted by bukkan View Postuse the overload
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,BertrandNinjaTrader Customer Service
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,BertrandNinjaTrader Customer Service
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 mjairg, 07-20-2023, 11:57 PM
|
3 responses
213 views
1 like
|
Last Post
by PaulMohn
Today, 04:22 AM
|
||
Started by TheWhiteDragon, 01-21-2019, 12:44 PM
|
4 responses
544 views
0 likes
|
Last Post
by PaulMohn
Today, 04:09 AM
|
||
Started by GLFX005, Today, 03:23 AM
|
0 responses
3 views
0 likes
|
Last Post
by GLFX005
Today, 03:23 AM
|
||
Started by XXtrader, Yesterday, 11:30 PM
|
2 responses
12 views
0 likes
|
Last Post
by XXtrader
Today, 03:07 AM
|
||
Started by Waxavi, Today, 02:10 AM
|
0 responses
7 views
0 likes
|
Last Post
by Waxavi
Today, 02:10 AM
|
Comment