Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

stop trading for day after x realized loss

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

    stop trading for day after x realized loss

    I looked in the help but I didn't seem to be able to get this working. Not sure if this has been covered before.

    I want to stop trading for the current day if RealizedProfitLoss is equal to lets say -$1000.

    Any suggestions or links?

    Thanks.

    #2
    Hello,

    You will want to use Performance.AllTradesPerformance.Currency.CumProfi t

    This link will help:


    This reference sample will help also:
    DenNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Ben View Post
      Hello,

      You will want to use Performance.AllTradesPerformance.Currency.CumProfi t
      Hi there, I have used this successfully on strategies for clients, but today I was working on a strategy that uses AtmStrategyCreate() to issue orders. And, it would appear that the same kind of performance accounting does not happen when I do this. Is there a way to collect the performance data from the AtmStrategies I'm creating, so I can stop or alter the strategy based on real-time performance?

      Thanks!

      Comment


        #4
        For ATMs you can only get things like Realized PnL and Unrealized PnL. You will need to run your own cache for remembering these values though.



        Please take a look at the Help Guide index. Scroll down to the G section and look at any of the GetAtmStrategy..() methods.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Josh View Post
          For ATMs you can only get things like Realized PnL and Unrealized PnL. You will need to run your own cache for remembering these values though.
          Thanks, I have it working now!

          Comment


            #6
            I ran across another issue that is causing some problems in back testing. I have bad tick spikes.

            Is there a way I can reload my backfill data from scratch, or filter out these bad ticks?

            Can I globally delete all my data so it will call the backfills again?

            Comment


              #7
              sauer11155,

              Please go to Tools->Historical Data->Reload or Delete.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Thanks for the help.

                I have been searching in the Help and can't really find this info.

                When I have a trade condition, I have a flag become true, and I have a double called signalPrice = Open [0]. I can code this.

                I now want to wait for 3 bars to pass by and then compare the current bar open to the signal price. If it is higher by x percent, I take the trade.

                I looked around at BarsInProgress and others but not sure those apply to this example.

                Do any of you know a handy link I can read up on this?

                Comment


                  #9
                  If you want to see how many bars pass by you will need another variable to keep track of CurrentBar.
                  Code:
                  if (some condition)
                       tradeConditionBar = CurrentBar;
                  
                  if (CurrentBar == tradeConditionBar + 3)
                  {
                       if (Open[0] > signalPrice * 1.05)
                            EnterLong();
                  }
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_Josh View Post
                    If you want to see how many bars pass by you will need another variable to keep track of CurrentBar.
                    Code:
                    if (some condition)
                         tradeConditionBar = CurrentBar;
                    
                    if (CurrentBar == tradeConditionBar + 3)
                    {
                         if (Open[0] > signalPrice * 1.05)
                              EnterLong();
                    }

                    Awesome thanks! Funny how the more clear I am about what I am trying to do, the more helpful this forum is. I hope other folks appreciate this here.

                    Comment


                      #11
                      Originally posted by NinjaTrader_Josh View Post
                      If you want to see how many bars pass by you will need another variable to keep track of CurrentBar.
                      Code:
                      if (some condition)
                           tradeConditionBar = CurrentBar;
                       
                      if (CurrentBar == tradeConditionBar + 3)
                      {
                           if (Open[0] > signalPrice * 1.05)
                                EnterLong();
                      }
                      Josh,

                      I'm assuming "signalPrice" is set up in variables as "double"...
                      is "tradeConditionBar" set up in variables as "int" or "double"? or???
                      Kirk

                      Comment


                        #12
                        tradeConditionBar is an int and signalPrice is a double.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          thanks Josh

                          Comment


                            #14
                            Hello Josh,

                            I was wondering whether you can show me a sample of how he saved the Close[0] to a double after his trade condition was met, I was thinking of DataSeries.Set

                            "When I have a trade condition, I have a flag become true, and I have a double called signalPrice = Open [0]. I can code this."

                            Thank you in advance

                            Comment


                              #15
                              Hello katsaf,

                              Thanks for your note.

                              An example of how to save the value to a variable is below:

                              Code:
                              In the variables region:
                              
                              private double signalPrice = 0;
                              
                              In OnBarUpdate:
                              
                              if (some condition)
                              {
                                   tradeConditionBar = CurrentBar;
                                   signalPrice = Open[0];
                              }
                               
                              if (CurrentBar == tradeConditionBar + 3)
                              {
                                   if (Open[0] > signalPrice * 1.05)
                                        EnterLong();
                              }
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

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