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 different contract

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

    Trade different contract

    I would like to add some code to a strategy i built in the strategy builder as im assuming it cannot be done in the strategy builder itself.

    condition is:

    if position size for contract x = 10
    then buy current position size (10) worth of contract y and stop trading strategy

    Thanks in advance for any help

    #2
    Hello jmahon,

    That should be possible. You can use the Strategy -> Current Position Size in the builder to know the position size. You can also use that as the quantity for an entry.

    Stopping trading could be accomplished by using a variable. If you made a bool variable with a default value of true, then check that the variable is true as part of the entry condition. That could be used to toggle the condition on or off, if you set the variable to false when entering the order the condition wont happen again. That variable could also be used in other conditions to effectively turn the whole strategy off.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello jmahon,

      That should be possible. You can use the Strategy -> Current Position Size in the builder to know the position size. You can also use that as the quantity for an entry.

      Stopping trading could be accomplished by using a variable. If you made a bool variable with a default value of true, then check that the variable is true as part of the entry condition. That could be used to toggle the condition on or off, if you set the variable to false when entering the order the condition wont happen again. That variable could also be used in other conditions to effectively turn the whole strategy off.

      I look forward to being of further assistance.
      Thanks for the reply.

      sorry but i must have not explained well enough. i am wanting to buy a different contract when those conditions are met. its not the conditions I'm uncertain of its can i buy a separate contract.

      Thanks again for your time

      Comment


        #4
        Hi jmahon,
        Sure. That is possible.
        Step 1: In the Strategy Builder, under Additional Data, add the instrument you want to use a signal trigger as Input Series.
        Step 2: Under Conditions, make sure to refer to this Additional Data series instead of "Default Input" when checking if you should place a trade.
        Or look at both, the signal trigger instrument and the trading instrument for your entry/exit logic, if so desired.
        Step 3: Actions, Stops & Targets remain as is.
        Step 4: In the Strategy Analyzer, pick the instrument you want to place trades against.
        Step5: Run the strategy.
        Have fun.
        NT-Roland

        Comment


          #5
          Hello jmahon,

          NT-Roland is correct in case you want to place trades based on another contract to the primary instrument. In case you are looking to do a multi instrument strategy for trading both instruments/contracts you would need to unlock the code. You can manually create strategy which target multiple contracts or instruments to trade them at the same time.

          You can see the SampleMultiinstrument strategy for an example of this concept.

          I look forward to being of further assistance.
          JesseNinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_Jesse View Post
            Hello jmahon,

            NT-Roland is correct in case you want to place trades based on another contract to the primary instrument. In case you are looking to do a multi instrument strategy for trading both instruments/contracts you would need to unlock the code. You can manually create strategy which target multiple contracts or instruments to trade them at the same time.

            You can see the SampleMultiinstrument strategy for an example of this concept.

            I look forward to being of further assistance.
            Gday Jesse, thanks for the advice. yes i am wanting to trade two instruments long on one contract short the other contract. Are you experienced with coding in c# ? Im looking to hire a tutor as some of this will be over my head
            Last edited by jmahon; 11-11-2020, 02:19 AM.

            Comment


              #7
              Hello jmahon,

              If you are just getting started I would suggest to use some external C# edutation websites like MSDN to learn prior to starting NinjaScript. While our support can assist with coding questions we are unable to provide general C# education as those resources already exist in other places. C# is a prerequisite of developing NinjaScript so learning that first will greatly help with NinjaScript.

              Here is a public learning resource provided by Microsoft: https://dotnet.microsoft.com/learn/csharp

              I look forward to being of further assistance.
              JesseNinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_Jesse View Post
                Hello jmahon,

                If you are just getting started I would suggest to use some external C# edutation websites like MSDN to learn prior to starting NinjaScript. While our support can assist with coding questions we are unable to provide general C# education as those resources already exist in other places. C# is a prerequisite of developing NinjaScript so learning that first will greatly help with NinjaScript.

                Here is a public learning resource provided by Microsoft: https://dotnet.microsoft.com/learn/csharp

                I look forward to being of further assistance.
                Thanks jesse appreciate the help. enjoy the rest of your week

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by RookieTrader, Today, 07:41 AM
                1 response
                5 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by kujista, Today, 05:44 AM
                1 response
                9 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by elderan, Yesterday, 08:03 PM
                1 response
                12 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Started by samish18, Yesterday, 08:57 AM
                8 responses
                25 views
                0 likes
                Last Post samish18  
                Started by DJ888, 04-16-2024, 06:09 PM
                3 responses
                10 views
                0 likes
                Last Post NinjaTrader_Erick  
                Working...
                X