Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Daily High average over a 10 day Period

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

    Daily High average over a 10 day Period

    I've been attempting to render the daily high exponential average value over ten days. I thought i was close but can't ever seem to get the last or current (most recent) days to render within the calculations which is obviously not very good when looking for the accurate exponential. I am using "US Equities RTH" within the data set and am on a "type" of "day" within the chart. The summary of the script in question is as follows:

    protected override void OnBarUpdate()
    {
    double ExpoHigh = MAX(High, 10)[0];
    }

    Is there anything obviously wrong (I realize this is, most likely, a stupid question).
    It give's me 10 days back skipping the most recent and current day. I'm simply sending the result to Print for now.

    Thanks and sorry to bother,

    AA

    #2
    Hello larkmail,

    Thanks for your post.

    What is the Calculate setting of the script?

    Where are you testing your script? (Live chart with historical data, or Historical data in the strategy analyzer, or Playback with market replay data)

    You mention Exponential average but it looks like you are trying to find the Highest High of the last 10 days including the current day (as it relates to the calculate setting). Can you clarify what you are looking for?


    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Paul, Thanks for the post.

      I'm running via "live chart with historical data" provided by TD.
      I've built a bit more with details commented out (best viewed within the editor).
      protected override void OnBarUpdate()
      {
      //CHART DATA SERIES set to 1 Minute and Loaded 13 Days. I feel it's these data sheets that I may be failing in.
      double DailyHigh0 = CurrentDayOHL().CurrentHigh[0]; //NO ISSUE. Gives me the Current High just fine so long as i'm on a Minute data set.
      double DailyLow0 = CurrentDayOHL().CurrentLow[0]; //NO ISSUE. Gives me the Current Low just fine so long as i'm on a Minute data set.
      double PriorWeek = EMA(PriorDayOHLC().PriorHigh,1)[0] - EMA(PriorDayOHLC().PriorLow,1)[0]; //ISSUE. I must change the indicator to append to a Daily set. I'm a little lost here as i want to have 10 days worth of highs (including the current day but have no idea as to how to collect the data correctly for the calculation). i realize that this only renders the prior days but, strangely, will sometimes skip up to two days. I feel this has something to do with the data set the indicator is appended to or trading hours, etc?
      double ExpAveSpread = EMA(CurrentDayOHL().CurrentHigh,390)[0] - EMA(CurrentDayOHL().CurrentLow,390)[0]; //ISSUE. Will not work if i append the indicator to a Daily set and 100% on the period settings true end results.
      double SpreadLock = (DailyHigh0 - DailyLow0) / 2; //NO ISSUE but lacks the EMAs of the privous days so i tried the following...
      double ComboSpread = (PriorWeek + ExpAveSpread)/2; //ATTEMPT to fudge the two spreads (PriorWeek & ExpAveSpread) to get closer to an accurate EMA highest and lowest over ten days while taking into consideration the current days H/L.

      //Print("Value is " + SpreadLock);
      //Print("Value is " + ComboSpread);
      }

      I'm hoping i've not made this more confusing?

      Thanks for any direction,
      AA

      Comment


        #4
        Hello larkmail,

        Thanks for your reply.

        I am still confused but I think what you really want here is to add a secondary series of daily bars and use that to drive your results based on daily data.

        To add a secondary series you would use the AddDataSeries() method: https://ninjatrader.com/support/help...dataseries.htm

        For example AddDataSeries(BarsPeriodType.Day, 1); // add daily bars tot the script. (Note: this will add only as many days as the primary series (chart data seies) specifies. If you need more days then you would need to extend the number of days to load to accommodate that. Note that Days to load is calendar days so that would include weekends.

        You can then directly pull the Daily high and low values from the daily bars and can access indicator methodson them like EMA(Highs[1], 10)[0] // 10 period EMA of the High data series of the added data series [1]

        In order to be well versed in multi time frame coding, please review this critical section of the help guide: https://ninjatrader.com/support/help...nstruments.htm






        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by bortz, 11-06-2023, 08:04 AM
        47 responses
        1,611 views
        0 likes
        Last Post aligator  
        Started by jaybedreamin, Today, 05:56 PM
        0 responses
        9 views
        0 likes
        Last Post jaybedreamin  
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        19 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        6 views
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        22 views
        0 likes
        Last Post Javierw.ok  
        Working...
        X