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

Simple Indicator that alerts with every new bar

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

    Simple Indicator that alerts with every new bar

    Good Morning,

    I am looking for a very simple indicator that will send me either a text or email alert every time a new bar is created.

    I use long range bars so sitting in front of the screen isnt really practical ... instead I need something to let me know (actually just before) a new bar is created, so I can open up a remote desktop or sit down at the comp and manage trades.

    Has anyone ever come across anything like this? or Do I have to write it ...

    Oh and I'm on NinjaTrader 6.5

    Thank you very much

    #2
    Hello,

    NinjaTrader does not support sending text messages so it would have to send an email.

    Also, I'm not aware of anything indicators already developed that does this which would mean it would need to be custom coded.

    You can contact one of our NinjaScript consultants to assist you with coding this or you can use our NinjaScript guide and forums to code this indicator yourself if you are a programmer.

    NinjaScript Consultants:

    NinjaScript Help Guide:

    NinjaTrader Support Forum:



    Let me know if I can be of further assistance.

    Comment


      #3
      Code:
      if (FirstTickOfBar) SendMail("[email protected]", "[email protected]",  "New Bar Alert", "New bar just opened");
      That would be your action code. You may want to put time constraints on it, so that you do not get emailed after market hours.

      Comment


        #4
        Thanks kog , It looks like I'll have to sit down and learn a little ninja script

        Comment


          #5
          Started Looking into NinjaScript

          Good Morning,

          I just spent a couple hours doing some research on NinjaScript ... though since my programming skills are a bit rusty I have a couple quick questions that hopefully someone can help me out with.

          First, to lay out what I'm after ...

          I am looking to create an indicator that will send me an email alert once the current bar is at a certain percentage of completion. (more than likely 90% ... though I would set up a variable for this ... this will allow for delays in emails and logging on to trade platforms etc.)

          My thoughts are ... (in English)

          If (current price > ((RangeBarSetting * 90%) + current bars low)) or (current price < ((RangeBarSetting *90%) - current bars high)) and alerted = false than send an email

          For explanation:
          RangeBarSetting would be the variable that equals the charts range bar setting.
          Alerted is a boolean variable to keep me from getting more than 2 alerts in the same bar. (just in case price hits 90%, sends an alert, and then retraces to the other 90% threshold)

          This way I am getting alerted at 90% regardless of price going up or down. I'm sure there is a much more sophisticated way of achieving this, so any help would be greatly appreciated.

          Thanks in Advance
          Last edited by Aithin; 01-23-2011, 09:36 AM.

          Comment


            #6
            Aithin, there is actually a property available to check how far along a bar is called PercentComplete.

            You'll have to set CalculateOnBarClose = false to get intrabar updates/alerts.

            Once you do that, you could do this:
            Code:
            // in variables
            bool waitForNewBar = false;
            
            OnBarUpdate()
            if (Bars.PercentComplete > 0.9)
            {
            waitForNewBar = true;
            // send alert
            }
            if (FirstTickOfBar)
            {
            waitForNewBar = false;
            }
            As a side note, many cell phone providers will allow you to send an "email" to a certain address, which will then forward on the email as a text message to your phone. Verizon, for example, lets you send an email to ##########@vtext.com, and then it gets sent to the phone number represented by ##########.

            A quick search yielded this page with information and the email addresses for many carriers - http://www.emailtextmessages.com/
            AustinNinjaTrader Customer Service

            Comment


              #7
              Thank You very much

              Thank you very much, though when I put the code into the indicator I am not receiving alerts. Below I have copy/pasted the exact indicator code ...

              ________ Begin copy/paste

              #region Using declarations
              using System;
              using System.ComponentModel;
              using System.Diagnostics;
              using System.Drawing;
              using System.Drawing.Drawing2D;
              using System.Xml.Serialization;
              using NinjaTrader.Cbi;
              using NinjaTrader.Data;
              using NinjaTrader.Gui.Chart;
              #endregion

              // This namespace holds all indicators and is required. Do not change it.
              namespace NinjaTrader.Indicator
              {
              /// <summary>
              /// This Indicator will send email alerts just before every new bar is created.
              /// </summary>
              [Description("This Indicator will send email alerts just before every new bar is created.")]
              public class RangeBarAlerts : Indicator
              {
              #region Variables
              // Wizard generated variables
              // User defined variables (add any user defined variables below)
              bool waitForNewBar = false;

              #endregion

              /// <summary>
              /// This method is used to configure the indicator and is called once before any bar data is loaded.
              /// </summary>
              protected override void Initialize()
              {
              CalculateOnBarClose = false;
              Overlay = false;
              PriceTypeSupported = false;
              }

              /// <summary>
              /// Called on each bar update event (incoming tick)
              /// </summary>
              protected override void OnBarUpdate()
              {
              if (Bars.PercentComplete >= 0.9)
              {
              waitForNewBar = true;
              // send alert
              SendMail("[email protected]", "[email protected]", "New Bar Alert", "New bar just opened");

              }
              if (FirstTickOfBar)
              {
              waitForNewBar = false;
              }
              }

              #region Properties

              #endregion
              }
              }

              #region NinjaScript generated code. Neither change nor remove.
              // This namespace holds all indicators and is required. Do not change it.
              namespace NinjaTrader.Indicator
              {
              public partial class Indicator : IndicatorBase
              {
              private RangeBarAlerts[] cacheRangeBarAlerts = null;

              private static RangeBarAlerts checkRangeBarAlerts = new RangeBarAlerts();

              /// <summary>
              /// This Indicator will send email alerts just before every new bar is created.
              /// </summary>
              /// <returns></returns>
              public RangeBarAlerts RangeBarAlerts()
              {
              return RangeBarAlerts(Input);
              }

              /// <summary>
              /// This Indicator will send email alerts just before every new bar is created.
              /// </summary>
              /// <returns></returns>
              public RangeBarAlerts RangeBarAlerts(Data.IDataSeries input)
              {

              if (cacheRangeBarAlerts != null)
              for (int idx = 0; idx < cacheRangeBarAlerts.Length; idx++)
              if (cacheRangeBarAlerts[idx].EqualsInput(input))
              return cacheRangeBarAlerts[idx];

              RangeBarAlerts indicator = new RangeBarAlerts();
              indicator.BarsRequired = BarsRequired;
              indicator.CalculateOnBarClose = CalculateOnBarClose;
              indicator.Input = input;
              indicator.SetUp();

              RangeBarAlerts[] tmp = new RangeBarAlerts[cacheRangeBarAlerts == null ? 1 : cacheRangeBarAlerts.Length + 1];
              if (cacheRangeBarAlerts != null)
              cacheRangeBarAlerts.CopyTo(tmp, 0);
              tmp[tmp.Length - 1] = indicator;
              cacheRangeBarAlerts = tmp;
              Indicators.Add(indicator);

              return indicator;
              }

              }
              }

              // This namespace holds all market analyzer column definitions and is required. Do not change it.
              namespace NinjaTrader.MarketAnalyzer
              {
              public partial class Column : ColumnBase
              {
              /// <summary>
              /// This Indicator will send email alerts just before every new bar is created.
              /// </summary>
              /// <returns></returns>
              [Gui.Design.WizardCondition("Indicator")]
              public Indicator.RangeBarAlerts RangeBarAlerts()
              {
              return _indicator.RangeBarAlerts(Input);
              }

              /// <summary>
              /// This Indicator will send email alerts just before every new bar is created.
              /// </summary>
              /// <returns></returns>
              public Indicator.RangeBarAlerts RangeBarAlerts(Data.IDataSeries input)
              {
              return _indicator.RangeBarAlerts(input);
              }

              }
              }

              // This namespace holds all strategies and is required. Do not change it.
              namespace NinjaTrader.Strategy
              {
              public partial class Strategy : StrategyBase
              {
              /// <summary>
              /// This Indicator will send email alerts just before every new bar is created.
              /// </summary>
              /// <returns></returns>
              [Gui.Design.WizardCondition("Indicator")]
              public Indicator.RangeBarAlerts RangeBarAlerts()
              {
              return _indicator.RangeBarAlerts(Input);
              }

              /// <summary>
              /// This Indicator will send email alerts just before every new bar is created.
              /// </summary>
              /// <returns></returns>
              public Indicator.RangeBarAlerts RangeBarAlerts(Data.IDataSeries input)
              {
              if (InInitialize && input == null)
              throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");

              return _indicator.RangeBarAlerts(input);
              }

              }
              }
              #endregion



              ________ End copy/paste





              Thanks again for the help thus far ... any and all help is greatly appreciated.
              Last edited by Aithin; 02-08-2011, 10:21 AM.

              Comment


                #8
                Hello,

                There must have been a mis communication. As http://www.ninjatrader.com/support/h...ntcomplete.htm

                Bars.PercentComplete does not work on Range Bars. You would need to use this on another type of chart.

                Let me know if I can be of further assistance.

                Comment


                  #9
                  Ok

                  Oh ok. Then can anyone help me with my previous question from post #5?

                  Thanks

                  Comment


                    #10
                    Hello,

                    Sure, You would need to do this manually on a range bar.

                    For example heres what I would do.

                    Once a range bar is complete. So If(FirstTickOfBar == true)

                    Then calculated what the next 4 ticks price would be for example we are running this on a 4 tick chart.

                    Take the alertlevel = Close[0] + 3 * TickSize;

                    Then setup a check for if (Close[0] == alertLevel)

                    Then sent the email/alert.

                    Let me know if I can be of further assistance.

                    Comment


                      #11
                      intrabar update and alerts

                      Does the intrabar update and alerts work with Range Bars? If so can I use something that would be

                      if currentprice == alertlevel then send the alert?

                      (current price obviously being plain english and not the real command)

                      Thanks

                      Comment


                        #12
                        Hello,

                        Yes this is possible. I would set a re-arm on the alert to be like 1 minute or something like that so that it does not keep sending you email over and over.

                        I look forward to assisting you further.

                        Comment


                          #13
                          Command for Current Price

                          I have been searching all morning and can not find the command for the current price.

                          I've seen Open, Close, High, Low ... but no current market price (or bid / ask it doesnt really matter in this case)

                          Thanks

                          Comment


                            #14
                            Current price is Close[0]

                            I look forward to assisting you further.

                            Comment


                              #15
                              Hello,

                              Also, if you want it to update tick by tick you would need to set this indicator when you add it to the chart to Calculate On Bar Close = False.

                              Let me know if I can be of further assistance.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              169 responses
                              2,268 views
                              0 likes
                              Last Post QuantKey_Bruce  
                              Started by Irukandji, Yesterday, 02:53 AM
                              2 responses
                              17 views
                              0 likes
                              Last Post Irukandji  
                              Started by adeelshahzad, Today, 03:54 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post adeelshahzad  
                              Started by CortexZenUSA, Today, 12:53 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post CortexZenUSA  
                              Started by CortexZenUSA, Today, 12:46 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post CortexZenUSA  
                              Working...
                              X