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

ENTRY Orders Not Working the Right Way

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

    ENTRY Orders Not Working the Right Way

    Hey guys, I uploaded a simple strategy I'm testing. and it uses OnOrderUpdates. The Strategy is for RANGE BARs ONLY.

    My goal is that when Volume[0] > Volume[1] an Entry Order will be placed in both Directions a BUY and SELL before the Current Bar closes. It's why I'm using LiveUntilCancelled Orders.

    The Problem is that when Volume[0] > Volume[1] only One Order is placed in either direction. and I don't know WHY.

    Can someone please help. The Strategy keeps placing ONE order. and I want it to place a EntryStopOrder in both directions. Then I want the Other Order to Be Cancelled if the current Bar Closes in either direction.

    I placed a small code that Cancels this
    Code:
    	if( FirstTickOfBar && shortEntryOrder1 != null && (CurrentBar > trigBar && CurrentBar < trigBar + 2)  && Close[1] > Low[1])
    					{
    						CancelOrder(shortEntryOrder1);
    					}
    Please check this and tell me what I need to fix.

    Thank you so much!

    P.S: PLEASE Don't Look at this in Strategy Analyzer. as this is ONly Set for FORWARD TESTING. thank you!

    P.P.S: I use Default Values on EUR/USD 20 Range (TenthOfaPip) Chart.
    Attached Files

    #2
    Hello ginx10k,

    You are likely running into a violation of the Internal Order Handling rules.

    From the help guide:
    Methods that generate orders to enter a position will be ignored if:
    • The strategy position is flat and an order submitted by an enter method (EnterLongLimit() for example) is active and the order is used to open a position in the opposite direction

    In your case this would be an active EnterLongStop or EnterShortStop.

    See 'Internal Order Handling Rules that Reduce Unwanted Positions'.
    http://ninjatrader.com/support/helpG...d_approach.htm

    To place these orders at the same time you will need to switch to the unmanaged approach and control the placing, modifying, and canceling of orders with logic.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      ORDERS Working but NOT cancelling Now

      Hey, I've UPloaded a script. that Pretty much does what I was looking for. but I can't Cancel the Orders after the Bar closes. This is for Range Bars Only. and it's super simple.

      if Volume[0] > Volume[1] = Enter LongStop and ShortStop.

      Then Cancel One order if bar closes against it:

      Code:
      	//CANCEL BUY ORDER if Down CLOSE
      			if(FirstTickOfBar && (orderId.Length > 0) && (CurrentBar > trigBar && CurrentBar < trigBar + 2) && Close[1] < Open[1])
      			{	AtmStrategyCancelEntryOrder("orderId");	}
      			
      			//CANCEL SELL ORDER if Down CLOSE
      			if(FirstTickOfBar && (orderId2.Length > 0) && (CurrentBar > trigBar && CurrentBar < trigBar + 2) && Close[1] > Open[1])
      			{	AtmStrategyCancelEntryOrder("orderId2");	}
      The Trade is Entering perfectly. but the Other Entry Order Won't Cancel. Any Ideas
      Attached Files

      Comment


        #4
        Hi ginx10k,

        It looks like you create an orderId with GetAtmStrategyUniqueId()..

        However, you try and cancel the order with a string. What is this string and why are you not using the orderId that you have already saved?

        (Is this string a single name? These don't work with Atm strategy methods...)

        When you cancel an Atm strategy entry you need to do this with the OrderId (not a string that has a message that says order id)
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Problem solved. Thank you

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by alifarahani, Today, 09:40 AM
          4 responses
          19 views
          0 likes
          Last Post alifarahani  
          Started by gentlebenthebear, Today, 01:30 AM
          3 responses
          16 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by PhillT, Today, 02:16 PM
          2 responses
          7 views
          0 likes
          Last Post PhillT
          by PhillT
           
          Started by Kaledus, Today, 01:29 PM
          3 responses
          11 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by frankthearm, Yesterday, 09:08 AM
          14 responses
          47 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Working...
          X