Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy + ATM?

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

    Strategy + ATM?

    Hi,

    I would like to set a strategy so that when an event occurs (20/50 crossover) an order is triggered that matches my ATM strategy which is the following:

    1. limit order with +8 target and -6 stop
    2. break-even set to +1 when price is at +3
    3. at +4 ticks from signal, trailing stop is triggered

    Any and all help would be greatly appreciated. Thanks in advance.

    #2
    Hello,

    I suggest starting here:


    and:


    Also, start with the SampleMACrossOver strategy that comes with NT by default since it already has a crossover trigger coded within it.

    Then give it a try and post your code for assistance.
    DenNinjaTrader Customer Service

    Comment


      #3
      Ben, thank you for getting back to me. Please bear in mind that I do not speak code and was hoping to do this all through the wizard. I have come up with the following where "ES 1" is the name of my current ATM Strategy:


      // Condition set 1
      if (CrossAbove(EMA(20), EMA(50), 1))
      {
      AtmStrategyCreate(Action.Buy, OrderType.Limit,
      0, 0,
      TimeInForce.Day, GetAtmStrategyUniqueId(),
      "ES 1",
      GetAtmStrategyUniqueId());
      }
      }
      #region Properties
      [Description(
      "FAST")]
      [Category(
      "Parameters")]
      publicint FAST
      {
      get { return fAST; }
      set { fAST = Math.Max(1, value); }
      }
      [Description(
      "SLOW")]
      [Category(
      "Parameters")]
      publicint SLOW
      {
      get { return sLOW; }
      set { sLOW = Math.Max(1, value); }
      }
      #endregion
      }
      }

      Thanks - Dave

      Comment


        #4
        Hello,

        Sorry, I didn't realize you were using the Wizard. You can do #1 but you can't do the second two without custom programming. Here are two screen shots that show the first item in the Wizard.
        Attached Files
        DenNinjaTrader Customer Service

        Comment


          #5
          Ben,

          My mistake. I forgot to mention it. Earlier, you sent me a link stating that you can set an automated trading variable (like a 20/50 crossover) to activate an ATM strategy (thank you for that, by the way). Unfortunately, at least for me, the directions on how to do that aren't clear. Does the code that I've posted accomplish what I want? Am I missing something? A point in the right direction would be an enormous help.

          Thanks.

          Comment


            #6
            Hello,

            The code you posted will create an ATM strategy using a previously saved ATM strategy given a cross over condition that occured one bar pervious.
            DenNinjaTrader Customer Service

            Comment


              #7
              So it works? Oh my God I'm a coding genius! And if I want my ATM strategy to execute upon the following:

              20/50 cross above and below
              20/200 cross above and below
              50/200 cross above and below

              Can I do that in the same Strategy or do I have to set them each up separately?

              This is an enomous help, Ben. Thank you.

              Comment


                #8
                Hello,

                Glad to help! I recommend renaming the SampleMACrossOver strategy and inserting your condition and order placement code in it. Get it to work within this strategy first then add and modify your other conditions until it works. You may need to debug it. If you need help debugging please visit this link:
                DenNinjaTrader Customer Service

                Comment


                  #9
                  Morning Ben,

                  I was about to continue using the link you sent but unfotunately, the code I posted is not working. Is there something wrong with it?

                  Thanks.

                  Comment


                    #10
                    dsraider, please post the code you're currently working with so we can take a look - thanks!
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      // Condition set 1
                      if (CrossAbove(EMA(20), EMA(50), 1
                      ))
                      {
                      AtmStrategyCreate(Action.Buy, OrderType.Limit,
                      0, 0
                      ,
                      TimeInForce.Day, GetAtmStrategyUniqueId(),
                      "ES 1"
                      ,
                      GetAtmStrategyUniqueId());
                      }
                      }
                      #region
                      Properties
                      [Description(
                      "FAST"
                      )]
                      [Category(
                      "Parameters"
                      )]
                      publicint
                      FAST
                      {
                      get { return
                      fAST; }
                      set { fAST = Math.Max(1
                      , value); }
                      }
                      [Description(
                      "SLOW"
                      )]
                      [Category(
                      "Parameters"
                      )]
                      publicint
                      SLOW
                      {
                      get { return
                      sLOW; }
                      set { sLOW = Math.Max(1
                      , value); }
                      }
                      #endregion
                      }
                      }

                      It would not let me post the entire section so hopefully this is the relevant part. All I am looking to do is have an automated strategy that signals a pre-saved ATM Strategy once a certain condition is met (20/50 cross).

                      Thanks again, Ben.

                      Comment


                        #12
                        Please make sure you submit the entry limit order at a valid price, yours is 0 in the code (right after the OrderType.Limit).

                        For a complete sample how to achieve what you want, I'd suggest to review the SampleAtmStrategy installed per default with your NinjaTrader installation.
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          Well, the good is I think it worked, even with 0 as the limit price - it seems to just place a limit order at the current market price.

                          The bad news is I decided to set calculate on bar to false after, which resulted in several hundred orders and now my computer freezes whenever I try to log on. Is there a way to delete all orders and strategies without connecting so that I may get my computer back when I connect???

                          Thanks.

                          P.S. Drinks are on me.

                          Comment


                            #14
                            dsraider,

                            When does it freeze? In the NT splash screen? What does it say for the status on the splash screen? If it is trying to process your trades during the splash screen you can try ctrl+alt+del to abort the process and close NT. Then reopen NT and it should not try to redo it. At this point in time you may want to reset your database to ensure nothing goes wrong. Go to Tools->Options->Misc->Reset DB.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Hi Josh,

                              EVERYTHING in NT freezes the second I connect to AMP. If I reset the database, will I lose the custom Automated Strategies I've created? I'm not sure I could reprogram them if you paid me. By the way, I did this in the simulator and not in the live program. It's the only good decision I've made all day.

                              Thanks.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by jaybedreamin, Today, 05:56 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post jaybedreamin  
                              Started by DJ888, 04-16-2024, 06:09 PM
                              6 responses
                              18 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by Jon17, Today, 04:33 PM
                              0 responses
                              1 view
                              0 likes
                              Last Post Jon17
                              by Jon17
                               
                              Started by Javierw.ok, Today, 04:12 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post Javierw.ok  
                              Started by timmbbo, Today, 08:59 AM
                              2 responses
                              10 views
                              0 likes
                              Last Post bltdavid  
                              Working...
                              X