Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EnterLong() not working

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

    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);
    }
    }
    ====================================

    #2
    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.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      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");
      }
      }
      ====================================

      Comment


        #4
        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.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          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?

          Comment


            #6
            Please use TraceOrders = true as suggested earlier. I assure you the EnterLong() went through if you are able to get ExitLongStop/Limit() orders.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              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

              Comment


                #8
                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.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  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

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by tsantospinto, 04-12-2024, 07:04 PM
                  5 responses
                  67 views
                  0 likes
                  Last Post tsantospinto  
                  Started by cre8able, Today, 03:20 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post cre8able  
                  Started by Fran888, 02-16-2024, 10:48 AM
                  3 responses
                  48 views
                  0 likes
                  Last Post Sam2515
                  by Sam2515
                   
                  Started by martin70, 03-24-2023, 04:58 AM
                  15 responses
                  115 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Started by The_Sec, Today, 02:29 PM
                  1 response
                  8 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Working...
                  X