Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multiple Timeframes

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

    Multiple Timeframes

    I was doing some work on C# Arraylists recently and it occurred to me that if I combined that with the Candle Clear code I'd written previously I could get NT to display multiple timeframes on one chart!

    What I've ended up with works on all time based timeframes (except Monhtly and Yearly), as well as tick and volume timeframes. It also works for all chart types (Candlestick, OHLC, HiLoBars and LineOnClose). Theres also been a lot done to optimise the efficiency of the code, so it produces little overhead in terms of cpu usage.





    The above screenshot shows Multiple Timeframes (MTF) added 3 times with different options applied. The first MTF is given a Multiplier input of 2 (the default) which creates a 2 minute panel (because we started off with a 1 minute chart), I've then applied the embedded "Scalper style" option which gives the same results as the Scalper indicator would on a 2 minute chart. The second MTF I've created a 5 minute panel and applied the embedded ModHeikenAshi option. The third MTF I've created a 15 minute panel and applied the Candle scale option to produce larger candles.



    Above is a screenshot of the properties options all set to default. Notice that by default we take on the Plot type, such as "CandleStick", "OHLC" and the up/down colours directly from the Chart's existing defaults, but we can if we want use the override options to create mixed charts. There is no limit in terms of applying all the options at once, etc..

    For those TTM fans I've attached another screenshot with the bars set in a TTM / OHLC manner with both Scalper and ModHeikenAshi stype options applied. The Scalper and ModHeikenAshi implementations are exactly the same as in the standalone indicators, with one exception, if you are running the Scalper on a time based chart within the MTF and have enabled the "Highlight current trigger bars" option you will be able to see historic trigger bars as you scroll backwards, an added bonus and side effect of the MTF optimisation process.


    There are two things to be aware of.

    1. NT will only allow indicators in seperate panels to display values/prices always set to 2 decimal places, so by default MTF will adjust the price, whether the ticksize is above or below 2 decimal places to be 2 decimal places. If you want to change the MTF behaviour you can by changing the "Price indicator scale" option in properties, you will probably soon notice the limitation, but it has the advantage in that you can overlay other indicators if the ticksize is not 2 decimal places (e.g. an EMA with a matching scale for its input period).

    2. These candles are reconstructed bars completely done in MTF and do not constitute NT Bars objects or anything similar. So an MTF bar for a day, for example, which was created from minute bars, will possibly have different boundary times to a default NT daily bar.


    To import:

    - Download the file contained in this thread to your desktop
    - From the Control Center window select the menu File > Utilities > Import NinjaScript
    - Select the downloaded file
    Attached Files
    Last edited by Gumphrie; 09-02-2007, 05:42 AM.

    #2
    Mtf

    Gotta hand it to you Gump.. I have implemented this and it is pretty darn slick. Kudos to you once again. It will be interesting to finally use NT to run multiple time frames on the same chart.

    What can I say.. you have outdone yourself this time.

    Happy Trading,
    EZ

    Comment


      #3
      Excellent work Gumphrie ! Contributions . I noticed a little bug - on the price scale of the second chart is one decimal-switch

      regs
      Jojo
      Attached Files

      Comment


        #4
        Originally posted by jojojo View Post
        Excellent work Gumphrie ! Contributions . I noticed a little bug - on the price scale of the second chart is one decimal-switch

        regs
        Jojo
        Thanks Jojo,

        Its a switch to two decimal places. Read "things to be aware of" point 1.

        Comment


          #5
          you are right - too fast because of excitement. This offers some substantial possibilities . Thanks again

          Comment


            #6
            On a related note I found it wasn't automatically scaling the price to 2 decimal places if the ticksize didn't contain a decimal point at all, (e.g. the YM), so I've updated the MTF attachment in the first post. (Seemed too minor to add a version number change at this early stage.)

            Comment


              #7
              Hello Gumphie

              What would be involved in extending this such that it can be used as input to other indicators.

              For example .. an EMA of the longer period...

              Displayed on the main chart of course... ;-)

              Comment


                #8
                Hi Zoltran,

                Not sure I understand the question.

                For simple plots like an EMA its probably easier to overlay the indicators.

                Comment


                  #9
                  Let say I use a 5x MTF on a 1 min chart to produce a '5 min' chart pane. I'd like to put an EMA or other indicator on that 5 min pane and have it use the the derived 5min data as input.

                  ie.. another indicator on the mtf indicator.

                  I do this all the time with other indicators
                  For example EMA(CCI(14),4) to get a 4 period EMA of the CCI.

                  I'd like to do EMA(MTF(4),4) to get a 4 period EMA of the MTF output.
                  In the example at the top, .. the EMA line looks the same as an EMA of the base 1 minute data... not an EMA of the 5x the MTF output.

                  Comment


                    #10
                    For that to work it would have to export or return a Dataseries and as a DataSeries is by definition in the same timeframe as the indicator that called it, it cannot work. You'd have to be able to create a new Bars object and you can only to that in a strategy, not an indicator. (Read "things to be aware of" point 2.)

                    MTF does not use DataSeries but C# ArrayLists within its custom plotting in order to get around this NT limitation.

                    But overlaying should work, if you open a 1 minute chart, create an 2 minute MTF, then overlay a 10 EMA onto the MTF it will in effect be the same as putting a 5 EMA onto a 2 minute chart. Obviously its not 'exactly' the same because of the bar spacing and averaging, but close.... Probably close enough for MAs.

                    The only way to add 'exact' implementations of other indicators on the MTF pane is to create style options within the MTF code itself like the embedded ModHA and Scalper options.

                    Comment


                      #11
                      Originally posted by Gumphrie View Post
                      But overlaying should work, if you open a 1 minute chart, create an 2 minute MTF, then overlay a 10 EMA onto the MTF it will in effect be the same as putting a 5 EMA onto a 2 minute chart.
                      Thanks Gumphie...
                      Overlaying doesn't seem to work like that .. An EMA on a 5x MTF looks the same as it does on the primary timeframe.

                      No problem .. I'm just playing with some ideas here.

                      This really should be a base NT function (Multiple TFs )

                      Comment


                        #12
                        Hi Gumphrie,
                        Is there a way to insert indicators on the MTF window?
                        thanks,
                        David

                        Comment


                          #13
                          Hi David,

                          Not without specifically designing one as an add-on. Did you have any in mind?

                          Otherwise, all you can do is overlay onto the panel.

                          Comment


                            #14
                            Hello Gumphrie,

                            I am new to Ninja Trader, so I wanted to know if there was a way to use your script here on stochastics?

                            I am trying to find a way to get MTF stochastics (in 1 panel) for trading. 15min, 30min, 1hr, and 4hr.

                            Would that be possible with your script here? or would I need to find something else?

                            -MW

                            Comment


                              #15
                              Hi MW,

                              Probably not in the MTF itself, as its mainly concerned with price bars rather than plots, but you certainly can use the (ArrayList) concepts in the code to create such an indicator.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by JonesJoker, 04-22-2024, 12:23 PM
                              8 responses
                              41 views
                              0 likes
                              Last Post JonesJoker  
                              Started by timko, Today, 06:45 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post timko
                              by timko
                               
                              Started by Waxavi, 04-19-2024, 02:10 AM
                              2 responses
                              38 views
                              0 likes
                              Last Post poeds
                              by poeds
                               
                              Started by chbruno, Yesterday, 04:10 PM
                              1 response
                              44 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by Max238, Today, 01:28 AM
                              1 response
                              25 views
                              0 likes
                              Last Post CactusMan  
                              Working...
                              X