Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

EMA offset

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

    EMA offset

    Hello,
    I would like to build a strategy in Strategy Builder that plots a 21 day EMA line with a 21 day EMA line plotted 24 ticks above and a 21 day EMA line 24 ticks below the first EMA plot. I am hoping to create three paralleled EMA lines, then use them in a cross strategy.

    I have not been able to make the off sets work, can anyone help with this?

    Thank you,
    Joe P..

    #2
    Hello jpatri,
    You can use as below:-
    Code:
    Plot1[0] = ema[0];
    Plot2[0] = ema[0] + 24 * TickSize;
    Plot3[0] = ema[0] - 24 * TickSize;
    Hope it helps!

    Comment


      #3
      Hello s.kinra,
      Thank you very much for your rely to my request!
      Your solution appears to be ninjascript code? I am not able to find (plot) in the strategy builder and I am inept at coding. If there is a Strategy Builder solution you can suggest I would be grateful.
      Thank you,
      jpatri

      Comment


        #4
        Hello jpatri,
        Can you share your strategy so it would be easier to help.

        Comment


          #5
          Hello jpatri,
          I believe there is some limitation of Strategy Builder & you won't be able to get what you're expecting. You can have the plot in Strategy Builder by selecting Add to Chart, but it won't allow you to add ticks to it.
          I am attaching a sample strategy for reference, it will add the three moving averages you're looking for so you can add your logic in this to get working.
          EMAoffset.zip

          Comment


            #6
            Hello s.kinra,
            Thank you for the file, it worked perfectly. It is plotting a center 21 day EMA, with a 21 day EMA 24 ticks above and another 24 ticks below.
            I am now trying to load it into Ninjascript editor to try add the rest of my strategy.
            Thank you!
            jpatri

            Comment


              #7
              Hello Joe P.,

              s.kinra is correct in that while you can apply an offset to an indicator plot for a condition, this does not change the indicator plot on the chart and does not visually add the offset to the indicator with 'Plot on chart' enabled.

              My recommendation would be to create an indicator (and not a strategy) with the code that s.kinra has suggested which has 3 plots and sets these plot values with an offset. Then call this indicator from your strategy in the strategy builder.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Chelsea B.
                Thank you for your input!
                .kinra's solution did work perfectly. I was able to plot the three EMA lines as I wanted.
                Now I am trying to figure out how to attach a cross over function to place a buy order as the price crossed above or below each of the 24 tick extremes. Since I am not a coder, I am working it slowly.

                Thank all for you help with the 24 tick plots, This is a very helpful blog!

                jpatri

                Comment


                  #9
                  Hello jpatri,
                  You can use as below:
                  Code:
                  [INDENT]if(CrossAbove(Close, Ema_upr, 1)[/INDENT][INDENT=2]{
                  // your code here
                  }[/INDENT][INDENT]else if(CrossBelow(Close, Ema_lwr, 1)[/INDENT][INDENT=2]{
                  // Your code here
                  }[/INDENT]
                  Hope it helps!

                  Comment


                    #10

                    Hi all,


                    Firstly, this post has helped me out a lot today! Thank you to jpatri for asking and starting this post, ChelseaB for the suggestion of creating the indicator and s.kinra for the strategy. I have used the strategy s.kinra has provided and created an indicator.


                    So as my way of giving back, here is the EMABands Indicator with an image that I have created based on your work and I am using in my strategy. I hope this helps someone and that they can pay it forward as well.


                    Oh, and a side note, it would be great if NinjaTrader could tune up the Strategy Builder with more options to create without going to the code, for us non-coder types. The Indicator Builder is in dire need of an overhaul also!
                    Attached Files

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by chartchart, 05-19-2021, 04:14 PM
                    3 responses
                    577 views
                    1 like
                    Last Post NinjaTrader_Gaby  
                    Started by bsbisme, Yesterday, 02:08 PM
                    1 response
                    15 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by prdecast, Today, 06:07 AM
                    0 responses
                    3 views
                    0 likes
                    Last Post prdecast  
                    Started by i019945nj, 12-14-2023, 06:41 AM
                    3 responses
                    60 views
                    0 likes
                    Last Post i019945nj  
                    Started by TraderBCL, Today, 04:38 AM
                    2 responses
                    18 views
                    0 likes
                    Last Post TraderBCL  
                    Working...
                    X