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

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();
    			[B][COLOR="Red"]if(Bars.PercentComplete >95 && Plot0[0]>0)[/COLOR][/B]
    			{
    				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:
    [FONT=Courier New]
    if(High[0] <High[1] +TickSize && Low[0] >Low[1] -TickSize )
    {
        [/FONT][FONT=Courier New][FONT=Courier New]Plot0.Set(Close[0]);
        [/FONT][/FONT][FONT=Courier New][FONT=Courier New][FONT=Courier New]Alert(Instrument.FullName + CurrentBar,NinjaTrader.Cbi.Priority.High, "Getready for insider",  "Alert1.wav", 10, Color.Black, Color.Yellow);
    [/FONT][/FONT]}[/FONT]
    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:
        [FONT=Courier New]if([B]FirstTickOfBar && [/B]High[0] <High[1] +TickSize && Low[0] >Low[1] -TickSize )[/FONT]
        Otherwise, if you would like to filter this out so that a certain time period has to elapse, you can use

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

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by timko, Today, 06:45 AM
        1 response
        7 views
        0 likes
        Last Post gaz0001
        by gaz0001
         
        Started by Waxavi, 04-19-2024, 02:10 AM
        3 responses
        41 views
        0 likes
        Last Post gaz0001
        by gaz0001
         
        Started by Max238, Today, 01:28 AM
        2 responses
        26 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Started by Shansen, 08-30-2019, 10:18 PM
        25 responses
        949 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by JonesJoker, 04-22-2024, 12:23 PM
        8 responses
        44 views
        0 likes
        Last Post JonesJoker  
        Working...
        X