Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

StopLoss is not working?

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

    StopLoss is not working?

    Hi there

    I hope someone can help, when I'm running my code, my long/short entries are working but my slop loss isn't working? Am I doing anything wrong?

    My order are limit orders, and I know when to place my stoploss target, but it just isnt working?

    thanks


    Code:
     protected override void Initialize()
            {
                SetProfitTarget(CalculationMode.Ticks, myInput0);
    			CalculateOnBarClose = true;
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
    						
            	if (condition)
                {				
                    EnterLongLimit(DefaultQuantity, 12, "long");
                }
                     
                if (condition)							
                {				
                    EnterLongLimit(DefaultQuantity, 14, "short");
                } 
    			
    			//if (Position.MarketPosition == MarketPosition.Long)
    			{
    				ExitLongStopLimit(14, upperStopLoss);				
    			}
    			
    			//if (Position.MarketPosition == MarketPosition.Short)
    			{
    				ExitShortStopLimit(16, lowerStopLoss);				
    			}
            }

    #2
    ninjamouse, I would suggest to the script run with TraceOrders enabled, this will give more detailed debug info for the order processes happening 'under the hood' and note if you would run into ignored orders for example, while hitting the Internal Order Handling Rules with this approach -

    Comment


      #3
      so with my code when I say

      ExitShortStopLimit(16, lowerStopLoss);

      does that mean it will exist the trade if price foes 16 ticks against the order? If so, why is this never getting filled? i.e. stopping

      Comment


        #4
        No ninjamouse, the 16 would be the limit price of your exit order, that would activate once your lowerStopLoss price is hit.

        It might be easier working with the SetStopLoss or SetTrailStop methods when getting started in this area - http://www.ninjatrader.com/support/h...ub=SetStopLoss

        Comment


          #5
          ok, I'm now using

          if (condition)
          {
          EnterLongLimit(DefaultQuantity, 12, "long");
          SetStopLoss("long", CalculationMode.Ticks, stopLoss, true);
          }

          and my SetStopLoss isnt getting triggered when price is going against me? Any idea?

          thanks

          Comment


            #6
            ninjamouse, the stoploss is probably getting ignored, as another Entry limit order is working which would trigger a signal in the opposite direction. To find out more detailed, a run with TraceOrders enabled would be needed. Here's the relevant tip that goes over this technique:

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            646 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            367 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            107 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            569 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