Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

adjustments to strategy for distribution.

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

    adjustments to strategy for distribution.




    people with nt,



    i am preparing some automated strategies i have developed for distribution.



    i have spoken with some nt employees about these subjects so i already have a basic understanding of the tools that the nt platform has available to restrict the use of a strategy only to paying clients.



    however, my strategies are intended to be traded only on specific instruments, on an account with a given minimum capital available and with defined position sizes. this means that i want to incorporate code to my strategies so that the strategy will only run if all conditions are valid. i imagine nt must have the capability to deliver every one of these requirements.


    ¿how can one limit a strategy to only run if the chart or instrument it has been enabled on is the nq futures contract? ¿and is that also possible for the mnq futures contract?


    similarly, ¿is it possible to have a check for available capital in the account? and this could be a little more complex than it seems. i would like to have an initial check on the first day the strategy is enabled to verify the available capital is above $50,000 usd, and then check every day that the available capital is still above $40,000 usd.


    and the strategy would always trade in multiples of 2. so the smallest position size would be 2, then 4, 6 and so on. i don't think that would be hard, however, i would like to offer clients the possibility to trade smaller (never larger) position sizes than their account can accommodate. so, a client that has enough capital to trade 6 contracts could trade only 2 contracts if they so choose. i imagine i could create a calculation with the available capital divided by the minimum i set for every 2 contracts and then check use an input the client could choose but only if it is not greater than the previously calculated variable.


    i should be enrolled in the vendor program before one or two days, so these are some adjustments that i want to complete as soon as possible. very well, regards.


    #2
    You can use Instrument.MasterInstrument.Name to find the symbol. So if you wanted to limit it to specific Instruments, I would assume a simple boolean being equal to "NQ" or "MNQ" would suffice.

    I haven't attempted to check the account value, but I'm sure that should be possible? I only add a question mark to that as I have yet to reliably retrieve the commissions from the account I happen to be on. It seems the workaround I am using has a variable that is set for strategy purposes.

    As for trading in multiples of 2. That is more than possible. I currently have code to limit my trades to roughly $50 per trade and it calculates the amount needed in that instance. I also have code that limits the total max contracts at any given time as 60. So any more, and it won't take the trade. If I have a trade that can have at most 10 lots, and I already have 53 being traded, it will adjust to 7.

    I'm sure there are a handful of things that you might not be able to do due to limitations with NT itself or c#. There are usually ways to code these things, the problem most of the time is if you don't know how to create the logic for what you want to attempt.

    Comment


      #3
      Originally posted by rockmanx00 View Post
      You can use Instrument.MasterInstrument.Name to find the symbol. So if you wanted to limit it to specific Instruments, I would assume a simple boolean being equal to "NQ" or "MNQ" would suffice.

      I haven't attempted to check the account value, but I'm sure that should be possible? I only add a question mark to that as I have yet to reliably retrieve the commissions from the account I happen to be on. It seems the workaround I am using has a variable that is set for strategy purposes.

      As for trading in multiples of 2. That is more than possible. I currently have code to limit my trades to roughly $50 per trade and it calculates the amount needed in that instance. I also have code that limits the total max contracts at any given time as 60. So any more, and it won't take the trade. If I have a trade that can have at most 10 lots, and I already have 53 being traded, it will adjust to 7.

      I'm sure there are a handful of things that you might not be able to do due to limitations with NT itself or c#. There are usually ways to code these things, the problem most of the time is if you don't know how to create the logic for what you want to attempt.



      thanks.



      i agree. nt is a powerful platform, it is possible to code a lot of different capabilities.



      the checks will probably look something like:


      _ if instrument =/ nq then return;


      _ if accountsize < requiredcapital then return;


      _ positionsizetotrade = 2 * min { user input, calculationformaximumpositionsizeinpairs } ; where the user would choose the number of pairs.



      however, there could be multiple ways to code these checks and the nt staff should be far more knowledgeable on how to create this code and in which section to place it.

      Comment


        #4
        Yes. If you are trying to code this, Google is also a very good resource, especially since Ninjascript is C# based. The key is if you want to understand something that is more C# specific, try googling what you want and specify C#. If you want something that is more Ninjatrader related, then make sure to add either ninjatrader or even ninjascript. Many times you will see the results pop up something from these forums as well. You may not find the exact solution, but you may find some hints that'll get you on track.

        Comment


          #5
          Hello rtwave,

          rockmanx00 is providing good information.

          Below are links to the Desktop SDK which provide the specific documentation.

          Instrument.FullName - https://developer.ninjatrader.com/docs/desktop/fullname
          Account.Get() - https://developer.ninjatrader.com/docs/desktop/get
          AccountItem - https://developer.ninjatrader.com/do...op/accountitem

          As well as the microsoft documentation on Math.Min().


          You could add your conditions to State.Configure logic block in OnStateChange() and if the condition fails call SetState(State.Terminated) to disable the script.
          Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.


          I would also recommend calling Log() first to inform the user what is going on.
          Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.

          Chelsea B.NinjaTrader Customer Service

          Comment


            #6


            i have decided on two strategies i will be leasing through the nt ecosystem.


            this if the first one, i decided to call it _ short and long strategies nasdaq strategy level 2 of 4 _.


            Click image for larger version

