protected override void OnBarUpdate()
{
if (CurrentBar < Lookback)
return;
EnterLongStop(DefaultQuantity, MAX(High, Lookback)[1] + 1 * TickSize, "Long Break");
EnterShortStop(DefaultQuantity, MIN(Lookback)[1] + -1 * TickSize, "Short Breakout");
}
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Simple Breakout, No entries
Collapse
X
-
Simple Breakout, No entries
Not getting any entries with this. Log not giving any clues. Need a little code help.
Code:Tags: None
-
Kentoes, please set TraceOrders = true in the Initialize() section of your strategy in order to gain a better understanding of why orders could've been rejected. Then open up the Output Window (from the Tools menu) to see all the order information.
Just a quick guess from looking at your code, but the default behavior of NinjaTrader/NinjaScript is to prevent two opposing orders from working at the same time. It is a part of the Internal Order Handling Rules. Basically, if you have an open buy order and try to submit a sell order while the buy order is still active, it will be ignored.AustinNinjaTrader Customer Service
-
That would indicate that the entry conditions are not being met. You can add Print() statements (that print out information to the same Output Window) throughout your code in order to see exactly what is going on, like this:
Code:protected override void OnBarUpdate() { Print("on bar update for bar number:" + CurrentBar); if (CurrentBar < Lookback) { Print("currentbar is less than lookback, return"); return; } Print("submitting long stop order"); EnterLongStop(DefaultQuantity, MAX(High, Lookback)[1] + 1 * TickSize, "Long Break"); Print("submitting short stop order"); EnterShortStop(DefaultQuantity, MIN(Lookback)[1] + -1 * TickSize, "Short Breakout"); }AustinNinjaTrader Customer Service
Comment
-
Still nothing. I do getin the log window.Failed to call method 'Initialize' for strategy Breakout2:Position property cannot be accessed within 'Initalize method
Code:protected override void Initialize() { SetProfitTarget("", CalculationMode.Ticks, 3); SetProfitTarget("", CalculationMode.Ticks, 5); SetStopLoss("", CalculationMode.Ticks, 4, false); SetStopLoss("", CalculationMode.Ticks, 5, false); TraceOrders = true; CalculateOnBarClose = true; }
Comment
-
Code:#region Using declarations using System; using System.ComponentModel; using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.Xml.Serialization; using NinjaTrader.Cbi; using NinjaTrader.Data; using NinjaTrader.Indicator; using NinjaTrader.Gui.Chart; using NinjaTrader.Strategy; #endregion // This namespace holds all strategies and is required. Do not change it. namespace NinjaTrader.Strategy { /// <summary> /// Enter the description of your strategy here /// </summary> [Description("Enter the description of your strategy here")] public class Breakout2 : Strategy { #region Variables // Wizard generated variables private int lookback = 10; // Default setting for Lookback // 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() { SetProfitTarget("", CalculationMode.Ticks, 3); SetProfitTarget("", CalculationMode.Ticks, 5); SetStopLoss("", CalculationMode.Ticks, 4, false); SetStopLoss("", CalculationMode.Ticks, 5, false); TraceOrders = true; CalculateOnBarClose = true; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { Print("on bar update for bar number:" + CurrentBar); if (CurrentBar < Lookback) { Print("currentbar is less than lookback, return"); return; } Print("submitting long stop order"); EnterLongStop(DefaultQuantity, MAX(High, Lookback)[1] + 1 * TickSize, "Long Break"); Print("submitting short stop order"); EnterShortStop(DefaultQuantity, MIN(Lookback)[1] + -1 * TickSize, "Short Breakout"); if (CurrentBar < Lookback) return; EnterLongStop(DefaultQuantity, MAX(High, Lookback)[1] + 1 * TickSize, "Long Break"); EnterShortStop(DefaultQuantity, MIN(Lookback)[1] + -1 * TickSize, "Short Breakout"); } #region Properties [Description("")] [Category("Parameters")] public int Lookback { get { return lookback; } set { lookback = Math.Max(1, value); } } #endregion } }
Comment
-
Kentoes, are you recompiling the script after you make changes? You can hit the F5 key, or right-click in the editor window and then select Compile.
I ran your script and got the expected output, including the part where the order was rejected due to the Internal Order Handling Rules. Here is the output with the order tracing and the Print() statements. There were thousands of lines of output, I've only copied the first few here.
Code:on bar update for bar number:20 submitting long stop order 6/14/2010 7:51:00 AM Entered internal PlaceOrder() method at 6/14/2010 7:51:00 AM: Action=Buy OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1094.75 SignalName='Long Break' FromEntrySignal='' submitting short stop order 6/14/2010 7:51:00 AM Entered internal PlaceOrder() method at 6/14/2010 7:51:00 AM: Action=SellShort OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1092.50 SignalName='Short Breakout' FromEntrySignal='' 6/14/2010 7:51:00 AM Ignored PlaceOrder() method at 6/14/2010 7:51:00 AM: Action=SellShort OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1092.50 SignalName=Short Breakout' FromEntrySignal='' Reason='An Enter() method to submit an entry order has been ignore. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.' **NT** An Enter() method to submit an entry order at '6/14/2010 7:51:00 AM' has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.
AustinNinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
633 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
364 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
105 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
567 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
568 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment