Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Limit order trouble

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

    Limit order trouble

    Hi,

    I coded a simple strategy where I buy limit below the market.
    What I don't understand is why, once filled the two orders, the strategy creates a new position (at the market). I tried with TraceOrders, but I don't understand.
    below the code:
    Code:
     protected override void Initialize()
            {
                CalculateOnBarClose = true;
    			EntriesPerDirection = 1; 
    			EntryHandling = EntryHandling.UniqueEntries;
    			TimeInForce = Cbi.TimeInForce.Day; 
    			TraceOrders         = true; 
    			SetProfitTarget("Buy_Test", CalculationMode.Ticks, 5);
    			SetProfitTarget("Buy_Test1", CalculationMode.Ticks, 5);
    			
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
        protected override void OnBarUpdate()
    	{
    		if (start_Price > 1)
    		{
    		 EnterLongLimit(nCtr, 1207, "Buy_Test");
    		 EnterLongLimit(nCtr, 1206, "Buy_Test1");
    		}	
        }
    I attach the pictures of what happen in simulation and the startegy setting.

    Thanks.
    Attached Files

    #2
    I'm also trying to use the IOrder with the following code, but I don't see any order on the market. The TraceOrder is completely empty.
    I first defined the following variable in the proper region:
    private IOrder entryOrder = null;

    Code:
     protected override void Initialize()
            {
                CalculateOnBarClose = true;
    			//EntriesPerDirection = 1; 
    			//EntryHandling = EntryHandling.UniqueEntries;
    			//TimeInForce = Cbi.TimeInForce.Day; 
    			TraceOrders         = true; 
    			//SetProfitTarget("Buy_Test", CalculationMode.Ticks, 5);
    			//SetProfitTarget("Buy_Test1", CalculationMode.Ticks, 5);
    			
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
        protected override void OnBarUpdate()
    	{
    	// Submit an entry limit order if we currently don't have an entry order open
    			if (entryOrder == null && Close[0] > Open[0])
    			{
    				/* The entryOrder object will take on a unique ID from our EnterLong()
    				that we can use later for order identification purposes in the OnOrderUpdate() method. */
    				entryOrder = EnterLong(1, "Buy_TestOne");
    			}

    Comment


      #3
      MAX, for your first question, you are seeing a position because your strategy had its orders filled. The sell limit orders are then sent because of the profit target you have set in the code.

      As for the second question, are you seeing any errors in the logs (right-most tab of Control Center)? Also, are you sure the conditions are being met?
      AustinNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      647 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      369 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      108 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      572 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      573 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X