Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

distance between 2 EMAs

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

    distance between 2 EMAs

    Hello. Trying to restrict trades from entering if the 21 is too far from the 50. Or could be worded the other way. Only enter trade if the 21 is within a certain amount of ticks from the 50. Either way. Can it be done on the strategy builder? Thank you

    #2
    Hi Touch-Ups, thanks for posting. You would need to be able to do some math operations on the value of each EMA object, so unfortunately that would not be possible in the builder. You would need to check:

    Code:
    if(Math.Abs((EMA(21)[0]-EMA(50)[0])/Bars.Instrument.MasterInstrument.TickSize) > SomeTickValue)
    {}​


    Kind regards,
    -ChrisL

    Comment


      #3
      Well... I ran across EMAticksaway indicator from here:

      Hello, I have been looking through the huge list of indicators to see if I can find one that measures the distance from EMA to the current candle. For example, it asks for what EMA you want let's say EMA13 for starters, and then it would always tell you how man ticks away from that EMA the closest part of the current candle is.


      It would be perfect, but I can not get it to work in the strategy analyzer. I don't get any errors. It just will not allow any trades when I run it.

      Comment


        #4
        Never mind. Got the price from ema to work. That is not what I wanted. Got myself confused messing with this so much. Really want the ema distance thing, but if it can't be done, then you have answered my question. thanks

        Comment


          #5
          Hi Touch-Ups, thanks for the follow up.The indicator was not adding a Plot that strategies need to read data. I added a Plot object to it called "DifferenceValue". It is now useable in a strategy.

          Kind regards.
          Attached Files

          Comment


            #6
            If you set the input series to an EMA you can take the difference of two EMA objects e.g.



            Kind regards,
            -ChrisL

            Comment


              #7
              You can work with the distance between moving averages in the strategy builder. It requires using the "offset" for the math of subtracting one from the other and it would require using the "points" instead of a tick reference.

              I've attached an example using the MES 12-22, which has 4 ticks per point. In the example I created the conditions to look for a spread of less than or equal to +/- 1 (4 ticks) and when true to color the background. You use the +/- because sometimes one moving average is above or below the other. As you can see it is showing correct functionality.

              Click image for larger version

Name:	StrategyBuilderEMAspread.png
Views:	558
Size:	121.7 KB
ID:	1219056


              Here is a link to the strategy builder help guide on Offset: https://ninjatrader.com/support/help...setAnItemValue

              It would also be possible to convert to ticks however it is more complex and involves storing values in custom series in the strategy builder.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by mlarocco, 06-20-2025, 11:12 AM
              1 response
              46 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by futurenow, 12-06-2021, 05:49 PM
              19 responses
              1,025 views
              0 likes
              Last Post Redders
              by Redders
               
              Started by mathfrick2023, 05-08-2025, 12:51 PM
              8 responses
              139 views
              0 likes
              Last Post Yogaman
              by Yogaman
               
              Started by several, 04-22-2025, 05:21 AM
              1 response
              296 views
              0 likes
              Last Post Lukasxgtx  
              Started by NTEducationTeam, 06-12-2025, 02:30 PM
              0 responses
              54 views
              0 likes
              Last Post NTEducationTeam  
              Working...
              X