Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Synching multiple times frames

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

    Synching multiple times frames

    I am trying to access5 minute bars within an indicator that will run from a tick chart. Below is the code, which compiles fine but generates the wrong results. I believe is has to do with the hma1 = HMA(HA2_C, Period); statement in the OnStartUp() section. I don't believe I have that piece coded correctly such that it synchronizes with the 5 min bars. Can you advise? Thank you

    protected override void Initialize()
    {
    Add(PeriodType.Minute, 5);
    HA2_C = new DataSeries(this);
    }

    protected override void OnStartUp()
    {
    hma1 = HMA(HA2_C, Period);
    hma2 = HMA(hma1, Period);
    hma3 = HMA(hma2, Period);

    }

    protected override void OnBarUpdate()
    {
    if (CurrentBars[0] <= 2 || CurrentBars[1] <= 2) return;

    if (BarsInProgress == 1) // process min chart
    {
    HA2_C.Set((((Opens[1][0] + Highs[1][0] + Lows[1][0] + Closes[1][0]) / 4));
    MyVal = (3 * hma1[0] - 3 * hma2[0] + hma3[0]);
    }

    if (MyVal >= 800) BackColorSeries[0] = risingColor;
    else BackColorSeries[0] = fallingColor;

    }

    #2
    pman,

    That looks like it will synchronize with 5 minute bars currently.

    What issue are you seeing here? Could you possibly show a chart?

    I wrote an indicator that creates indicator objects like what you appear to be trying to do. You might be able to learn how to do it by viewing this.

    Adam P.NinjaTrader Customer Service

    Comment


      #3
      thanks ... but your example doesn't seem to use multiple time frames as mine does. My issue is definitly with my HMA(HA2_C, Period) statement in the OnStartUp section. The HA2_C value is not the same value that is being calculated in the OnBarUpdate section for the 5 min chart (BarsInProgress = 1).Any thoughts?

      Comment


        #4
        Originally posted by pman777 View Post
        thanks ... but your example doesn't seem to use multiple time frames as mine does. My issue is definitly with my HMA(HA2_C, Period) statement in the OnStartUp section. The HA2_C value is not the same value that is being calculated in the OnBarUpdate section for the 5 min chart (BarsInProgress = 1).Any thoughts?
        I did some more testing and discovered that my HMA settings are defaulting to my tick chart, not my 5 min chart (which it should). I set the variables as
        private HMA hma1;
        private HMA hma2;
        private HMA hma3;


        And set them in my code while processing my 5 min bars as :
        hma1 = HMA(HA2_C, Period);
        hma2 = HMA(hma1, Period);
        hma3 = HMA(hma2, Period);


        but when I print them out, I get
        TF test4: hma1 HMA(TF 12-12 (322 Tick),13) hma2 HMA(HMA(TF 12-12 (322 Tick),13),13) hma3 HMA(HMA(HMA(TF 12-12 (322 Tick),13),13),13)

        As you can see, they are set for "322 Tick" which is the chart I'm running. Rather, I want these to reference my 5 minute bars.

        Any ideas?

        Comment


          #5
          I'm going to close out this thread and open another one with a more comprehensive explanation ... thanks!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          578 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          334 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          554 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X