Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

About reversing orders

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

    About reversing orders

    Hi,

    I would like to know wheteher this combination of orders is ok.

    I enter long at some level if some conditions are true with an EnterLongStop Order.

    If price goes right I close with profit at some level with a: SetProfitTarget(CalculationMode.Ticks,profitticks) , placed in the Initialize() method.

    But, if I am wrong an price goes against my prediction I want to reverse position with a ExitShortStop.

    If this combinations of orders is posible? the ExitShortStop order has to have more contracts than the EnterLongStop Order.?

    Thanls a lot for the constant help

    #2
    Sorry,

    I did mean reverse the long position to short with a EntershortStop order with double size.

    Thanks

    Comment


      #3
      Hello CJS,

      My initial response was incorrect. Please see post #5 in this thread.
      Last edited by NinjaTrader_RyanM1; 08-20-2010, 10:02 AM. Reason: Correction
      Ryan M.NinjaTrader Customer Service

      Comment


        #4
        Sorry,

        I am using a ExitLongStop order which is being ignored while a SetProfitTarget (In the Initialize()) is active.

        How can I have a profit target and a ExitLongStop (used as a SL at certain level) at the same time?

        Thanks

        Comment


          #5
          I apologize. You're right - this would violate internal order handling rules.


          Methods that generate orders (excluding market orders) to enter a position will be ignored if:
          • A position is open and an order submitted by an exit method (ExitLongLimit() for example) is active and the order is used to open a position in the opposite direction
          • A position is open and an order submitted by a set method (SetStopLoss() for example) is active and the order is used to open a position in the opposite direction
          To work around this: Instead of using the set statements, you could submit a market order once your target price has been reached.

          Example:

          if (Position.MarketPosition == MarketPosition.Long)
          {
          if (Close[0] >= Position.AvgPrice + TickSize * targetTicks)
          ExitLong();
          }
          Ryan M.NinjaTrader Customer Service

          Comment


            #6
            Hi,

            Thanks a lof for all the hepl. Yuor recommendation is working really well.

            I have a last question about this topic.

            Is there any problem or uncompatibility with this block of code? I am just trying to close an order at a fix price either with profit or a loss. The point is that for back test purposes I need to exit the position at some level (and not at the open level of the next bar where conditions become true)

            .......

            else if (Position.MarketPosition==MarketPosition.Short)
            {

            if (Close[0]<=Position.AvgPrice-TickSize*2)

            {
            ExitShortLimit(Position.AvgPrice-myrange*coef_TP); // with benefit
            }
            else
            {
            ExitShortStop(myhigh,"La entrada Corta"); // with loss

            }

            Comment


              #7
              CJS, I took a quick look and do not see anything wrong with your code. Please try it out and if it doesn't work as expected, you can start using Print() to print out (to the Output Window under the Tools menu) the values you're using to see what the script is "thinking", basically just debugging the script.
              AustinNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by kaywai, 09-01-2023, 08:44 PM
              5 responses
              601 views
              0 likes
              Last Post NinjaTrader_Jason  
              Started by xiinteractive, 04-09-2024, 08:08 AM
              6 responses
              22 views
              0 likes
              Last Post xiinteractive  
              Started by Pattontje, Yesterday, 02:10 PM
              2 responses
              17 views
              0 likes
              Last Post Pattontje  
              Started by flybuzz, 04-21-2024, 04:07 PM
              17 responses
              230 views
              0 likes
              Last Post TradingLoss  
              Started by agclub, 04-21-2024, 08:57 PM
              3 responses
              17 views
              0 likes
              Last Post TradingLoss  
              Working...
              X