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

How to perform True/False tests on an Indicator (SMA20) from Two different Timeframes

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

    How to perform True/False tests on an Indicator (SMA20) from Two different Timeframes

    Hi,

    I know how to Plot multiple Time Frames on a Single Chart using dataseries, as in the aSMAmultitime Example posted in the Indicator Development forum under
    How do you plot two time frames of an indicator?.

    I perform "True" or "False" tests on Many different indicators within an Indicator (that I created) and does Not Plot on the Chart. It Only Draws the Signal Arrows on the chart when the "True" condition is satisfied. I would like to know how to Format the test code to compare an indicator from two different time frames?

    Example:
    // Compare SMA(20) from a 4 Range Time Frame to SMA(20) from a 8 Range Time Frame
    if ( SMA(Close, 20)[0] > SMA(Close, 20)[0] ) <--- How to FORMAT this Correctly?
    { Then.............................................. ....}

    I would like to have the capability to test both the Current Bar [0] from both time frames and also Previous Bars [3] from both time frames.

    Thanks in advance for your support!

    Joe

    #2
    Hi Joe,

    There is a sample multi series implementation you can view. Click Tools > Edit NinjaScript > Strategy > SampleMultiTimeFrame.

    Documentation for this is available here:


    Once you have added the series in the Initialize method, you reference the series with BarsArray[] or Closes, Highs, Lows, Opens.

    if ( SMA(Close, 20)[0] > SMA(Closes[1], 20)[0] )
    Last edited by NinjaTrader_RyanM1; 03-04-2011, 02:46 PM.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hi Ryan,

      Thank you for the support.

      Could you PLEASE elaborate a little more on what you mean by "reference the series with BarsArry[] "? Thank You Again.

      Joe

      Comment


        #4
        Hi Joe,

        BarsArray[] is the collection of bar objects. It's discussed in the documentation linked:


        Please review the documentation for multi series and let us know if you have any additional questions.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Very, Very Interesting!

          Thank You Ryan for your support, have a nice weekend!

          Comment


            #6
            My pleasure, Joe. You do the same.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Hi Ryan,

              Hope you had a nice weekend.

              I was working on this, this weekend and wanted to verify a couple of things to see if I'm correct or if there possible.

              1)
              What I wanted to accomplish was to create an All in One Indicator that would PLOT the 50,100 & 200 SMA's from the 500T, 1000T, 1500T & 2000T Timeframes on a 250Tick Chart (15 Plot's Total). It compiled but did not plot correctly, I believe this was Not possible because there was different Periods within the indicator. Is this correct or is there a way to accomplish this within a single Indicator or a Strategy and if so, How?

              2)
              Continuing with this, I also realized that you can only PLOT 3 DataSeries within a Single Indicator, otherwise it did Not plot correctly. Example:
              dataseries0 <---Primary Chart TimeFrame
              dataseries1 <---2nd TimeFrame
              dataseries2 <---3rd TimeFrame

              Is this correct or is there a way to accomplish this within a Single Indicator or Strategy and if so, How?

              Thank You in Advance!

              Comment


                #8
                Yes, this is possible. Check log tab of control center for any error messages when applying the script to a chart. To create this, first start simple to get one plot working correctly, and only add additional plots when you verified it's working as you expect.
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  Hi Ryan,

                  You were right!

                  Thanks Again for your help with this.

                  Joe

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by pechtri, 06-22-2023, 02:31 AM
                  9 responses
                  122 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by frankthearm, 04-18-2024, 09:08 AM
                  16 responses
                  64 views
                  0 likes
                  Last Post NinjaTrader_Clayton  
                  Started by habeebft, Today, 01:18 PM
                  1 response
                  5 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by benmarkal, Today, 12:52 PM
                  2 responses
                  13 views
                  0 likes
                  Last Post benmarkal  
                  Started by f.saeidi, Today, 01:38 PM
                  1 response
                  7 views
                  0 likes
                  Last Post NinjaTrader_BrandonH  
                  Working...
                  X