• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

not getting alerts

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

    not getting alerts

    i want to raise a alert when my indicator plots something and its close to end of bar.
    i can see my indicator plot values but i dont get the alerts
    Code:
    if( CurrentBar < 5)
    				return;
                // Use this method for calculating your indicator values. Assign a value to each
                // plot below by replacing 'Close[0]' with your own formula.
    			if(High[0] <High[1] +TickSize && Low[0] >Low[1] -TickSize )
                Plot0.Set(Close[0]);
    			else
    				Plot0.Reset();
    			if(Bars.PercentComplete >95 && Plot0[0]>0)
    			{
    				Alert(Instrument.FullName + CurrentBar,NinjaTrader.Cbi.Priority.High, "Getready for insider", "Alert1.wav", 10, Color.Black, Color.Yellow);
     
    
    			}
    Last edited by junkone; 09-15-2016, 11:12 AM.

    #2
    Hello junkone, and thank you for your query.

    I see two potential reasons why you would not get alerts.

    First, from the documentation for Bars.PercentComplete,

    Originally posted by http://ninjatrader.com/support/helpGuides/nt7/percentcomplete.htm
    Definition
    Gets a value indicating the completion percent of the current bar in progress.


    • Will always return a value of zero (0) when working with Kagi, LineBreak, Range, Renko, or PointAndFigure bars
    • Will always return a value of one (1) which represents 100% during a strategy backtest


    NOTE: This property does not track the completion percent of historical bars. When accessing it on a historical bar it will return the progress of the currently building bar. All historical bars are already 100% complete and you can check if it is a historical bar with "if (Historical)".



    Property Value

    A double value representing a percent. e.g. 50% complete would return 0.5.
    If you wanted to see if something was 95% complete, you would use 0.95, not 95 . You can use (95.0 / 100.0) if 95 is easier to work with than 0.95 .

    Second, DataSeries are maintained by Ninja internally. Their values should not be checked during the same OnBarUpdate that they are set, and calling reset is unnecessary if set is never called during the current bar. I would recommend restructuring your code like this functionally equivalent example :

    Code:
    
    if(High[0] <High[1] +TickSize && Low[0] >Low[1] -TickSize )
    {
        Plot0.Set(Close[0]);
        Alert(Instrument.FullName + CurrentBar,NinjaTrader.Cbi.Priority.High, "Getready for insider",  "Alert1.wav", 10, Color.Black, Color.Yellow);
    }
    Please try this out and let us know if any other questions come up.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      thanks and it works. however the alert keeps coming for every tick after the trigger. how can i ensure that it only rings once per bar?
      Alert(Instrument.FullName + CurrentBar,NinjaTrader.Cbi.Priority.High, "Getready for insider", "Alert1.wav", 10, Color.Black, Color.Yellow);

      Comment


        #4
        If you have CalculateOnBarClose = false, you can use FirstTickOfBar as follows :

        Code:
        if(FirstTickOfBar && High[0] <High[1] +TickSize && Low[0] >Low[1] -TickSize )
        Otherwise, if you would like to filter this out so that a certain time period has to elapse, you can use

        Code:
        
        private int barsBetween = 0;
        protected override void OnBarUpdate()
        {
        
        // ...
        
        if( (++barsBetween > 5) && High[0] <High[1] +TickSize && Low[0] >Low[1] -TickSize )
        {
            barsBetween = 0;
        
        Please feel free to combine both.
        Jessica P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by swcooke, Today, 12:33 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by NinjaCustomer, Today, 12:10 PM
        2 responses
        8 views
        0 likes
        Last Post NinjaCustomer  
        Started by KINGKODA, Today, 11:48 AM
        0 responses
        3 views
        0 likes
        Last Post KINGKODA  
        Started by mlarocco, Today, 10:52 AM
        6 responses
        17 views
        0 likes
        Last Post mlarocco  
        Started by Eros Lima, Today, 09:45 AM
        2 responses
        7 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Working...
        X