Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

exit trade when loss reaches certain percentage

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

    exit trade when loss reaches certain percentage

    hi,

    i would like to exit a trade once it reaches a certain percentage loss of the current trade. I dont know how to program in the sript editor but i hope it can be done when editing the strategy. can anyone help?

    thanks

    #2
    Hello alexkow1,

    Thank you for your post.

    When working with the condition builder you can access property Unrealized PnL. It's under category Strategy.

    NinjaScript Reference:
    You can work with the TradePerformance class to capture this information, specifically the GetProfitLoss() method.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      stop order

      Thanks for your reply, the stop seems to be working now.

      however, after putting my stop loss at -50 points, and checking the largest loosing trade i discovered that the largest loosing trade is above -50 points.

      another thing i have observed is that after a trade got stopped when it reached -50 points it immediately entered the market again because my signal was still active.
      I would like the strategy to wait until my signal changes to a new position rather than entering the market again after getting stopped out.

      Comment


        #4
        You'll have to look at the conditions for accepting a trade and redfine them if needed. You can see below for a reference sample on halting a strategy after user defined conditions as one approach.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          identify highs and lows within a certain timeframe

          Hi,
          is there a way in the conditioner to identify the high and low of the last say 1hour ?
          thanks

          Comment


            #6
            Hello alexkow1,

            Yes, see this help guide article for help on making Time comparisons with the condition buillder.

            Then, within the actions, you could set a user variable to a bar high or low. This reference sample can help with using user variables in the condition builder.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              only one trade at a time

              hi,

              thanks for your great help sofar,
              I got one problem at the moment, I would like to allow only one trade at a time.
              I got a strategy where a signal could occur again many times after the first and subsequently ninja trader opens new positions.
              How can i change this in the conditioner?
              once i got a long position for example i dont want ninja trader to generate another one (long or short) until the trade is completed.
              can anyone help?

              thanks

              Comment


                #8
                Hello,

                Use a condition like this before your order line:
                Position.MarketPosition == MarketPosition.Flat



                DenNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                80 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                46 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                29 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                32 views
                0 likes
                Last Post TheRealMorford  
                Started by Mindset, 02-28-2026, 06:16 AM
                0 responses
                66 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Working...
                X