Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MasterInstrument and Timeframe

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

    MasterInstrument and Timeframe

    Hi Guys, I use this masterinstrument piece quite a bit. For example:

    if Instrument.MasterInstrument.Name ="TF"
    {
    play alert
    }

    What I'm trying to do now is add a timeframe in without using barsarray. For example if the instrument on the chart is TF AND the chart timeframe is 30 minutes. eg:

    if Instrument.MasterInstrument.Name ="TF" AND 30 Min timeframe
    {
    play alert
    }


    Any ideas on how to do this?

    Thanks
    DJ

    #2
    djkiwi,

    Here is an example of some code I have that may be helpful for you. It is in Initialize().

    Code:
    switch (BarsPeriod.Id)
    			{
    				case PeriodType.Day:
    				case PeriodType.Week:
    				case PeriodType.Month:
    				case PeriodType.Year:
    				case PeriodType.Minute:
    				case PeriodType.Second:
    					Add(Symbol2, BarsPeriod.Id, BarsPeriod.Value);
    					supportedBarsPeriodType = true;
    					break;
    				default:
    					break;
    			}
    Its not recommended to use Barsperiod.Id in initialize(), however this code works in a spread indicator I have.
    Last edited by NinjaTrader_AdamP; 03-18-2012, 05:07 PM.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Barsperiod

      Thanks Adam, I see the answer is in this barsPeriod function which I'd never seen. In any case I'm applying the following code in an indicator in the onbarupdate section on a 10 renko chart and included the following:

      if (BarsPeriod.BasePeriodType == PeriodType.Renko && BarsPeriod.Value == 10)
      {
      DrawTextFixed("demsup11","Reg Divergence", trPosition,Color.Black,textFontMed, Color.White, Color.Red, 10);
      }

      The problem is nothing draws. Even if I remove the BarsPeriod.Value ==10 nothing works. Do I have this syntax correct because that is what it shows in the manual?

      Thanks in advance
      DJ

      Comment


        #4
        djkiwi,

        Is this being used in OnBarUpdate() or Initialize()?

        What is trPosition set to?
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          Barsperiod

          Hi Adam, I put this little indicator together and would be grateful if you could check it on a 5 renko chart. It doesn't work for me so I think I'm doing something wrong with the syntax somewhere.

          Thanks in advance
          DJ
          Attached Files

          Comment


            #6
            djkiwi,

            Please use BarsPeriod.Id == PeriodType.Renko
            Adam P.NinjaTrader Customer Service

            Comment


              #7
              BarsPeriod

              Thanks Adam, I had already tried that one and didn't work either. I tried it again and still doesn't work. Any other ideas on it?

              Cheers
              DJ

              Comment


                #8
                djkiwi,

                The following works for me.

                Code:
                if (BarsPeriod.Id == PeriodType.Renko && BarsPeriod.Value == 5)
                			{
                				DrawTextFixed("InfoPanel3","Reg Divergence", trPosition,Color.Black,textFontMed, Color.White, Color.Red, 10);
                			}
                Please see the attached image.
                Attached Files
                Adam P.NinjaTrader Customer Service

                Comment


                  #9
                  Better Renko

                  Hi Adam, you are quite right it does work with the Renko. I'm actually using a BetterRenko bar. I've never had to worry about a reference being different applied to a Renko or Better Renko so this is the first time it's been a problem. In fact I've been referencing BetterRenko with multitimeframes and had no problems eg:

                  AddRenko("ES 06-11", 2, MarketDataType.Last);

                  In any case I do not see BetterRenko as an option for barsperiod. Any idea on how to get it to reference a BetterRenko bar type chart?

                  Thanks
                  DJ

                  Comment


                    #10
                    djkiwi,

                    I would suggest printing out the values to your output window to see what to expect.

                    Print(BarsPeriod.Id.ToString()+" "+BarsPeriod.BasePeriodType.ToString()+" "+BarsPeriod.Value.ToString());

                    This will allow you to figure out what to compare to using the Tools > Output window.
                    Adam P.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi Adam, sometimes I wonder if there is anything you guys don't know about ninjatrader. I tried what you said and it popped up with Custom4 and minute 5 and so I changed it from renko to

                      BarsPeriod.Id == PeriodType.Custom4

                      and it worked perfectly.

                      Thanks again
                      DJ

                      Comment


                        #12
                        djkiwi,

                        Our training period is quite long, so we do cover a lot with NinjaTrader.

                        Anyway, I am happy you have resolved your issue.

                        Please don't hesitate to contact us should you require additional assistance.
                        Adam P.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        633 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        364 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        105 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        567 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        568 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X