Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Best way to implement this simple automated ES hedging strategy

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

    Best way to implement this simple automated ES hedging strategy

    Let's say that I am currently short 1 contract of ES @ 2100.

    What is the easiest way to instruct Ninjatrader to ALWAYS go to 0 (i.e. +1 contract ES) when the price hits 2014, and ALWAYS go back to -1 when the price drops below 2100 again?

    In this case, market orders would be fine with me.

    But the key is that this trade could reverse itself a hundred times in a week without me touching a button (just simply obeying the rule of always short 1 contract when at or under 2100 & then always back to no net position when at or over 2014, until I'm ready to turn it off.)

    #2
    Hello,

    If this is the entirety of the setup you are looking for, then you should be able to accomplish this by calling EnterLong() and EnterShort() at the appropriate price points. You can compare Close[0] to your trigger prices, then call the appropriate entry method.

    A convenient thing about EnterLong() and EnterShort() is that they will automatically close an open position in the opposite direction. So when you are currently short, and call EnterLong(), it will close the short position, then open a long position.

    Please let me know if I can assist further.
    Dave I.NinjaTrader Product Management

    Comment


      #3
      I appreciate this info, but I am pretty new to autotrade setup, what is the easiest way to program this simple system, "calling Enter Long() and Enter Short() at the apropriate price points. I am looking to do this as well, selling at resistance and buying at support, what do you suggest to get this started?

      Comment


        #4
        Hello,

        The reference sample below should get you started with trading support/resistance crossovers:

        http://www.ninjatrader.com/support/f...ead.php?t=3224

        You might also take a look at the SampleMACrossover script that comes pre-loaded with NinjaTrader. That script shows the mechanics of trading crossovers, and you will only need to define your support and resistance levels to modify it for your purposes.

        If you would like, I'll be happy to provide a list of helpful resources to help you get up and running quickly with NinjaScript.
        Dave I.NinjaTrader Product Management

        Comment


          #5
          I am new to Ninjatrader, I have been using TOS but it does not have a Auto Trade function. I am playing with the demo and what I want to have is a simple moving average of 4 and 7, when they cross say 4 over 7, an trade is made with a buy, then when 7 crosses back over 4 I want to sell and do a reverse sell at the same time and then when 4 crosses back over 7 it will buy.

          Can this be done and how would I get started. I have found some code from above but have no clue how to start writing to import into NT

          Thanks

          Comment


            #6
            Hello bughatti, and thank you for your question.

            I have prepared a short screencast in which I go through the strategy wizard and set up a strategy like the one you were requesting.

            Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.


            The best way to begin learning ninjascript is to use the strategy wizard. with the strategy wizard you can setup conditions and variables and then see the generated code in the ninjascript editor by clicking the view code button.


            I am proving a link to a pre-recorded 'automated strategy development webinar' video for you to view at your own convenience:


            Download NinjaTrader FREE at http://www.ninjatrader.comThis video is a recording of our live "Automated Strategy Development Level 1" webinar covering the to...


            You can find that and many more training webinars on the NinjaTrader 7 training channel,


            Recordings of our daily NinjaTrader product training webinars.



            For information on running strategies please visit the following link: http://www.ninjatrader.com/support/h...strategies.htm
            Jessica P.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by bughatti View Post
              I am new to Ninjatrader, I have been using TOS but it does not have a Auto Trade function. I am playing with the demo and what I want to have is a simple moving average of 4 and 7, when they cross say 4 over 7, an trade is made with a buy, then when 7 crosses back over 4 I want to sell and do a reverse sell at the same time and then when 4 crosses back over 7 it will buy.

              Can this be done and how would I get started. I have found some code from above but have no clue how to start writing to import into NT

              Thanks
              Look at the SampleMACrossover strategy that ships with NT. It is exactly what you are asking to see.

              Comment


                #8
                Jessica, thanks for the information. I was able to follow it and setup what I needed. It worked just like you stated but turned out to not be what I want. I used your guide to try a different method using EMA 8, 14 and 26. Since I have 3 EMA I used 2 conditions, when EMA 8 crosses above 14 and a second condition when EMA8 crosses above 26. I did not set the opposite Set 2 yet because I just wanted to see if it would hit the indicators correctly.

                Problem is when I setup EMA 8, 14 and 26 on the chart and see 8 crossing above 14 then 26 it does not match my Strategy at all.

                Comment


                  #9
                  I would like to second koganam's suggestion. In fact, it is the strategy used in the Training Channel webinar introducing you to NinjaScript, which I will provide a link for here.

                  Dive into manipulating C# code from within an unlocked NinjaScript strategy using the NinjaScript Editor.NinjaTrader 7 is an award winning end to end online ...


                  If you would like to see where the indicators are being hit, I would recommend, from the screen where you set up the actions to perform when a crossover is detected (the 4th screen), selecting add -> Drawing -> Dot . I would recommend a red dot for one of the crosses, and a blue dot for the other. Select "OK" after configuring each dot.

                  Rather than adding indicators to your chart manually, you can also have the indicators you are using to calculate crossovers plotted directly on your chart. You can do this on the same screen, by setting each indicator's "Plot on Chart" property to "True". I have included a picture of this setting.
                  Attached Files
                  Jessica P.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by arvidvanstaey, Today, 02:19 PM
                  4 responses
                  11 views
                  0 likes
                  Last Post arvidvanstaey  
                  Started by samish18, 04-17-2024, 08:57 AM
                  16 responses
                  60 views
                  0 likes
                  Last Post samish18  
                  Started by jordanq2, Today, 03:10 PM
                  2 responses
                  9 views
                  0 likes
                  Last Post jordanq2  
                  Started by traderqz, Today, 12:06 AM
                  10 responses
                  18 views
                  0 likes
                  Last Post traderqz  
                  Started by algospoke, 04-17-2024, 06:40 PM
                  5 responses
                  47 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Working...
                  X