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

Getting the EMA from two different time frames?

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

    Getting the EMA from two different time frames?

    How to I get the EMA (or other indicator value) from two different time frames?

    Say I'm running my strategy, in a 10 minute chart. I'd like to get the EMA(20) value from the 10 minute, 5 minute, and 1 minute charts. How to do? Thanks

    #2
    Hello timmbbo,

    Thank you for your note.

    To calculate the values of an indicator for a time series which is not the primary series, you would have to add additional data series, for example,

    Code:
    AddDataSeries(BarsPeriodType.Minute, 5);
    AddDataSeries(BarsPeriodType.Minute, 10);
    See AddDataSeries section of our helpguide,


    Then you should add current bar checks to make sure each series has enough bars, for example,

    Code:
    if(CurrentBars[0] <20 || CurrentBars[1]<20  || CurrentBars[2]<20) return;
    See more about current bar checks at "Make sure you have enough bars in the data series you are accessing" reference example,


    Then you can set the value of the indicator to a plot or a variable or use in your conditions.

    I have attached a sample strategy which adds 2 additional data series and sets plot values equal to the simple moving average of the primary, secondary, and third data series.

    Please let us know if you need further assistance.
    Attached Files
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by timmbbo View Post
      How to I get the EMA (or other indicator value) from two different time frames?

      Say I'm running my strategy, in a 10 minute chart. I'd like to get the EMA(20) value from the 10 minute, 5 minute, and 1 minute charts. How to do? Thanks
      Here's a strategy that simply adds a secondary series and prints the SMA(20) from the two different series on each tick. This is what helped me wrap my head around it. Link

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by rdtdale, Today, 01:02 PM
      1 response
      4 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by alifarahani, Today, 09:40 AM
      3 responses
      16 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by RookieTrader, Today, 09:37 AM
      4 responses
      19 views
      0 likes
      Last Post RookieTrader  
      Started by PaulMohn, Today, 12:36 PM
      0 responses
      9 views
      0 likes
      Last Post PaulMohn  
      Started by love2code2trade, 04-17-2024, 01:45 PM
      4 responses
      41 views
      0 likes
      Last Post love2code2trade  
      Working...
      X