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

Trade Limit with Time Parameters

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

    Trade Limit with Time Parameters

    Hello. I am trying to make a trade limit with time parameters. I have looked at the example and needing more assistance.

    Here is what I have so far.

    // Reset the tradeCounter value at the beginning of each session.

    if (*Time Parameter*)
    {
    Print("resetting tradeCounter");
    tradeCounter = 0;
    }

    // If the amount of trades is less than the permitted value and the position is flat, go on to the next set of conditions.
    if (tradeCounter < MaxTrades && Position.MarketPosition == MarketPosition.Flat)
    {


    How would I add the Time Parameters in the first If Statement??

    #2
    Hello HTrader,

    Below is a link to the 'Automate Your Trading with NinjaTrader's Strategy Builder' which demonstrates a time filter in the strategy builder.
    https://www.youtube.com/watch?v=VxU4...XkWe0Nf&t=2529

    And a link to the reference sample.
    https://ninjatrader.com/support/help...to_limit_t.htm

    As well as a link to a forum post with helpful information about getting started with NinjaScript and C#.
    https://ninjatrader.com/support/foru...040#post786040
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Correction **Time with Maxtrade limit**

      Comment


        #4
        Hello HTrader,

        The time conditions would be the same, and you can add to the conditions a check for an integer incremented on each order submission.

        If you are asking how to use an integer as a counter, below is a link to a code sample.
        https://ninjatrader.com/support/foru...260#post812260
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thank you for clarifying Time parameter steps. More so, How do I set up a Maxtrade strategy in the Strategy builder so I may Limit amount of trades per session.

          Comment


            #6
            Hello HTrader,

            This would have to be tracked with a custom series, as this is the only math available in the strategy builder. As demonstrated in the ExampleBarCounter linked from the post I have linked you, on each bar the current bars value is set to the previous bars value, to carry the value forward. In your script when submitting a new entry order, set the series to the value of itself with an offset adding a value of 1. This will increment in the value.

            This value can be set to 0, if Misc -> First bar of session is True.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by DouglasHogan, Today, 02:12 AM
            0 responses
            4 views
            0 likes
            Last Post DouglasHogan  
            Started by SydniBuck, Today, 12:54 AM
            0 responses
            8 views
            0 likes
            Last Post SydniBuck  
            Started by ketostrongbuyno, Yesterday, 11:50 PM
            0 responses
            11 views
            0 likes
            Last Post ketostrongbuyno  
            Started by ReinaKutch, Yesterday, 11:08 PM
            0 responses
            11 views
            0 likes
            Last Post ReinaKutch  
            Started by JackyThur, Yesterday, 10:51 PM
            0 responses
            12 views
            0 likes
            Last Post JackyThur  
            Working...
            X