Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem adding 2:nd instrument

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

    #16
    CarlZAZ, did you just delete your question?

    Aren´t you using the wrong syntax for the "Add" method here?!:

    Add(PeriodType.Minute, ATRBasisBars);

    Should be:

    Add("ATRBasisBars", PeriodType.Minute, 30);

    (If ATRBasisBars is your second instrument and you use 30 min bars)
    Last edited by FREEN; 06-06-2010, 12:42 PM.

    Comment


      #17
      SendMail

      I´m trying to get NT to send a mail at a specific time but it won´t send, (NT test mail works fine). How often is this statement evaluated? Is the evauation only made on bar update so that I should code an interval rather than a specific time? Any other idea why this won´t send?


      if (ToTime(Time[0]) == ToTime(19, 0, 0))
      {
      SendMail(
      "[email protected]", "[email protected]", "Test mail", "Test mail main text");
      }


      Thanks, Fredrik

      Comment


        #18
        Hello,

        If you have that code in the OnBarUpdate block of code it will be evaluated each new tick (each bar update). However, it may be that you are not getting a tick right at (19,0,0). You might want to use

        if (ToTime(Time[0]) >= ToTime(19, 0, 0) && not_emailed)
        {
        SendMail(
        "[email protected]", "[email protected]", "Test mail", "Test mail main text"
        );

        not_emailed = false;

        }

        Or course you will need to reset not_emailed at some point to true when you want to start looking for the time again. The not_emailed variable is a bool flag that toggles to prevent multiple emails from being sent.
        DenNinjaTrader Customer Service

        Comment


          #19
          Thanks Ben,

          That would work fine. Would it also be possible to have the code before the "OnBarUpdate" to have it evaluated in realtime as bellow?

          CalculateOnBarClose = true;
          }
          ///<summary>
          /// Called on each bar update event (incoming tick)
          ///</summary>

          if (ToTime(Time[0]) == ToTime(19, 0, 0))
          {
          SendMail(
          "[email protected]", "[email protected]", "Test mail", "Test mail main text");
          }


          protectedoverridevoid OnBarUpdate()
          {
          // Condition set 1

          Comment


            #20
            Hello Freen,

            No, that wouldn't work there. You would want to put in OnBarUpdate() or develop your own custom method.

            If you want to base the calculation on your PC clock rather than bar time stamps, you can use DateTime.Now

            if (ToTime(DateTime.Now) == ToTime(19, 0, 0))
            Ryan M.NinjaTrader Customer Service

            Comment


              #21
              Thanks,

              Would that be evaluted in realtime? Doesn´t the "OnBarUpdate()" method make the code run in the bar duration intervals wich would make it almost impossible to hit the second in the "ToTime(19, 0, 0)" method?!
              Last edited by FREEN; 06-21-2010, 04:02 PM.

              Comment


                #22
                Yes, OnBarUpdate() will update on every incoming tick or on bar close if you have CalculateOnBarClose = true.

                My suggestion was to check your computers date/time rather than a specific bar time stamp. A bar might not end exactly at 19:00:00, but your computer clock will at some point. There's still precision needed if the market you're viewing isn't actively trading. OnBarUpdate could trigger just before or after the specified time.

                You can create custom events that are not tied to OnBarUpdate(). This reference sample offers a sample implementation.
                Ryan M.NinjaTrader Customer Service

                Comment


                  #23
                  I don´t get this working. If I have set the Time Series to 1 min in the Strategies Tab, wouldn´t this code send a mail at some point (each minute/bar update?) after 11:05 based on the server/computer clock? "not_emailed" is reset to "true" a all times to make sure this wasn´t the problem:

                  #region Variables
                  // Wizard generated variables
                  // User defined variables (add any user defined variables below)

                  private bool not_emailed;

                  #endregion

                  /// <summary>
                  /// This method is used to configure the strategy and is called once before any strategy method is called.
                  /// </summary>
                  protected override void Initialize()
                  {
                  CalculateOnBarClose = true;
                  }

                  /// <summary>
                  /// Called on each bar update event (incoming tick)
                  /// </summary>
                  protected override void OnBarUpdate()
                  {

                  not_emailed = true;

                  if (ToTime(DateTime.Now) >= ToTime(11, 05, 0) && not_emailed)
                  {
                  SendMail("[email protected]", "[email protected]", "Test mail", "Test mail main text");

                  not_emailed = false;
                  }
                  Last edited by FREEN; 06-27-2010, 09:54 AM.

                  Comment


                    #24
                    Hello,

                    Print() out your two time values in your criteria to see what they are showing. Also, try using Time[0] instead of .Now.
                    DenNinjaTrader Customer Service

                    Comment


                      #25
                      Tnx Ben,

                      It runs, don´t know what I did wrong the first time. Might just have forgotten to "Enabled" the strategy. Sorry for the inconvenience.

                      Does the "Print()" method display in the primary series panel? I noticed you often suggest this approach in debugging.

                      Comment


                        #26
                        Hi Freen,

                        Print will output to the Tools > Output Window. Additional debugging help is available at the link below:

                        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
                        633 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        364 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        105 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        567 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        568 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X