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.

    http://www.ninjatrader.com/support/f...d=4&linkid=535
    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 twitch251, Today, 05:14 PM
          0 responses
          1 view
          0 likes
          Last Post twitch251  
          Started by robforee2, Today, 05:07 PM
          0 responses
          1 view
          0 likes
          Last Post robforee2  
          Started by blar58, Today, 03:16 PM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Melissa  
          Started by alcorr247, Today, 02:52 PM
          2 responses
          7 views
          0 likes
          Last Post robforee2  
          Started by Radano, Today, 02:30 PM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_ChrisL  
          Working...
          X