Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Stopping Strategy

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

    Stopping Strategy

    The code below is from the reference sample "HaltBasicStrategy":

    if
    (Performance.AllTrades.TradesPerformance.Currency. CumProfit > 1000

    How can I change this to be 100 pips, plus be sure it includes unrealized as well as realized profit?
    Thanks,
    Jim

    #2
    >> plus be sure it includes unrealized as well as realized profit?
    Unfortunately this is not supported.

    Comment


      #3
      Stopping Strategy

      Are you saying that "pips" is not supported, which I assume I could use "ticks" instead, oR the Unrealized Plus Realized profit?

      Comment


        #4
        Both are not supported.

        Comment


          #5
          I was given this at one time in the past, for currency basis.
          Is it no longer valid?

          if ((Performance.RealtimeTrades.TradesPerformance.Cur rency.CumProfit + Position.GetProfitLoss(Close[0], PerformanceUnit.Currency) >= 200)

          Comment


            #6
            Right, forgot about that. Since you aware of this feature: why do you ask if it's available?

            Comment


              #7
              I had problems getting it to work in the past, but there are new features in the reference sample that I need to use, that hopefully will allow it to work.
              Also, was really wanting to use "ticks", rather than a currency amount.

              Comment


                #8
                GetProfitLoss() works with parameters documented here: http://www.ninjatrader-support.com/H...rofitLoss.html

                Comment


                  #9
                  So, PerformanceUnit.Points, could only be used with the Unrealized p&l, and not the realized?
                  Is that correct, which still would not give me what I was hoping for.

                  Comment


                    #10
                    Sure you can use Points like
                    Performance.AllTrades.TradesPerformance.Points.Cum Profit

                    Comment


                      #11
                      Great!
                      Thank you for the help.
                      Jim

                      Comment


                        #12
                        getting error message about the "+" when trying this.

                        if
                        ((Performance.RealtimeTrades.TradesPerformance.Poi nts + Position.GetProfitLoss(Close[0],PerformanceUnit.Points) >= 100))

                        Comment


                          #13
                          Found my error, left out .Cumprofit

                          Comment


                            #14
                            Stop strategy

                            The below code is not working.
                            Was up 24 pips, and never closed out and stopped.

                            // If the profit on real-time trades = 10 pips stop trading
                            if ((Performance.RealtimeTrades.TradesPerformance.Poi nts.CumProfit + Position.GetProfitLoss(Close[0],PerformanceUnit.Points) >= 10))

                            {
                            StopStrategy();
                            return;
                            }

                            Comment


                              #15
                              Not sure what you mean by "pips". You code below works based on points not "pips".

                              Also: not sure what "StopStrategy" does. This is not a NinjaScript but a custom method. I suggest debugging your code as per here: http://www.ninjatrader-support.com/v...ead.php?t=3418

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by adeelshahzad, Today, 03:54 AM
                              5 responses
                              30 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by stafe, 04-15-2024, 08:34 PM
                              7 responses
                              31 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by merzo, 06-25-2023, 02:19 AM
                              10 responses
                              823 views
                              1 like
                              Last Post NinjaTrader_ChristopherJ  
                              Started by frankthearm, Today, 09:08 AM
                              5 responses
                              17 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              3 responses
                              43 views
                              0 likes
                              Last Post jeronymite  
                              Working...
                              X