Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ExitLong not fired

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

    ExitLong not fired

    Hi all, I'm a newbie of the ninja trader and this is my first post.
    I'm trying to create a simple strategies in order to open and close a long position in the same day.
    I wrote the following code in the OnBarUpdate method

    if(Position.MarketPosition == MarketPosition.Flat)
    {
    Print(String.Format(
    "- Today is {0}, We buy at {1}, the low of the day is {2}",Time[0], actualSupportL1, Low[0]));
    entryOrder = EnterLongStop(actualSupportL1,orderName);

    }
    //after that entryOrder is NOT null and I can see the record
    //in the Executions tab of the Strategy Analizer


    if(entryOrder != null)
    {
    string fromEntrySignal = entryOrder.FromEntrySignal;
    Print(String.Format(
    "- Today is {0}, We sell at {1}, the high of the day is {2}, the close of the day is {3}",Time[0],actualOpen,High[0],Close[0]));
    entryOrder = ExitLong(orderName,fromEntrySignal);
    }

    //after that entryOrder is null and I can NOT see any record
    //in the Executions tab of the Strategy Analizer


    Where I'm wrong?
    If is suitable for you I can attach the source file.
    Thanks in advance
    Best regards


    #2
    Hello maxambrogi,

    Thank you for your post and welcome to the NinjaTrader Support Forum!

    The entryOrder will return as != null on each OnBarUpdate() pass after the first. You need to use another IOrder object for your exit and set your entryOrder IOrder object to null or use if(Position.MarketPosition != MarketPosition.Flat) before submitting the exit order.

    For information on IOrder objects please visit the following link: http://www.ninjatrader.com/support/h...nt7/iorder.htm

    Comment


      #3
      Hello Patrick,
      usign yuor suggestions now I have this

      if(Position.MarketPosition == MarketPosition.Flat)
      {
      Print(String.Format("- Today is {0}, We buy at {1}, the low of the day is {2}",Time[0], actualSupportL1, Low[0]));
      entryOrder = EnterLongStop(actualSupportL1,orderName);//,String.Format());
      }

      if(Position.MarketPosition != MarketPosition.Flat)
      {
      Print(String.Format("- Today is {0}, We sell at {1}, the high of the day is {2}, the close of the day is {3}",Time[0],actualOpen,High[0],Close[0]));
      exitOrder = ExitLong(orderName);
      }

      Using the OutputWindows or the VisualStudio debug, I've verified that the condition Position.MarketPosition != MarketPosition.Flat was not execute despite the entryOrder is != null.

      I'm using the simulated platform, kinetick End of day data, day as interval, ES 03-14 as instrument.

      Thanks in advance
      Best regards

      Comment


        #4
        Originally posted by maxambrogi View Post
        Hello Patrick,
        usign yuor suggestions now I have this

        if(Position.MarketPosition == MarketPosition.Flat)
        {
        Print(String.Format("- Today is {0}, We buy at {1}, the low of the day is {2}",Time[0], actualSupportL1, Low[0]));
        entryOrder = EnterLongStop(actualSupportL1,orderName);//,String.Format());
        }

        if(Position.MarketPosition != MarketPosition.Flat)
        {
        Print(String.Format("- Today is {0}, We sell at {1}, the high of the day is {2}, the close of the day is {3}",Time[0],actualOpen,High[0],Close[0]));
        exitOrder = ExitLong(orderName);
        }

        Using the OutputWindows or the VisualStudio debug, I've verified that the condition Position.MarketPosition != MarketPosition.Flat was not execute despite the entryOrder is != null.

        I'm using the simulated platform, kinetick End of day data, day as interval, ES 03-14 as instrument.

        Thanks in advance
        Best regards
        You cannot trade intraday on a chart that only has daily bars.

        Moreover, in your particular case, this will not be viable because you cannot know in advance what the Low or High of the day will be.

        Comment


          #5
          Hello maxambrogi,

          Thank you for your response and thank you to koganam for his response to your last post.

          koganam is correct, you cannot trade intra-day on daily data. The Low and High will not be known on the End Of Day data until the close of the bar.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          649 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          370 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          109 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          574 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          576 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X