Name:	20250209-d-mnq-sls-l2-0001.jpg
Views:	47
Size:	36.4 KB
ID:	1334292

            Click image for larger version

Name:	20250209-d-mnq-sls-l2-0002.jpg
Views:	43
Size:	79.6 KB
ID:	1334293

            Click image for larger version

Name:	20250209-d-mnq-sls-l2-0003.jpg
Views:	43
Size:	91.1 KB
ID:	1334294

            Comment


              #7

              this if the second one, _ short and long strategies nasdaq strategy level 3 of 4 _.

              Click image for larger version

Name:	20250209-d-mnq-sls-l3-0001.jpg
Views:	46
Size:	36.4 KB
ID:	1334296


              Click image for larger version

Name:	20250209-d-mnq-sls-l3-0002.jpg
Views:	43
Size:	79.1 KB
ID:	1334297

              Click image for larger version

Name:	20250209-d-mnq-sls-l3-0003.jpg
Views:	41
Size:	93.7 KB
ID:	1334298

              Comment


                #8

                these strategies are ready to be enabled on my account, but not yet to distribute to other individuals. therefore, i have some more questions for nt staff.



                the most relevant question is, ¿what are the possible ways to distribute a strategy? ¿will i have to create a workspace and then distribute that file in addition to the files for the strategy? ¿is it possible to only disseminate the files for the strategy itself?


                and related to this, ¿how can indicators be distributed? ¿is it possible to transform an indicator into a function or some other formulation such that it will only perform the required calculations inside a strategy? the idea is to distribute code that will not plot in a chart and could not be used for any other purpose outside of the strategy.


                and my last question for the moment, i plan to create files to distribute once per month. i think that it should be possible to distribute files to every client so that the strategy would only function for the period that has already been paid for. in this case, ¿what kind of code should i use? i imagine something like if date < start date or date > end date then terminate.


                very well, regards.
                Last edited by rtwave; 02-11-2025, 09:49 AM.

                Comment


                  #9
                  Hello rtwave,

                  You can export your code as an assembly (.dll) to prevent this code from being read or modified, and optionally you can use Agile.NET to prevent the code from being un-assembled (deobfuscated).

                  To export your script do the following:
                  1. Click Tools -> Export -> NinjaScript
                  2. Click the 'add' link -> check the box(es) for the script(s) you want to include -> click OK
                  3. Check the option labelled 'Export as compiled assembly'
                  4. If you have Agile.NET installed and would like to use this, check the box labelled Protect compiled assembly
                  5. Click Export -> enter a unique name for the file in the Dialog window
                  6. Choose a save location -> click Save
                  7. Click OK to clear the export location message
                  By default your exported file will be in the following location:
                  • (My) Documents/NinjaTrader 8/bin/Custom/ExportNinjaScript/<export_file_name.zip>
                  Below is a link to the help guide on Exporting NinjaScripts.
                  Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.


                  As well as a link to the Distribution section of the Desktop SDK.
                  https://developer.ninjatrader.com/do...p/distribution

                  Below is a link to the help guide on Agile.NET protection.
                  Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.


                  You can purchase Agile.NET here.
                  http://www.secureteam.net/ninja-pricing

                  You can include workspace xml files in a folder named workspaces manually added to the export zip file and these will import when importing the export zip.
                  Your templates are stored in the NinjaTrader settings folder in:
                  • (My) Documents\NinjaTrader 8\workspaces​
                  You can also include templates with the export.
                  Your templates are stored in the NinjaTrader settings folder in:
                  • (My) Documents\NinjaTrader 8\templates
                  ​Below is a link to a short to an older video to demonstrate.



                  You can expose values to a host that are not intended to plot​.

                  Below is a link to the reference sample which demonstrates.
                  Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.



                  The Vendor License Management Console allows for expiring licenses after a preset amount of time.
                  I would recommend you use incrementing version numbers in the export window to keep track of which release is the latest.

                  I also recommend isolating any shared dependencies to separate files. Below is a link to a video demonstrating.
                  Chelsea B.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by rubiijonson, Today, 01:02 AM
                  0 responses
                  4 views
                  0 likes
                  Last Post rubiijonson  
                  Started by fkronloff, Today, 12:25 AM
                  0 responses
                  3 views
                  0 likes
                  Last Post fkronloff  
                  Started by Zadomani, Yesterday, 11:39 PM
                  0 responses
                  11 views
                  0 likes
                  Last Post Zadomani  
                  Started by ToNovy, 01-27-2025, 11:22 PM
                  20 responses
                  197 views
                  0 likes
                  Last Post ToNovy
                  by ToNovy
                   
                  Started by hypercube, 03-07-2025, 12:22 AM
                  2 responses
                  38 views
                  0 likes
                  Last Post hypercube  
                  Working...
                  X