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

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 traderqz, Today, 12:06 AM
          8 responses
          14 views
          0 likes
          Last Post traderqz  
          Started by SightCareAubetter, Today, 12:50 PM
          0 responses
          1 view
          0 likes
          Last Post SightCareAubetter  
          Started by Mongo, Today, 11:05 AM
          4 responses
          14 views
          0 likes
          Last Post Mongo
          by Mongo
           
          Started by Skifree, Today, 03:41 AM
          5 responses
          13 views
          0 likes
          Last Post Skifree
          by Skifree
           
          Started by traderqz, Yesterday, 09:06 AM
          5 responses
          35 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X