Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Gap Up/Down Alert

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

    Gap Up/Down Alert

    How can I set an Market Analyzer alert for a instrument that opens above yesterday's high price or opens below yesterdays low????!!! I have been searching the help guides and other forum posts to no avail. Any help is appreciated!

    #2
    Hello aktrdr071,

    Thanks for posting and welcome to the NT forums. This type of alert requires custom programming to create for the market analyzer. You can setup alerts and filters there, based on the indicators plot value. A common approach is setting a plot value of 1 when your condition is true and 0 otherwise. You can then be alerted when the column (indicator) value == 1.

    One way to do this with your condition in NinjaScript is with the snippet below:

    Code:
    if (CurrentDayOHL().CurrentOpen[0] > PriorDayOHLC().PriorHigh[0] || CurrentDayOHL().CurrentOpen[0] < PriorDayOHLC().PriorLow[0])
    	Value.Set(1);
    			
    else Value.Set(0);
    The indicator is created using Tools > New NinjaScript > indicator menu and then configured in the market analyzer. See here for help working with columns there:


    See here for help working with alert, filter, and cell conditions.
    Last edited by NinjaTrader_RyanM1; 01-17-2012, 04:31 PM.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks Ryan,

      So if I understand correctly, I will need to create a new indicator that returns a value of 1 or 0 based on a formula like yours below in the Ninjascript editor? How and where will I enter a code snippet?

      Comment


        #4
        Yes, that's it. To create a new indicator Click Tools > New NinjaScript > Indicator. Click Next to advance through the wizard to customize its name, plots and input parameters if needed.

        Click Generate to have it create the basic indicator structure. The snippet can be pasted exactly as it is, inbetween the two brackets { } of OnBarUpdate, like:

        Code:
        protected override void OnBarUpdate()
        {
        if (CurrentDayOHL().CurrentOpen[0] > PriorDayOHLC().PriorHigh[0] || CurrentDayOHL().CurrentOpen[0] < PriorDayOHLC().PriorLow[0])
        	Value.Set(1);
        	
        else Value.Set(0);
        }
        If you want to get started with indicator development in NinjaTrader, the following tutorials are helpful for explaining the structure and introducing the basics.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Great! Thanks Ryan

          Comment


            #6
            Is there a way to not make an alert but to pull all the stocks that meet a given requirement in the if function and put them into a preset instrument list that is every changing?

            Comment


              #7
              Yes, that would be considered a market analyzer filter. The setup and conditions work the same as alerts, but filters only show those instruments meeting the requirements you set. More information on filters is available here:
              Ryan M.NinjaTrader Customer Service

              Comment


                #8
                I have now see how to do this. Can it be done for only a group of labeled instruments? For instance, if I have my positions, and the NASDAQ 100, can I only run my filter on the NASDAQ 100 although only one market analyzer is open? Thank you.

                Comment


                  #9
                  The filter would check all instruments in that particular market analyzer window. It's easy to add a list of instruments to the MA window, and NASDAQ 100 is a built-in list. Right Click > Add Instrument List > NASDAQ 100 to add all instruments.
                  Ryan M.NinjaTrader Customer Service

                  Comment


                    #10
                    10-4. That is what I thought. Thank you.

                    Comment


                      #11
                      This is my indicator I created. I cannot return any results when I setup it up under columns and hide all values that equal zero. Please help? Thank you.

                      Comment


                        #12
                        Sure, I'll take a look. Nothing was attached yet in the previous post.
                        Ryan M.NinjaTrader Customer Service

                        Comment


                          #13
                          Forgive me.... here is the code.

                          Code:
                              [Description("")]
                              public class DonchianChannelSDLongScan : Indicator
                              {
                                  #region Variables
                          
                                  #endregion
                          
                                  protected override void Initialize()
                                  {
                                      Overlay				= false;
                                  }
                                  protected override void OnBarUpdate()
                                  {
                          			if (Close[0] >= MAX(High, 504)[1])
                          				Value.Set(1);
                          			else
                          				Value.Set(0);
                                  }
                          
                                  #region Properties
                          
                                  #endregion
                              }
                          }

                          Comment


                            #14
                            Thanks for posting that. A few things you would want to check:

                            The bars to load setting for the indicator needs to be enough, greater than 504.

                            You are using a lookback greater than 256, so also need to make sure you have Maximum Bars Looback set to Infinite.

                            Check the Row filter is enabled from the Right Click context menu. - From the main Market Analyzer screen.
                            Ryan M.NinjaTrader Customer Service

                            Comment


                              #15
                              It is still returning 0 results. Here are screenshots of my inputs.
                              Attached Files

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by bortz, 11-06-2023, 08:04 AM
                              47 responses
                              1,610 views
                              0 likes
                              Last Post aligator  
                              Started by jaybedreamin, Today, 05:56 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post jaybedreamin  
                              Started by DJ888, 04-16-2024, 06:09 PM
                              6 responses
                              19 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by Jon17, Today, 04:33 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post Jon17
                              by Jon17
                               
                              Started by Javierw.ok, Today, 04:12 PM
                              0 responses
                              22 views
                              0 likes
                              Last Post Javierw.ok  
                              Working...
                              X