Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EnterLong() not working

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • monpere
    replied
    Originally posted by NinjaTrader_Josh View Post
    You need to look back to the very first entry. Remember you are literally sending these orders again and again on every single bar. After the first bar you are already long. All subsequent bars' EnterLong() call will be ignored as mentioned in the trace output since you are already long. Since the first call to EnterLong() likely happened on a historical bar that is why you see no historical position. This is all in line with what you have stated earlier. I suggest you open a chart, throw the strategy onto the chart, and scroll all the way back to the beginning of your chart. You should see an execution plotted on the first processed bar.
    Ok, thanks, I see. That actually was not my original problem. I was trying to simplify the code to determine if I was seeing some bug. Thanks

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    You need to look back to the very first entry. Remember you are literally sending these orders again and again on every single bar. After the first bar you are already long. All subsequent bars' EnterLong() call will be ignored as mentioned in the trace output since you are already long. Since the first call to EnterLong() likely happened on a historical bar that is why you see no historical position. This is all in line with what you have stated earlier. I suggest you open a chart, throw the strategy onto the chart, and scroll all the way back to the beginning of your chart. You should see an execution plotted on the first processed bar.

    Leave a comment:


  • monpere
    replied
    Originally posted by NinjaTrader_Josh View Post
    Please use TraceOrders = true as suggested earlier. I assure you the EnterLong() went through if you are able to get ExitLongStop/Limit() orders.
    Ok, I set TraceOrders, and changed the code to this:

    protected override void OnBarUpdate()
    {
    if (FirstTickOfBar) {
    Print ("*** Entering order");
    iorder1 = EnterLong (0, 1000, "TradeEntry");
    Print ("*** Order should now be entered");
    }

    This is what I get in the output window:

    *** Entering order
    08-May-09 2:48:49 PM Entered internal PlaceOrder() method at 08-May-09 2:48:49 PM: Action=Buy OrderType=Market Quantity=1,000 LimitPrice=0 StopPrice=0 SignalName='TradeEntry' FromEntrySignal=''
    08-May-09 2:48:49 PM Ignored PlaceOrder() method at 08-May-09 2:48:49 PM: Action=Buy OrderType=Market Quantity=1,000 LimitPrice=0 StopPrice=0 SignalName='TradeEntry' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
    *** Order should now be entered

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    Please use TraceOrders = true as suggested earlier. I assure you the EnterLong() went through if you are able to get ExitLongStop/Limit() orders.

    Leave a comment:


  • monpere
    replied
    Originally posted by NinjaTrader_Josh View Post
    monpere,

    EnterLong() is not a working order. It is a market order that gets filled immediately. You will not see a market order sitting around because it is already filled. You should look in the Orders tab of the Control Center.

    There is nothing in the Orders tab, no visual indication of a filled order on the chart, no unrealized PnL in the chart trader panel. No errors in the error log. The only error in the error log says "strategy 'SampleMultiInstrument' has called the Add() method with and invalid instrument: ES 12-08'..." I don't even know where that is coming from, I am not running this 'SampleMultiInstrument' strategy, it is a system strategy which I cannot even delete.

    How else can I prove that the EnterLong() is not doing anything?

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    monpere,

    EnterLong() is not a working order. It is a market order that gets filled immediately. You will not see a market order sitting around because it is already filled. You should look in the Orders tab of the Control Center.

    Leave a comment:


  • monpere
    replied
    Originally posted by NinjaTrader_Josh View Post
    monpere,

    It is not possible to submit Exit() if you did not first open a position with an Enter(). If you got your Exits you did successfully fill on your EnterLong().

    I suggest you use TraceOrders = true in Initialize() to track your orders in the Output Window.
    The issue is, I don't get an order at all for the EnterLong(). I am using chart trader, the exit and stop orders appear on the chart, but not the EnterLong() order.

    Ok, here is an even simpler version of the code. All I have is one statement: EnterLong(...) When I run the startegy now, nothing happens period. Nothing shows up on the chart at all. Are you telling me that is normal?

    ====================================
    public class A1Test1 : Strategy
    {
    #region Variables
    private int myInput0 = 1; // Default setting for MyInput0

    IOrder iorder1;

    #endregion

    protected override void Initialize()
    {
    CalculateOnBarClose = false;
    }

    protected override void OnBarUpdate()
    {
    iorder1 = EnterLong (0, 1000, "TradeEntry");
    }
    }
    ====================================

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    monpere,

    It is not possible to submit Exit() if you did not first open a position with an Enter(). If you got your Exits you did successfully fill on your EnterLong().

    I suggest you use TraceOrders = true in Initialize() to track your orders in the Output Window.

    Leave a comment:


  • monpere
    started a topic EnterLong() not working

    EnterLong() not working

    Can someone tell me what is wrong with this very simple startegy? When I run it I get orders for the exit and stop targets, but I never get an entry order from the EnterLong(). What gives?

    ====================================
    public class A1Test1 : Strategy
    {
    #region Variables
    private int myInput0 = 1; // Default setting for MyInput0

    IOrder iorder1;
    IOrder iorder2;
    IOrder iorder3;

    #endregion

    protected override void Initialize()
    {
    CalculateOnBarClose = false;
    }

    protected override void OnBarUpdate()
    {
    iorder1 = EnterLong (0, 1000, "TradeEntry");
    iorder2 = ExitLongLimit (0, true, 1000, Close[0]+(25*TickSize), "ExitTarget", null);
    iorder3 = ExitLongStop (0, true, 1000, Close[0]-(25*TickSize), "ExitStop", null);
    }
    }
    ====================================

Latest Posts

Collapse

Topics Statistics Last Post
Started by CaptainJack, 04-24-2026, 11:07 PM
0 responses
12 views
0 likes
Last Post CaptainJack  
Started by Mindset, 04-21-2026, 06:46 AM
0 responses
118 views
0 likes
Last Post Mindset
by Mindset
 
Started by M4ndoo, 04-20-2026, 05:21 PM
0 responses
170 views
0 likes
Last Post M4ndoo
by M4ndoo
 
Started by M4ndoo, 04-19-2026, 05:54 PM
0 responses
88 views
0 likes
Last Post M4ndoo
by M4ndoo
 
Started by cmoran13, 04-16-2026, 01:02 PM
0 responses
131 views
0 likes
Last Post cmoran13  
Working...
X