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

limit number of trades per day

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

    limit number of trades per day

    Hello,

    i have setup a simple moving average crossover system on 5 minutes bars...and i am trying to create a rule that will limit the number of trades the system can take in a single day.

    Let's say i want it to stop trading in any day 2 signals where generated already. The next day everything should be reset and start over.
    Any guidance please?
    Thank you.

    #2
    Hello,

    Try counting your trades as you make them and putting a condition in your conditions to trade that uses this count. Also, reset this count when the day changes. Maybe something like this: (note, I have not tested this)

    if(ToDay(Time[0]) != the_last_day)
    {
    my_count = 0;
    the_last_day = ToDay(Time[0]);
    }

    if(....conditions to trade here.... && my_count <= 2)
    {

    //entry orders here

    my_count++; //adds one to the my_count variable
    }

    This link will help with ToDay():
    DenNinjaTrader Customer Service

    Comment


      #3
      great

      thank you. it worked like a charm.

      Comment


        #4
        I am also working on counting trades to establish a maximum number of trades per session but the link that was referred to as helpful for ToDay, goes to a general website outside of the forum.
        This is that link:


        Would it be posible to correct the link so it actually goes to the proper forum location? I tried searching on ToDay and ToDay[0] but I couldn't find the reference that was alluded to.
        Thanks
        DaveN

        Comment


          #5
          The link to the NT7 ToDay() function is below:



          You can find a list of all functions for NT7 from the following link:

          MatthewNinjaTrader Product Management

          Comment


            #6
            my_count counts within one trade

            I implemented the code in the earlier sections of this thread, but the variable "my_count" appears to be incrementing within one trade when it should be incrementing between trades.
            I"m attaching a screen shot so you can see the value of the variable as it counts up within the trade on the chart. Here is the code I am running:

            Code:
            			if (EMAProgressionOpenClose(14, 3, Scaler).Progression[0] > EMAProgressionOpenClose(14, 3, Scaler).Progression[1]				
            				&& Close[0] > High[1] && Low[0] >= Low[1]
            				&& ((ToTime(Time[0]) > TT1_Start && ToTime(Time[0]) < TT1_End ) || (ToTime(Time[0]) > TT2_Start && ToTime(Time[0]) < TT2_End )))
                        	{
            				EnterLongLimit(DefaultQuantity, GetCurrentAsk(), "Long");
            				Variable0 = Low[1];
            				my_count++; //adds one to the my_count variable
                        	}
            I set the my_count variable to 0 in the variables section and I have a go flat routine which detects if the my_counts variable is equal to another variable called "Max_Trades" which is also set in the variables section. All of the other stuff seems to be working the way I intend but for some reason the my_count variable incrments within a single trade. Is it possible to have the program execute through the trade execution portion as displayed, but not place a trade since there is already a trade on, but still increments the my_counts variable?
            Hope you can help.
            Thanks
            DaveN
            Attached Files
            Last edited by daven; 01-10-2013, 05:52 PM. Reason: Correct spelling

            Comment


              #7
              Hello DaveN,
              You may find this sample code helpful which demonstrates how to limit trading after consecutive losses.
              JoydeepNinjaTrader Customer Service

              Comment


                #8
                Yes, very helpful, thanks. I'm incorporating it into my existing strategy to improve my trade counting function.
                Thanks
                DaveN

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by gravdigaz6, Today, 12:05 AM
                0 responses
                1 view
                0 likes
                Last Post gravdigaz6  
                Started by alexstox, 10-16-2018, 03:29 PM
                11 responses
                344 views
                0 likes
                Last Post aligator  
                Started by ageeholdings, 05-01-2024, 05:22 AM
                6 responses
                44 views
                0 likes
                Last Post ageeholdings  
                Started by tony_28217, Yesterday, 07:04 PM
                0 responses
                11 views
                0 likes
                Last Post tony_28217  
                Started by flybuzz, Yesterday, 10:33 AM
                1 response
                10 views
                0 likes
                Last Post flybuzz
                by flybuzz
                 
                Working...
                X