Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Placing an Order based on Last Order's close price

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

    Placing an Order based on Last Order's close price

    Hi Everyone,

    I am trying to figure out how to trigger an order (long or short) based on the price that the last order closed out at. For example, if I was long one unit and it was sold at 500, how do I set up the next order based on that sale price + 5 ticks? The issue I have is that the target price from the preceeding order is also based on tick variance so I need to somehow capture the last price or use a variable or method that I don't know about.

    Thank You!

    #2
    Hello,

    Try using the Trades class to access it:


    So: something.Entry
    DenNinjaTrader Customer Service

    Comment


      #3
      Trade class

      Thanks for the tip on where to start. I still am not sure exactly how to get the information I am looking for though.

      Let's say I just want to print to the output window the price of the last order. To do this:
      .
      .
      .
      #region
      Variables
      private Trade entry = null;
      #endregion
      .
      .
      .
      protectedoverridevoid OnBarUpdate()
      {
      if (entryOrder == null && condition1 >= condition2)
      {
      entryOrder = EnterShort(
      1, "My Short Entry");
      Print (
      "Enter Short");
      Print (
      "Entry Price = " + entry.Entry);
      }
      else Print ("No EntryShort");
      }

      When I try this, the compilier works fine but nothing gets printed when I run it even though i know for sure that the entryOrder = EnterShort line does execute and the trade goes through. In fact, with this code in my strategy, the strategy actually quits when it hits this line.
      Last edited by roland5599; 02-09-2009, 07:59 PM. Reason: Code update

      Comment


        #4
        Your entry order may have triggered, but remember a Trade object is not generated until you go full circle. Enter and exit.
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        628 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        359 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        562 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        568 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X