Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to enable autotrailing in condition builder for automated trading

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

    How to enable autotrailing in condition builder for automated trading

    So i have build my first simple SMA auto trading strategy.....works fine.

    But i would like to add a condition, auto trailing....so that when the strategy opens a position....to close it when the auto trailing conditions are met.

    example:

    I would like the autotrailing to trail the actual price and keep a distance of 5 units.
    So if the price reverses more than 5 units, the positions closes....

    Any tips or references to look at?

    I tried messing with the strategy builder wizard....still couldn't figure it out...
    http://www.ninjatrader.com/support/h...sitionStrategy
    Last edited by davedxb; 08-25-2011, 12:33 AM.

    #2
    davedxb, welcome to our forums : on the stops & targets section please add for example the SetTrailStop to your strategy, you can then decide by how much ticks to trail.

    BertrandNinjaTrader Customer Service

    Comment


      #3
      I want to implement this AutoTrail
      http://www.ninjatrader.com/support/helpGuides/HelpGuideV6/helpguide.html?AutoTrail

      Into Auto Trading Strategy....using Wizard..or code...if i have too...


      Maybe this is what i am looking for?
      Last edited by davedxb; 08-25-2011, 03:42 AM.

      Comment


        #4
        Hi Dave, yes if you'd like to call AtmStrategyTemplate in your NinjaScript strategy then you'd need to work directly with the programming code in the NinjaScript editor, a full example is preinstalled with NT under the 'SampleAtmStrategy'.

        BertrandNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          Hi Dave, yes if you'd like to call AtmStrategyTemplate in your NinjaScript strategy then you'd need to work directly with the programming code in the NinjaScript editor, a full example is preinstalled with NT under the 'SampleAtmStrategy'.

          http://www.ninjatrader.com/support/h...gy_methods.htm

          Lovely link! i will go through all the codes and do some testing one by one....thank you...

          Comment


            #6
            Ok...so after alot of practice and reading...my coding skills are much better.

            But i STILL cant get this auto trail to work.

            // Condition set 1
            if (CrossAbove(MACD(12, 26, 9), MACD(12, 26, 9).Avg, 1)
            {
            EnterLong(DefaultQuantity, ");
            }

            What i want is, when it enters long....to follow the market price, auto trail it by 5 ticks.
            So as the market price increase on every bar update....the auto trail will update and keep a distance of 5 ticks from the current market price. This way, if the price goes back down, more than 5 ticks on the next bar, the strategy will exit my long position.

            Any help would be great....

            Comment


              #7
              Dave, that would be simply a command to enter a long position - it would not provide any stop loss or trailing on the position. For calling an ATM template with the AutoTrail setup as needed, please use the AtmStrategyCreate(): http://www.ninjatrader.com/support/h...strategycreate
              BertrandNinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_Bertrand View Post
                Dave, that would be simply a command to enter a long position - it would not provide any stop loss or trailing on the position. For calling an ATM template with the AutoTrail setup as needed, please use the AtmStrategyCreate(): http://www.ninjatrader.com/support/h...strategycreate
                Thanks for the quick response!

                So i created my Auto Trail strategy from the super DOM, just like shown over here:


                And i named my Auto Trail Strategy "myautotrailstats"

                Then, i go back to my code and it should look like this, where if triggered, the code shall call out the strategy i made "myautotrailstats"

                // Condition set 1
                if (CrossAbove(MACD(12, 26, 9), MACD(12, 26, 9).Avg, 1)
                {
                AtmStrategyCreate(OrderAction.Buy, OrderType.Market, 0, 0,
                TimeInForce.Day, GetAtmStrategyUniqueId(), "myautotrailstats",
                GetAtmStrategyUniqueId());
                }

                That didnt seem too hard!!!! taking into account i have not tested it yet! =] Does the above seem correct? Ill try it out on my demo account

                Comment


                  #9
                  Looks good davedxb,

                  Let us know if you see any issues or have any questions.
                  MatthewNinjaTrader Product Management

                  Comment


                    #10
                    Hello Matthew,
                    i've a question about macd conditions:
                    condition1: macd crossing above slow ema (12)
                    condition2: macd crossing below fast ema (26)
                    How can i set these conditions ?

                    Comment


                      #11
                      You would set this up in the Strategy Builder's Condition Builder - http://www.ninjatrader.com/support/h...on_builder.htm

                      For creating cross over conditions, please check into the 7th section from the above link from our helpguide ('How to create a cross over condition').
                      BertrandNinjaTrader Customer Service

                      Comment


                        #12
                        Sorry Bertrand,
                        moved my question to the right forum section. (indicator)
                        Is not a strategy question.

                        Comment


                          #13
                          For an indicator you would need to code this directly in the NinjaScript editor. You can though use the Strategy Wizard to 'view' the code it would generate and copy then sections over to your new indicator.
                          BertrandNinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by usazencort, Today, 01:16 AM
                          0 responses
                          1 view
                          0 likes
                          Last Post usazencort  
                          Started by kaywai, 09-01-2023, 08:44 PM
                          5 responses
                          603 views
                          0 likes
                          Last Post NinjaTrader_Jason  
                          Started by xiinteractive, 04-09-2024, 08:08 AM
                          6 responses
                          23 views
                          0 likes
                          Last Post xiinteractive  
                          Started by Pattontje, Yesterday, 02:10 PM
                          2 responses
                          22 views
                          0 likes
                          Last Post Pattontje  
                          Started by flybuzz, 04-21-2024, 04:07 PM
                          17 responses
                          230 views
                          0 likes
                          Last Post TradingLoss  
                          Working...
                          X