Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Setting ATM Quantities

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

    Setting ATM Quantities

    Hi Guys. I have an ATM strategy question. I'm using this code to create an ATM strategy buy order:

    PHP Code:
    if (DrawObjects["T3"]==null){AtmStrategyCreate(Cbi.OrderAction.BuyOrderType.Limit,  GetCurrentBid(), 0,TimeInForce.GtcorderId1atmnameatmStrategyId1);} 
    So today I started trying to apply a futures ATM strategy to a stock ATM strategy and got into some problems. The picture shows calling the strategy to buy 100 apple shares with two targets. The problem as you can see on the chart is once the limit order is set it is set to buy 51 shares instead of 100. Then once it fills it has 1st target of 50 and second target with the 1. I'm sure it is something simple.

    Any ideas on this one?

    Thanks in advance
    DJ
    Attached Files

    #2
    Hello,

    Thanks for the note.

    Appears you got a part fill, as you were only filled with 51 contracts. You were not actually 100 contracts long therefor, you didn't have the full 50 target 1 and 50 target 2 QTY's.

    NinjaTrader will submit and modify the stops as you get filled so that you never have a position unprotected, even if you get part filled.

    -Brett

    Comment


      #3
      Thanks Brett, I don't think a partial fill was the issue because I was getting 51 all the time. I realized I'd done something else which had caused some problem with the original ATM strategy so fixed now. I have a another issue though. I'm trying to calculate a reward $ figure based on the type of instrument being a future or a stock.

      For futures I use this formula which works well:

      PHP Code:
      double Reward2TMath.Round(((reward1+reward2) * Instrument.MasterInstrument.PointValue), 2MidpointRounding.AwayFromZero); 
      The problem is what do I do for stocks? For example if I buy 100 shares of apple and the target is $1 above the current price then the reward should show $200 but is showing me $2. So I think I need to replace the PointValue part for futures with something else for stocks but could not see any other option...

      Thanks
      DJ

      Comment


        #4
        Hello,

        The point value is fine as point value is just 1 for stocks.

        Most likely is the rounding in that case.

        -Brett

        Comment


          #5
          Hi Brett, here is another separate question as well. I've attached the AMT strategy. What I want to do is use the same template for multiple instruments but change the quantity for different instruments. For example I've put this in the initialize section.

          PHP Code:
          if (Instrument.MasterInstrument.Name == "AAPL")
                      {    
                      
          DefaultQuantity 300;
                      }    
                      
                      if (
          Instrument.MasterInstrument.Name == "CLF")
                      {    
                      
          DefaultQuantity 200;
                      } 
          What this should do is then buy 300 shares of APPL or 200 shares of CLF whichever is being purchased. There are two issues:

          1. The first problem is if I run this and buy AAPL it isn't buying 300 but only 100 as per the strategy.
          2. The second issue is even if it had purchased 300 AAPL shares how do I tell it the targets should be split into two so would be 150 for each target?

          Thanks in advance
          DJ
          Attached Files

          Comment


            #6
            Hello,

            1) I would set this in OnStartUp(). As in Initialize() it can be overridden by the user.

            2) This is determined by the strategy, you would need an ATM strategy setup for each stock and each QTY level unfortunately..

            -Brett

            Comment


              #7
              Originally posted by NinjaTrader_Brett View Post
              Hello,

              The point value is fine as point value is just 1 for stocks.

              Most likely is the rounding in that case.

              -Brett
              Thanks Brett, I see that is the problem. So how do I tell it to multiply it by the number of shares purchased? Otherwise all it is doing is saying take the target price of $570 less current price $569 = $1 x 1 for the point value =$1. To get the reward I need to tell it to multiply by the shares purchased. If it is 200 shares then the reward should be $200.

              Thanks
              DJ

              Comment


                #8


                This should do the trick.

                Comment


                  #9
                  Hi Brett, thanks this will help me once I'm in the trade. Let me explain further. Here is a chart of oil. I have programmed it so as I move the stop and target lines up and down it will calculate the risk/reward before entering the trade so I can see my risk and return prior to entry (see top left table). I need to do this for stocks as well so not sure why it doesn't work the same. It is something to do with this point value part as that's were it is all turning to custard.

                  I think what I need to do is access is the Qty for target 1 and Qty for target 2 in the ATM Strategy parameters section. I don't why this is working differently from the way futures are doing it.

                  Cheers
                  DJ
                  Attached Files

                  Comment


                    #10
                    To clarify, you need to computer while the previous trade is going? Wouldn't you only be computing this before entry or will you be doing this after entry?

                    -Brett

                    Comment


                      #11
                      Hi Brett, sorry for the confusion. There is no trade going and it's only before entry. So as I move the lines around the Reward is constantly updating in the table

                      Once in the trade it's fixed based on the before entry calculation.

                      I just tried out this here and notice it only works once you are in the position and not prior to entering the position.

                      PHP Code:
                      {DrawTextFixed("markettype22""Q: "+GetAtmStrategyPositionQuantity(atmStrategyId1).ToString("N0"), brPositionColor.BlacktextFontHugeColor.WhiteColor.Lime10);} 
                      The issue I guess is what makes this line so special in that it works on futures and not on stocks?

                      double Reward2T= Math.Round(((reward1+reward2) * Instrument.MasterInstrument.PointValue), 2, MidpointRounding.AwayFromZero);


                      Cheers
                      DJ
                      Last edited by djkiwi; 06-15-2012, 01:40 PM.

                      Comment


                        #12
                        Hello,

                        Thanks. Correct will only work after you are in the trade.

                        Lastly the difference here is still the rounding. Ir probably works on XXXX.XX instruments like the ES but not XX.XX instruments might be the missing factor.

                        -Brett

                        Comment


                          #13
                          Hi Brett, now I feel like a fool. Because it's a stock it's in denominations of $1 so the Point Value is incorrect for stocks. So what I need to do is multiply it by 100. So I think you guys need to say if it is a stock set the point value to 100 not 1.

                          I have a chart where you can see it working correctly.

                          Here is the code:

                          PHP Code:
                          double Reward2TMath.Round((((reward1+reward2) * Instrument.MasterInstrument.PointValue)*100), 2MidpointRounding.AwayFromZero); 
                          Cheers
                          DJ
                          Attached Files

                          Comment


                            #14
                            Hello,

                            The difference is a point for stocks is 1 cent.

                            A point for the ES is 4 ticks.

                            Not really a right or wrong way to do it but we wouldn't change it now.

                            -Brett

                            Comment


                              #15
                              Hi Brett, yes you are right 1 cent. I suggest Ninjatrader consider changing it because it is simply incorrect as it stands. All stocks are 1 cent so the point value should be 100 not 1 for all stocks.

                              Bear in mind you wouldn't need point value at all if all futures were the same denomination.

                              In any case thanks for your patience on this issue. Much appreciated.

                              Cheers
                              DJ
                              Last edited by djkiwi; 06-15-2012, 02:58 PM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by frankthearm, Today, 09:08 AM
                              9 responses
                              32 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by NRITV, Today, 01:15 PM
                              2 responses
                              9 views
                              0 likes
                              Last Post NRITV
                              by NRITV
                               
                              Started by maybeimnotrader, Yesterday, 05:46 PM
                              5 responses
                              26 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by quantismo, Yesterday, 05:13 PM
                              2 responses
                              20 views
                              0 likes
                              Last Post quantismo  
                              Started by adeelshahzad, Today, 03:54 AM
                              5 responses
                              33 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Working...
                              X