Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop losses on Positions from limit orders

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

    Stop losses on Positions from limit orders

    Hi there

    I have a strategy which enters positions using the EnterLongLimit & EnterShortLimit methods.

    My strategy with stop losses is to only add a stoploss if the position has moved into a profit on the previous bar. I then set the profit to be the avg entry price.

    However, i keep on having the stoploss triggerred inside the same 1 minute bar as the position was enterred, even when I add some code trying to prevent this (stipulating only SetStopLoss() when BarsSinceEntry() is greater than 0).

    The code is here:

    // Introduce stoploss on pos if sitting on profit
    if (Position.MarketPosition == MarketPosition.Short && Position.GetProfitLoss(Close[1], PerformanceUnit.Points)>=0)
    {SetStopLoss(short_position_name,CalculationMode.P rice, Position.AvgPrice,
    true);}

    if (Position.MarketPosition == MarketPosition.Long && BarsSinceEntry(long_position_name)>1 && Position.GetProfitLoss(Low[0], PerformanceUnit.Points )>=0)
    {SetStopLoss(long_position_name,CalculationMode.Pr ice, Position.AvgPrice,
    true);}


    Any advice much appreciated as usual!! :-)

    Ben

    I have tried to exclude the stoploss from doing this

    #2
    The current price and average position price will be very close together, no? Are you sure it's not just triggering like it's supposed to?

    Comment


      #3
      Hi Peter

      Hmm. Pretty sure that's not the case. Iin historical data there is no way o knowing what came first within the same bar of data (the trade ebtry or the stop loss). To avoid this problem I'd be happy to just prevent the stop loss being set in the same bar of data as the opening of the trade, but not sure how to achieve that.

      BH

      Comment


        #4
        If you do not want the stop loss to be submitted on the same bar as entry then do not use the SetStopLoss() method but instead call the ExitLongStop() or ExitShortStop() methods.
        RayNinjaTrader Customer Service

        Comment


          #5
          Tks Ray - i'll do that - BH

          Comment


            #6
            Its working! Tks Ray, pls ignore below..

            BH

            Hi Ray

            I tried as you suggested, but am struggling to get the stops to activate at all now... I tried the following:

            // Introduce stoploss
            if (Position.MarketPosition != MarketPosition.Flat)
            {ExitShortStop(Position.AvgPrice);
            ExitLongStop(Position.AvgPrice);
            }

            The stops are never activated, even on loss making trades. Just to recap, all the opening trades are enterred into using EnterLongLimit() and EnterShortLimit() statements.

            Tks for your help on this!

            Ben Heaton
            Last edited by BenHeaton; 03-04-2008, 12:54 PM.

            Comment

            Latest Posts

            Collapse

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