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

Scaling up a position

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

    Scaling up a position

    I would like to scale up my position after an initial order is placed. Specifically, I would like to add to the position after the price moves 25 ticks from the initial order, then add another after another 25 ticks. I would also like to move my trailing stops to break even after each additional order.

    Surely there is something in the tutorials on how to do this. Can someone point me in the right direction or at least show me some comparable syntax? Thanks in advance!

    Best regards,

    Dolfan

    #2
    Hello Dolfan,

    To scale in submit a new order in the same direction after the amount of movement is reached.
    To do this, you will need to have the EntriesPerDirection set to 2 or greater to allow for 2 orders to be placed in the same direction.
    http://ninjatrader.com/support/helpG...rdirection.htm

    You can use if (Close[0] + 25 * TickSize > entryOrder.AvgFillPrice) to see if the price has risen 25 ticks since the entryOrder has filled (if your entry is saved to an IOrder).
    http://ninjatrader.com/support/helpG...nt7/iorder.htm
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello Dolfan,

      To scale in submit a new order in the same direction after the amount of movement is reached.
      To do this, you will need to have the EntriesPerDirection set to 2 or greater to allow for 2 orders to be placed in the same direction.


      You can use if (Close[0] + 25 * TickSize > entryOrder.AvgFillPrice) to see if the price has risen 25 ticks since the entryOrder has filled (if your entry is saved to an IOrder).
      http://ninjatrader.com/support/helpG...nt7/iorder.htm
      Chelsea,

      This is not working at all for me so I am certain I am not entering the data correctly. Please advise. Thanks!

      Best regards,

      Dolfan

      protected override void OnBarUpdate()
      {
      // Condition set 1
      if (CrossAbove(Close, SMA(50), 1))
      {
      EnterLong(1, "");
      if (Close[0] + 25 * TickSize > entryOrder.AvgFillPrice);
      if (Close[0] + 50 * TickSize > entryOrder.AvgFillPrice);
      }

      // Condition set 2
      if (CrossBelow(Close, SMA(50), 1))
      {
      EnterShort(1, "");
      if (Close[0] + 25 * TickSize > entryOrder.AvgFillPrice);
      if (Close[0] + 50 * TickSize > entryOrder.AvgFillPrice);

      Comment


        #4
        Hello Dolfan,

        This is not quite how an if statement works.

        Below I am providing you with a link to the help guide on Basic Syntax.
        http://ninjatrader.com/support/helpG...sic_syntax.htm

        The if statement allows you to detect that certain variables have matched certain values. Then you can trigger any action you would like to trigger.

        This is similar to how you are detecting a CrossAbove and CrossBelow. However, I am not certain what you are trying to do. Are you trying to detect a cross after 25 ticks of profit have been made or lost?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Chelsea,

          I am trying to add contracts after the trend reaches 25 then 50 tics in profit.

          The ATM strategies in the Chart Trader allow you to peal off contracts as your position advances. Simply put, I want to do just the opposite. Let me illustrate.

          Let's just say that the target is 75 tics. An open order is initiated and 1 contract is in play. The position moves 25 tics and a second contract is picked up with 2 contracts now in play. The position moves another 25 tics and a third contract is picked up with 3 total contracts now in play. The target of 75 tics is hit and the profit is taken. Contract price is $10 thus;

          1st contract moves total of 75 tics = $750
          2nd contract moves total of 50 tics = $500
          3rd contract moves total of 25 tics = $250
          Total profit realized = $1500
          Initial trailing stop set @ 25 tics or $250
          Risk/reward = 1:6

          versus the current limitations of the Chart Trader ATM capabilities

          3 contracts bought up front
          1st contract sold @ 25 tics = $250
          2nd contract sold @ 50 tics = $500
          3rd contract sold @ 75 tics = $750
          Total profit realized = $1500
          Initial trailing stop set @ 25 tics or $750
          Risk/reward = 1:2

          Add in a trailing stop that moves to average entry every time a contract is added and all you need is the initial move to 25 tics and the WORST that can happen is a break even position for the trade. This method is less speculative, takes less risk up front and takes advantage of trend runs.

          I hope this is clear now. Let me know it it is not. Thanks!

          Best regards,

          Dolfan

          Comment


            #6
            Hello Dolfan,

            In this case, you will not want to nest the if statements.

            Instead, you would want to check the position is long and then check that the close is greater than the Position.AvgPrice plus 25 ticks.

            If true, call EnterLong() again for an additional order in the action block of the if statement.

            The EntriesPerDirection will need to be set to 3 or higher to get 3 entry orders in the same direction.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              would that be in a separate set or in the same set?

              Comment


                #8
                Hello Dolfan,

                These would be non-nested separate condition sets.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Chelsea,

                  Thank you so much in your assistance in this. It seems to be working in back testing so I will now test it in market replay before live in my SIM account.

                  One more thing, how do I get my trailing stop to move up to the average open position each time a contract is added? This is not evident in the strategy wizard.

                  Best regards,

                  Dolfan

                  Comment


                    #10
                    Hello,
                    This would not be possible within the Strategy Wizard.
                    To have your stops update based off of when certain orders are filled you would need to put the code to move your stops to breakeven within the OnExecution() event method which is only available with custom programming. For more information on the OnExecution() event method please see the following link: http://ninjatrader.com/support/helpG...nexecution.htm
                    Cody B.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_CodyB View Post
                      Hello,
                      This would not be possible within the Strategy Wizard.
                      To have your stops update based off of when certain orders are filled you would need to put the code to move your stops to breakeven within the OnExecution() event method which is only available with custom programming. For more information on the OnExecution() event method please see the following link: http://ninjatrader.com/support/helpG...nexecution.htm
                      Cody,

                      I had to break into the code anyhow so this is not a problem. I will take a look at this link and get back to you if I have further questions. Thanks!

                      Best regards,

                      Dolfan

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by KennyK, 05-29-2017, 02:02 AM
                      3 responses
                      1,281 views
                      0 likes
                      Last Post NinjaTrader_Clayton  
                      Started by AttiM, 02-14-2024, 05:20 PM
                      11 responses
                      184 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Started by fernandobr, Today, 09:11 AM
                      1 response
                      3 views
                      0 likes
                      Last Post NinjaTrader_Erick  
                      Started by timmbbo, Today, 08:59 AM
                      1 response
                      3 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Started by itrader46, Today, 09:04 AM
                      1 response
                      6 views
                      0 likes
                      Last Post NinjaTrader_Clayton  
                      Working...
                      X