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

NinjaScript - Enhanced restrictions

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

    NinjaScript - Enhanced restrictions

    Hi Support!

    I am about to launch an automated strategy to the marketplace on a subscribtion basis and these are the issues I have not found ANY support on, hope you can assist:

    1. The strategy must be locked to a specific contract, (NQ 12-19) and may not be used on any other, how do I program this into NinjaScript?

    2. The strategy must enter a position size of 1 lot, the subscriber may not be able to increase this, how do I program this into NinjaScript?

    3. Further to number 2, should a subscriber load the same strategy on an additional NQ 12-19 chart on his platform, how can I still make sure that the licence only allows 1 trade per entry to be executed and not multiple in the case of it being loaded on 2 or 3 charts? Can the restriction be locked to trades made on NQ12-19 in general?

    4. There are two specific settings built into the strategy, Setting A and Setting B, how do I lock those values so they cannot be manipulated, and as there is a box for TradeSize, can I lock this too?

    See screenshot for strategy

    Hope you can help!

    Kind regards,

    #2
    Hello TrendFollowingCapital,

    You can return in OnBarUpdate() if the Instrument.FullName does not match a specified string.


    Use 1 as the quantity parameter for each order method call.


    Each strategy is independent. Communication between scripts is not documented (or supported by NinjaTrader Support) but may be possible using static methods.
    Below is a link to an example.


    You can use private variables instead of public inputs if you do not want the user to be able to change the values. Then these will not be settable by the user.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea, thank you for your response.

      1. I have added the code and have tried numerous ways to incorportate the NQ12-19 but I get a string of errors, what do I edit to make it work with NQ12-19 only and is there any further editing on the rest of the script to work with this change?:

      // Print the full name (including contract month) of the configured instrument
      Print(String.Format("{0} is being used as the input series", Instrument.FullName));

      2. "Use 1 as the quantity parameter for each order method call."
      I have added this already but when you attach the strategy to a chart, the "order properties" allows you to "set order quantity" to any default quantity, can this "order properties" of the strategy Properties be hidden or made private? Or "default quantity" be made unselectable only allowing the "Strategy" option in the dropdown?

      3. Will have to explore the "static methods" but that is way out of my comprehension at this stage, I will try find a programmer to send me that specific code.

      4. Your suggestion to make the "public" into "private" did it's job perfectly, although when also hiding TradeSize it does not solve the problem due to number 3 above.

      Please could you assist further on 1 and 2 above?

      Kind regards,

      Comment


        #4
        Hi Chelsea

        I have solved number 2.
        By setting "EntryHandling.UniqueEntries" it prevents order quantity from being modified, and by setting trade size to private, the quantity is hidden too.
        Now I can limit the specific number of positions the strategy can execute without a subscriber being able to modify that setting no matter what is put in strategy properties.

        Comment


          #5
          Hello TrendFollowingCapital,

          What are the errors you are getting?

          The Instrument.FullName is a string of the instrument symbol. For example "ES 12-19".

          The return should be anywhere you don't want code to execute if the name does not match your string.
          I imagine that the if statement should be at the top of OnBarUpdate(), but an if statement could also be added to OnMarketData if you have code in there as well.


          Regarding the number of entries per direction, I was not understanding you were not asking about the quantity of orders. I'm glad you were able to resolve this.

          This is discussed in the Strategy Builder 301 course.



          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Hi Chelsea

            I changed:

            // Print the full name (including contract month) of the configured instrument
            Print(String.Format("{0} is being used as the input series", Instrument.FullName));

            to:

            // Print the full name (including contract month) of the configured instrument
            Print(String.Format("{0} is being used as the input series", NQ 12-19));

            and this option does not work, could you please clarify, in this example, how I can add NQ 12-19 to the above string so that it works in NinjaScript.
            Strategy builder course does not handle this query.

            Thank you,

            Comment


              #7
              Hello TrendFollowingCapital,

              It looks like you just missed the quotes on your second string. The first string will be what gets formatted and contains the delimiters like {0}, the second string after the comma will be what replaces the {0} but this needs to be a string also.

              Code:
              Print(String.Format("{0} is being used as the input series", [B]"NQ 12-19"[/B]));
              I look forward to being of further assistance.
              JesseNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by FAQtrader, Today, 03:35 PM
              0 responses
              2 views
              0 likes
              Last Post FAQtrader  
              Started by rocketman7, Today, 09:41 AM
              5 responses
              18 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by frslvr, 04-11-2024, 07:26 AM
              9 responses
              124 views
              1 like
              Last Post caryc123  
              Started by selu72, Today, 02:01 PM
              1 response
              11 views
              0 likes
              Last Post NinjaTrader_Zachary  
              Started by WHICKED, Today, 02:02 PM
              2 responses
              21 views
              0 likes
              Last Post WHICKED
              by WHICKED
               
              Working...
              X