Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Scaling in, Scaling out by differing poritions of total account size

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

    Scaling in, Scaling out by differing poritions of total account size

    To scale out of a position it is necessary first to scale in, using a distinctive designation for each entry position ("long1a", "long1b" etc.) and tying a particular profit target to each discrete entry.

    So it is explained in SampleScaleOut.zip .


    But what if one wishes to scale out in several unequal portions, say, first 20% at Profit Target A, the next 50% at Profit Target B and the rest at the next trade signal?

    In a Forum thread in Dec 08 NinjaTrader Josh suggested that this arrangement is possible but "it would take code" (not by wizard) and only by entering by "account size" and not default quantity.

    Could someone please describe the code?

    For example, enter long XYZon MA crossover for $10,000 worth of shares, exit 20% when a 8% profit target is reach; another 50% when 12% is reached and the remainder on next MA crossbelow.

    Thanks in advance.
    Last edited by tooearly; 08-08-2009, 10:10 PM. Reason: spelling

    #2
    There are several approaches you can take. The simplest could be just as the example states. If you know you want 20% gone at target A, 50% at target B, and the remaining 30% at target C you could just place in your entries at those values.

    $10,000. To keep it simple, let us just say we have 100 shares worth $100 each.

    20% would be 20 shares, 50% = 50 shares, 30% = 30.

    longA = quantity 20
    longB = quantity 50
    longC = quantity 30

    When you are in 8% profit, exit longA which would be an exit of 20%.
    When you hit profit 12%, exit longB which would be an exit of 50% of original quantity.
    Finally, the last exit removes the last positions.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      OK, I see how that works in principle, but isn't it necessary to introduce some calculation or function in the program such that LongA = 20% of total share of account size $XX; LongB = 50% of total shares of account size $XX, and so on?

      In Initialize() of the SampleScaleOut there is just such a function, "SetProfitTarget("Long 1a", CalculationMode.Percent, 0.08); ", although it addresses the target as a percentage of profit since entry, rather than the number of shares as a percentage of total position.

      Is there some function comparable to SetProfitTarget that I could use to SetPortionMarketPosition("Long1a", CalculationMode.Percent,0.2)?

      And would I not then need to assign LongA, LongB, LongC, etc to the value returned by that calculation in Initialize().

      I'm way out of my depth on this Josh, as is probably too painfully obvious to you, so I most appreciate your patience.

      Best regards and thanks for speedy response to earlier query.

      TE

      Comment


        #4
        When you use Percent mode for SetProfitTarget() that is not to say exit 8% of the position, but to say that the profit target is an 8% target.

        If you want to do some math to determine how many shares is 20% you can do that before you place the entries.

        numShares = AccountSize / Close[0] <-- number of shares you can purchase
        numShares * 0.2 <-- 20% of the shares you bought.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          I understand that SetProfitTarget sets the profit target at an 8% profit, in this example.

          I was asking for something analogous to SetProfitTarget that would set the proportion of shares held as percentage of whole.

          The math you offer (numShares * 0.2 = xx shares) looks like just the thing.

          But do I not then have to assign the value of this calculation to LongA, LongB, before entering LongA, LongB, etc.?

          Would this be done in Initialize()?

          Comment


            #6
            You would need to do the calculation before the EnterLong(). You would do it in OnBarUpdate() and not Initialize().
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              OK, thanks. I'll see what I can come up with.

              Appreciate your help!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by helpwanted, Today, 03:06 AM
              1 response
              7 views
              0 likes
              Last Post sarafuenonly123  
              Started by Brevo, Today, 01:45 AM
              0 responses
              7 views
              0 likes
              Last Post Brevo
              by Brevo
               
              Started by aussugardefender, Today, 01:07 AM
              0 responses
              5 views
              0 likes
              Last Post aussugardefender  
              Started by pvincent, 06-23-2022, 12:53 PM
              14 responses
              242 views
              0 likes
              Last Post Nyman
              by Nyman
               
              Started by TraderG23, 12-08-2023, 07:56 AM
              9 responses
              385 views
              1 like
              Last Post Gavini
              by Gavini
               
              Working...
              X