Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stopping Trending strategy on chop days

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

    Stopping Trending strategy on chop days

    I was looking at reference samples for stopping astretegy on chop days . I want to be able to shut down system after 2 or 3 losers in a row. There was a post in the ref samples that stated just that , I couldnt gather how to impliment it into my strategy can you explain further?

    #2
    DinoSchu, we can't program strategies for customers, but we can help you get started. This code snippet identifies when the last three trades have all been losers:
    Code:
    if (Performance.RealtimeTrades.Count >= 3)
    {
        if (Performance.RealtimeTrades[Performance.RealtimeTrades.Count - 1].ProfitPoints < 0 &&
            Performance.RealtimeTrades[Performance.RealtimeTrades.Count - 2].ProfitPoints < 0 &&
            Performance.RealtimeTrades[Performance.RealtimeTrades.Count - 3].ProfitPoints < 0)
        {
            // the last three realtime trades have all been losers. do something, like halt the strategy.
        }
    }
    There are quite a few helpful samples (complete with code) here.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Thank you . COuld you show a full page so I can see where to input this .

      Comment


        #4
        You could for example check into this specific sample here Dino working with the Performance class - http://www.ninjatrader-support2.com/...ead.php?t=4084

        Comment


          #5
          Refrences samples dont work !!!

          This is what I I put in to the onbar update section .

          // After two straight losers stop strategy
          if (Performance.RealtimeTrades[Performance.RealtimeTrades.Count - 1].ProfitPoints < 0 &&
          Performance.RealtimeTrades[Performance.RealtimeTrades.Count -
          2].ProfitPoints < 0)
          {
          /* A custom method designed to close all open positions and cancel all working orders will be called.
          This will ensure we do not have an unmanaged position left after we halt our strategy. */

          StopStrategy();

          // Halt further processing of our strategy
          return;


          To halt strategy after two straight losers.. The sample you gave me was the halt basic strategy and when I compile my strategy or tghe sample strategy I get the same error message. StopStrategy does not exist in the current context CS0103 . I get it for both mien and sample . is there something I am missing?

          Comment


            #6
            Dino, unfortunately wouldn't know how your custom method is programmed and what issues it may cause - lets try to simplify - did you test the SamplePnl strategy and does it work as you would expect, i.e. stopping trading for the day if either one of the following are happening -
            1. profit exceeds 1000
            2. losses exceed 400
            3. more than 10 trades done

            Comment


              #7
              sample works fine

              You are correct when running I believe the sample sorked fine. Instead of having dollar amounts as the trugger to turn stategy off . I am looking for consecutive losers . I put in the code below .

              http://www.ninjatrader-support2.com/...ad.php?t=25129 and made my adjustments to fit my stategy . the codign to actually turn the system off I cant figure out.

              when the last two trades are losers do something like halt trading.
              That part i can't seem to write corretly in the system. I know you cant write anything for me . I just want to be able to turn my system off after 2 traight losers no matter what my conditions on the strategy are . If you need more infromation from me just tell my what to copy and paste

              Comment


                #8
                Dino, here's a sample also working with the Performance class not entering new trades after 3 consecutive loosers...you just need to weave this into your trade entry conditions (so they don't trigger anymore) and reset the count each day / session.

                Comment


                  #9
                  I copied the sampl portion and pasted directly into my strategy . Wiht the 1000 and 400 dollar limits and it still wont compile . It does on the sample but not On mine . same error StopStrategy(); ... does not exist in its currecnt context . CS0103 error . just can t figure our what i am missing

                  Comment


                    #10
                    Thank you I will try that

                    Comment


                      #11
                      Ok, please let me know if you can get it going, or otherwise I'll need the script including the StopStrategy() to check into, if you don't want to post it just send via email to support at ninjatrader dot com Attn Bertrand

                      Comment


                        #12
                        it seems to me its something simple . I sent you the strategy attn to you . le me know

                        Comment


                          #13
                          Got it, will check into shortly.

                          Comment

                          Latest Posts

                          Collapse

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