Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Profit Chase Stop Trail Set Methods Example

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

    Profit Chase Stop Trail Set Methods Example

    Hi, I have modified the ProfitChaseStopTrailSetMethodsExample Script to consider both directions Long and Short. The chase stop trail works perfectly on the Long Position but with the Short Position, the trail does not work at all. The StopLoss and the Profit don't move.
    HTML Code:
    if (BarsInProgress == 1 && Position.MarketPosition == MarketPosition.Long)
                    {
                        if (UseProfitTarget && ChaseProfitTarget && Close[0] < currentPtPrice - ProfitTargetDistance * TickSize)
                            {
                                currentPtPrice = Close[0] + ProfitTargetDistance * TickSize;
                                SetProfitTarget(CalculationMode.Price, currentPtPrice);
                            }
    
                        if (UseStopLoss && TrailStopLoss && Close[0] > currentSlPrice + StopLossDistance * TickSize)
                            {
                                currentSlPrice = Close[0] - StopLossDistance * TickSize;
                                SetStopLoss(CalculationMode.Price, currentSlPrice);
                            }
                    }
    
                if (BarsInProgress == 1 && Position.MarketPosition == MarketPosition.Short)
                    {
                        if (UseProfitTarget && ChaseProfitTarget && Close[0] < currentPtPrice - ProfitTargetDistance * TickSize)
                            {
                                currentPtPrice = High[0] + ProfitTargetDistance * TickSize;
                                SetProfitTarget(CalculationMode.Price, currentPtPrice);
                            }
    
                        if (UseStopLoss && TrailStopLoss && Close[0] > currentSlPrice + StopLossDistance * TickSize)
                            {
                                currentSlPrice = High[0] - StopLossDistance * TickSize;
                                SetStopLoss(CalculationMode.Price, currentSlPrice);
                            }
                    }​
    The top loop is for the long Position and the bottom one is for the Short Position. Any feedback? I can send the entire script.

    #2
    Hello patdmoney,

    It appears you haven't reversed the condition or stop price for the short position.

    A short position would trail the stop when the price is less than the trigger price distance (reverse of a long position where the trail would occur when the price has risen above the trigger price).
    Further, a buy stop order would need to be placed above the market price, and not below.

    I recommend that you print all of the values to the output window and enable TraceOrders to understand further.

    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you. I fixed it

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      88 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      134 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      119 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      69 views
      0 likes
      Last Post PaulMohn  
      Working...
      X