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 cre8able, Today, 03:20 PM
      1 response
      9 views
      0 likes
      Last Post cre8able  
      Started by fiddich, Today, 05:25 PM
      0 responses
      3 views
      0 likes
      Last Post fiddich
      by fiddich
       
      Started by gemify, 11-11-2022, 11:52 AM
      6 responses
      804 views
      2 likes
      Last Post ultls
      by ultls
       
      Started by ScottWalsh, Today, 04:52 PM
      0 responses
      4 views
      0 likes
      Last Post ScottWalsh  
      Started by ScottWalsh, Today, 04:29 PM
      0 responses
      7 views
      0 likes
      Last Post ScottWalsh  
      Working...
      X