Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi Timeframe support

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

    Multi Timeframe support

    When trying to test the below script it doesn't perform as expected. Orders are getting executed below the Lower Channel or the Middle Channel instead of the Upper Channel as I expect. In plain English, I want an order to be executed if the closing of the 1 minute bar and the 1 day bar is > than the Keltner Upper Channel.
    Last edited by Edgar V.; 03-18-2008, 06:28 AM.

    #2
    The AND operator is && not &.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Question: When pressing the Start button for the Strategy it indicates in the "Avg Price" column a price "x". Is this the price when the strategy will execute?

      Comment


        #4
        This is the avg price of the position managed by the strategy

        Comment


          #5
          But the position wasn't executed yet. It is still pending to be executed. Will it execute when the Avg Price reaches 0?

          Comment


            #6
            Not sure I follow: This is the avg price of the position managed by the strategy and has nothing to do with any potentially pending signals/orders etc...

            Comment


              #7
              Exactly. When I press the start button, I want a condition to be met so an Entry order can be placed. Problem is that as soon as I hit the Start button I immediately see the Avg Price running, but no position open yet, even though conditions were not met yet.

              The reason I present this is also because the Entry of the order is way far from where I want it to be. Example, I want the order to enter as soon as the close of the 1 minute bar > Keltner Upper Channel (1 day chart), but the order is entering closer to the middle or Lower Channel. Sometimes way up the Upper Channel of the 1 day chart.

              The minute chart is used as a reference to enter an order and the daily chart is used as a reference to use the Keltner Channel.
              Last edited by Edgar V.; 03-18-2008, 06:41 AM.

              Comment


                #8
                Sure there is a position which was created on the historical part of your data series. You'd need to add code like

                if (Historical)
                return;

                to avoid that the strategy processes your historical data and creates historical positions.

                Read more here to understand the concept of how strategies are synced historical to live: http://www.ninjatrader-support.com/H...tegiesTab.html

                Comment


                  #9
                  Does this applies to Live Trading as well?

                  Comment


                    #10
                    >> Does this applies to Live Trading as well?
                    yes

                    Comment


                      #11
                      Thanks for the historical. It is working.

                      Question: During a Live Test, I'll like to have the following script to work:

                      protectedoverridevoid OnBarUpdate()

                      {
                      //Only run on real-time data
                      if (Historical)
                      return;


                      if (BarsInProgress == 0)
                      {

                      if (CrossAbove(SMA(1), Bollinger(BarsArray[1],2, 14).Upper, 0))


                      {
                      EnterLong(DefaultQuantity, "EnterLong");
                      }


                      What I'm looking for is to have the SMA for a 1min chart CrossAbove the Bollinger bands from another chart time such as the 1 day chart to enter a long position.

                      What I've noticed during my tests is that the Position won't get entered untill the Bar for the Daily chart is closed. I already had set in the Initialize section the

                      Add(PeriodType.Minute, 1440);
                      CalculateOnBarClose =
                      false;

                      but still won't execute at the tick or at least at the closing of the 1 minute bar chart. What happens is that is waiting for the 1 day Bar to close to then enter long. Any suggestions?
                      Last edited by Edgar V.; 03-19-2008, 06:05 AM.

                      Comment


                        #12
                        Just to put it out there for people searching the forums. As you have discovered in your other thread, CrossAbove needs to have at least 1 as the last parameter not 0.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          Question about multi-time frame

                          Hello.

                          I have an indicator that calculates, among other things, whether

                          (BackColor = "Green") or (BackColor = "Red").

                          Question.

                          I want to create a multi time frame strategy which includes the following code:

                          if (BackColor[primary bar][0] = "Green" && BackColor[secondary bar][0] = "Green")
                          {
                          EnterLong;
                          }

                          How do I expose the value of BackColor so the strategy can access it ?

                          Comment


                            #14
                            You usually set BackColor like this.
                            Code:
                            BackColor = Color.Green;
                            In your strategy you should be able to see what the BackColor is when your indicators change it. Do this:
                            Code:
                            if (BackColor == Color.Green)
                                 // Do something
                            If that doesn't work, you can just create a variable in the indicator that tracks the back color values and then expose it for use in the strategy. Please see this reference sample on how to do that: http://www.ninjatrader-support.com/v...ead.php?t=4991
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Getting CS0102

                              Thank you for the reply. I took a look at your example in SampleBoolSeries and I see that BearIndication and BullIndication Boolseries values are 'exposed' in the 'properties' section.

                              When I try that technique with my indicator, I get the following error message
                              " The type 'NinjaTrader.Indicator.rcsMACDBBv6' already contains a definition for 'barDotColor' - CS0102

                              I have this in my #region section :

                              // Declaration of two StringSeries objects. One for the color of the MACD value. The other for the backColor
                              private StringSeries barDotColor;
                              private StringSeries barBackColor;

                              I have this in my Initialize() :

                              barDotColor = new StringSeries(this);
                              barBackColor = new StringSeries(this);

                              But when I put the following in my 'Properties' section I get the above error :

                              [Browsable(false)]
                              [XmlIgnore()]
                              public StringSeries barDotColor
                              {
                              get { return barDotColor; } // Allows our public barDotColor StringSeries to access and expose our interal barDotColor StringSeries
                              }


                              What am I missing ?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              666 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              376 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              110 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              575 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              580 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X