Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Mutiple Time Frame Indicators - Best Way?

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

    Mutiple Time Frame Indicators - Best Way?

    What is the best way to use an indicator with a different time frame on a chart? I am trying to use an indy retrieving values from the 2 minute chart on the 5 minute chart... I am doing this by adding a 2 minute data series and then adding the 2 minute data series indicator to the 5 minute chart... this causes scaling issues for one (which I have fixed pretty well... thinking perhaps there is an easier way? is there code that could be added to the indy so it works more efficiently without scaling issues or needs of having to add two data series to charts for opening the chart template?

    thanks for any help with this!
    R.T.

    #2
    Hello tshirtdeal,

    Thank you for your post.

    You can use the Add() method in an indicator to add the second data series without ti appearing on the chart.

    Please see our NinjaScript resource on Multi-Time Frame & Instruments for more information:

    MatthewNinjaTrader Product Management

    Comment


      #3
      Thanks Mathew...

      So if I put
      Add(PeriodType.Minute, 2);
      Into the code then when I open that indy on any chart it will be producing the values of the 2 minute chart?

      Thanks for the quick help!
      R.T.

      Comment


        #4
        Hello,

        You would need to custom add these indicators to your script too. If you do not wish to recreate your indicators, your best bet would be following the steps you outlined in your first post.

        I'm also including a recent thread which discusses how to Add an SMA which is calculated from a second data series via NinjaScript:

        MatthewNinjaTrader Product Management

        Comment


          #5
          Thanks Matthew,

          so I have to call the indicator and also add all the plots with the BarArray? or can I just call the indicator and values with the Add script?

          Thanks for any help!

          Comment


            #6
            tshirtdeal,

            I am responding on behalf of Matthew,

            In the forum : http://www.ninjatrader.com/support/f...d.php?p=257203

            This line :
            Code:
            // Sets Plot0 to the SMA of the 5 minute data series
                            Plot0.Set(SMA(BarsArray[1], Period)[0]);
            Is crucial, as in your case it sets the value for the plot to the SMA from the 2 minute data series, otherwise you will just see a bunch of zeros or nothing at all. I would suggest following the example in that forum exactly, as it will work for what you need (of course modifying some variables for your specific example.

            Something like this is what you want :

            Code:
            private int Period = 15;
            
            protected override void Initialize()
            {  
                        Add(PeriodType.Minute, 2);
                        Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line,"Plot0"));
                        Overlay                = true;
            }
            
            protected override void OnBarUpdate()
            {        
                        // Ensures that the plot is drawn on the primary data series
                        if (BarsInProgress == 0)       
                        {
                            // Sets Plot0 to the SMA of the 2 minute data series
                            Plot0.Set(SMA(BarsArray[1], Period)[0]);
                        }
            }
            Adam P.NinjaTrader Customer Service

            Comment


              #7
              Thanks

              Thanks Adam,
              I can't seem to get it to compile.. I understand the logic... because the indy has a few parameters though I am running into a problem...

              Value.Set(MEFLinRegAngle(BarsArray[1], Period)[0]);

              this alone will not compile, I know I have to set the parameters as well correct?

              Value.Set(MEFLinRegAngle(60,14,3,9,3,false)

              not sure how to combine the two together, tired everything but errors on compile

              Thanks for any help

              Comment


                #8
                tshirtdeal,

                What are the errors specifically?
                Adam P.NinjaTrader Customer Service

                Comment


                  #9
                  I continue to get"""

                  'NinjaTrader.Indicator.IndicatorBase.Close' is a 'property' but is used like a 'method'

                  and
                  No overload for method 'MEF" takes '2' arguments

                  Comment


                    #10
                    tshirtdeal,

                    I believe the issue is elsewhere. Does MEFLinRegAngle compile normally? Could you send an email to [email protected] along with your code and MEFLinRegAngle. Pleases put ATTN : Adam in the message.
                    Adam P.NinjaTrader Customer Service

                    Comment


                      #11
                      Thanks Adam,

                      All sent, the MEF indy does still compile fine, just checked...

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by sidlercom80, 10-28-2023, 08:49 AM
                      168 responses
                      2,262 views
                      0 likes
                      Last Post sidlercom80  
                      Started by Barry Milan, Yesterday, 10:35 PM
                      3 responses
                      10 views
                      0 likes
                      Last Post NinjaTrader_Manfred  
                      Started by WeyldFalcon, 12-10-2020, 06:48 PM
                      14 responses
                      1,429 views
                      0 likes
                      Last Post Handclap0241  
                      Started by DJ888, 04-16-2024, 06:09 PM
                      2 responses
                      9 views
                      0 likes
                      Last Post DJ888
                      by DJ888
                       
                      Started by jeronymite, 04-12-2024, 04:26 PM
                      3 responses
                      41 views
                      0 likes
                      Last Post jeronymite  
                      Working...
                      X