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

Ensuring onBarUpdate will not process already existing Bars?

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

    Ensuring onBarUpdate will not process already existing Bars?

    Hi Team,

    I have built an indicator that sends me an email each time a condition is met,
    The problem is, that when I load my indicator (which have 5 days back) I get emails every time this condition triggered on the "Old" data.

    Is there a way for me to start the sending only from the current bar onwards?

    Thank you!





















    #2
    Hello liadmz,

    Thanks for your post and welcome to the Ninjatrader forums!

    As your post relates to Indicators I will move this topic to the appropriate forum (you posted in strategy development)

    Just to confirm, you are asking about a NinjaTrader8 indicator you created?

    What method are you using to send the e-mail(s)? SendMail() or share() or??

    Perhaps you can post the line(s) of code that relate (change the e-mail addresses to something like xxxx.gmail.com so that you don't get unsolicited spambot mails.

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by liadmz View Post
      I have built an indicator that sends me an email each time a condition is met,
      The problem is, that when I load my indicator (which have 5 days back) I get emails every time this condition triggered on the "Old" data.

      Is there a way for me to start the sending only from the current bar onwards?
      Sounds like you want to avoid sending email on historical bars ...

      From your question, I presume you're not using Ninja's SendMail?

      If so, whenever your custom send email code needs to run, you
      need a 'guard' to prevent doing so on Historical bars, like this,

      if (State != State.Historical)
      {
      ... your code to send email
      }

      But, if you use NinjaScript's own SendMail, it already does this check.

      Comment


        #4
        Originally posted by NinjaTrader_PaulH View Post
        Hello liadmz,

        Thanks for your post and welcome to the Ninjatrader forums!

        As your post relates to Indicators I will move this topic to the appropriate forum (you posted in strategy development)

        Just to confirm, you are asking about a NinjaTrader8 indicator you created?

        What method are you using to send the e-mail(s)? SendMail() or share() or??

        Perhaps you can post the line(s) of code that relate (change the e-mail addresses to something like xxxx.gmail.com so that you don't get unsolicited spambot mails.
        Yes, I am talking about NT8 indicator I created

        The code is a simple API using C# (the server-side sends the actual email and SMS)

        Code:
        var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
        httpWebRequest.Method = "POST";
        httpWebRequest.ContentType = "application/json";
        
        using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
        {
             string json = "{\"text\":\"" + txt + "\"}";
             streamWriter.Write(json);
        }
        
        var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
        using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
        {
             var result = streamReader.ReadToEnd();
        }

        Comment


          #5
          Originally posted by bltdavid View Post

          Sounds like you want to avoid sending email on historical bars ...

          From your question, I presume you're not using Ninja's SendMail?

          If so, whenever your custom send email code needs to run, you
          need a 'guard' to prevent doing so on Historical bars, like this,

          if (State != State.Historical)
          {
          ... your code to send email
          }

          But, if you use NinjaScript's own SendMail, it already does this check.

          Thank you!
          That is exactly what I was looking for!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by GLFX005, Today, 03:23 AM
          0 responses
          1 view
          0 likes
          Last Post GLFX005
          by GLFX005
           
          Started by XXtrader, Yesterday, 11:30 PM
          2 responses
          11 views
          0 likes
          Last Post XXtrader  
          Started by Waxavi, Today, 02:10 AM
          0 responses
          6 views
          0 likes
          Last Post Waxavi
          by Waxavi
           
          Started by TradeForge, Today, 02:09 AM
          0 responses
          12 views
          0 likes
          Last Post TradeForge  
          Started by Waxavi, Today, 02:00 AM
          0 responses
          2 views
          0 likes
          Last Post Waxavi
          by Waxavi
           
          Working...
          X