Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi-Market & Multi-Timeframe

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

    Multi-Market & Multi-Timeframe

    Hello

    Is it possible to combine a Multi-Market feature and a Multi-Timeframe feature in the same code?
    I've developed a strategy that is applied to a variety of markets and I'd now like to add the confirmation of a certain indicator on a slower timeframe before triggering a signal.

    Does NT support this?

    Thanks

    #2
    Hi laocoon,

    Yes, it depends on which overload you use for the Add() statement. Either you specify the instrument or not.
    Add("MSFT", PeriodType.Minute, 15);
    or
    Add(PeriodType.Minute, 15);

    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hi Ryan

      Thanks for your reply. Basically my strategy is exactly the same for every market, the only time I "call" the different markets is when a signal is triggered and a computer-generated voice tells me on which market the signal appeared. The corresponding code snippet looks like this:

      if (Instrument.MasterInstrument.Name == "FDAX")
      PlaySound("Dax Trend.wav");

      if (Instrument.MasterInstrument.Name == "6E")
      PlaySound("Euro Trend.wav");

      etc.

      This works well. What I want to add to this is a confirmation of an indicator on a slower timeframe.
      I tried with the following code and it compiles OK, but when I apply the strategy to my charts and enable it, it always shows the "D" of "Disabled".

      Add (PeriodType.Volume,500); //This is the slower timeframe

      protected override void OnBarUpdate()

      {
      ifBarsInProgress ==0 //Code for faster timeframe
      {
      Code
      }

      ifBarsInProgress ==1 //Code for slower timeframe
      {
      Code
      }
      }

      Any hints on what I'm missing are very much appreciated.

      Thanks

      Comment


        #4
        laocoon, any entries in the log that would help shed light onto why it would be disabled? Do you have a CurrentBars check for all series added present?

        Thanks,

        Comment


          #5
          Thanks for your reply Bertrand. The log doesn't show anything. What is a CurrentBars check?

          Thanks

          Comment


            #6
            Please see this check mentioned here, it would be the normal check you know for a single series to cover accessing invalid bars at the start of the chart, but this time extended to cover added series as well -

            Comment


              #7
              Hi Bertrand

              Thanks for your reply. I did as you suggested and managed to make it work.
              For testing purposes I created two versions of my strategy:

              -The Original one (No slower timeframe included)
              -The New one (With the additional layer of an indicator-check on a slower timeframe)

              Of the three trading signals my strategy generates, only one uses the check on the slower timeframe.

              What's really strange is that the New strategy (with the slower timeframe) produces false alerts for the two signals that DON'T use the slower timeframe as additional check.

              I'm really quite lost here.

              Comment


                #8
                laocoon,

                To debug this you will have to simplify and use Print() statements to check everything out. If the results don't match up with your expectations, please post a simplified script here and steps needed to see what you're seeing.
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  Hi RyanM

                  Thanks for your reply. I spent quite some time with the code and here's the problem: a few times a day the strategy will plot a dot or an arrow (those are the symbols I use to highlight entry signals) on a random location on the chart, far away from the candles. This plot isn't associated with a signal and just appears without any reason. That never happened with the earlier version (without the second timeframe). No idea how to correct it.

                  On a separate note, I noticed a potential issue with Multi-Timeframe strategies:
                  Let's say I use 100 contract Volume bars (fast timeframe) and 500 contract Volume bars (slow timeframe).
                  One of the criteria for the stragegy is that for a Long entry on the fast timeframe, the slow timeframe has to display a CLOSED Green (Up) Bar (not the current bar that hasn't closed yet but the one before). Basically I'm talking about Bar[0] with a CalculateOnBarClose=true setting.

                  Each 500 Volume bar obviously contains 5 X100 Volume bars, with the fifth 100 Volume bar closing at EXACTLY the same time as the 500 Volume bar. If this happens (20% chance), then the strategy won't generate a signal. Is there a way to avoid this limitation?

                  Thanks
                  Last edited by laocoon; 06-02-2011, 11:14 AM.

                  Comment


                    #10
                    Unfortunately there's no shortcut to debugging this. Print all needed values, BarsInProgress, CurrentBar, and the states of all values to track what your code is doing. If something doesn't work the way you expect, share a simplified code snippet and we will attempt to reproduce what you're seeing here.
                    Ryan M.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi RyanM

                      Thanks for your reply. I used the Print command but to no avail. Let me rephrase what I want to achieve, maybe this will make things clearer. I have a single timeframe strategy (2500+ lines of code) that works perfectly. The only thing I want to add to it is a confirmation for every signal by a slower timeframe. For a long signal on the fast timeframe the last closed candle on the slower timeframe must be green, for a short it must be red. That's it.

                      Here's how I went about it:


                      Add (PeriodType.Volume,500); //This is the slower timeframe

                      protected override void OnBarUpdate()

                      {
                      ifBarsInProgress ==0 //Code for faster timeframe (2500+ lines of code that work perfectly)
                      {
                      Code
                      }

                      ifBarsInProgress ==1 //Code for slower timeframe. This is where I check whether the last closed candle is Green or Red.
                      {
                      if Open[1] <Close [1]
                      SlowTimeframeLong = true
                      }

                      {
                      if Open[1] >Close [1]
                      SlowTimeframeShort = true
                      }
                      }

                      I then add the SlowTimeframeLong = true criteria to the criteria list of my Long entry signals (same for shorts) and that's it.

                      Unfortunately it doesn't work. I've read all tutorials about how to add another timeframe to a strategy but I'm not aware of a conceptual mistake I made.

                      Comment


                        #12
                        What do you feel is not working correctly? If you're not making any progress on your own, consider a NinjaScript consultant, who can be hired to debug and write code for you.


                        If you feel there is an issue with NinjaTrader, please provide us a simplified script and we will give it a run here. Let us know what you are expecting to see with the script and what you are seeing instead.
                        Ryan M.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        648 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        369 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        108 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        572 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        573 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X