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 cmoran13, Yesterday, 01:02 PM
        0 responses
        29 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        21 views
        0 likes
        Last Post PaulMohn  
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        160 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        95 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        148 views
        2 likes
        Last Post CaptainJack  
        Working...
        X