Announcement

Collapse
No announcement yet.

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, 01: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 KirkHammett, Yesterday, 11:15 PM
                0 responses
                5 views
                0 likes
                Last Post KirkHammett  
                Started by soon123, Yesterday, 11:12 PM
                0 responses
                4 views
                0 likes
                Last Post soon123
                by soon123
                 
                Started by JustinCross, Yesterday, 09:48 PM
                0 responses
                10 views
                0 likes
                Last Post JustinCross  
                Started by Unsuitable, Yesterday, 06:30 PM
                0 responses
                5 views
                0 likes
                Last Post Unsuitable  
                Started by michaelsh, Yesterday, 04:28 PM
                0 responses
                6 views
                0 likes
                Last Post michaelsh  
                Working...
                X