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

Alert when there are 3+ consecutive bars

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

    Alert when there are 3+ consecutive bars

    Hello, a newbie to ninja script and alert, I wonder how to build an alert to alert me when there are 3 or more consecutive bars appears in any given time? For e.g. I am trading ES 5 mins chart, I am looking for an alert that alerts me when there are 3 consecutive bull bars, especially when the size of bar keep increasing and when the bull bar close above 50% of the body, see bar 62, 63, 64 in attached screenshot. Vice versa for bear bars. Can anyone give me some guidance or has anyone done this before?
    Attached Files

    #2
    Hello diabloooo0,

    Thanks for your question.

    We would reference pervious bars with BarsAgo references.

    So you could check 3 consecutive up bars by checking:

    Code:
    if (Close[0] > Open[0] && Close[1] > Open[1] && Close[2] > Open[2])
    Close[0] > Open[0] checks the current bar,

    Close[1] > Open[1] checks 1 bar ago.

    Close[2] > Open[2] checks 2 bars ago.

    Code:
    if (Close[0] > Open[0] && Close[0] > Open[0] + (Close[1] - Open[1]) / 2)
    The above would check if the bar is an up bar and the close of that up bar is above 50% of the body of the previous bar.

    For more information on referencing price data so you can create custom conditions, please see the detail below. I am also linking our Help Guide reference for developing indicators and using Alert().

    Working with Price Series - https://ninjatrader.com/support/help...ice_series.htm

    Indicator Tutorials - https://ninjatrader.com/support/help...indicators.htm

    Strategy Tutorials - https://ninjatrader.com/support/help...strategies.htm

    Alert() - https://ninjatrader.com/support/help.../nt8/alert.htm

    Making sure there are enough bars in the data series you are accessing - https://ninjatrader.com/support/help...nough_bars.htm

    We look forward to assisting.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thanks Jim, looks like this is not something that can be achieved using the "Alert" menu after right click on the chart? Based on your reply it seems I need to build an indicator which runs the logic you mentioned and the use the Alert() function to pop up a small window on my screen? Also another question is, does the alert only work when the chart is open or it doesn't matter? Say if I am able to build such alert, and added it to AAPL, then I switch to TSLA on the same window, will the alert continue to work for AAPL?

      Comment


        #4
        Hello diabloooo0,

        The three consecutive Up bars can be made with Chart Alerts. The mathematical offsets used in for the second condition would not be possible with Chart Alerts and would need to be done with NinjaScript.

        Using Alerts - https://ninjatrader.com/support/help...ing_alerts.htm

        Condition Builder - https://ninjatrader.com/support/help...on_builder.htm

        When you change instruments on a chart with an Alert applied, you will be prompted if you want to move the alert to the new chart. If you do not move the alert, it will be removed.

        Alert() in NinjaScript will create Alert messages that can be seen in the Alerts Log window, but if you want a pop up, you would need to use NTMessageBoxSimple.Show()



        JimNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Jim View Post
          Hello diabloooo0,

          When you change instruments on a chart with an Alert applied, you will be prompted if you want to move the alert to the new chart. If you do not move the alert, it will be removed.
          Thanks for the quick reply, just want to make sure I understand it correctly, so if I choose to move the alert, will the alert still be effective on the old instrument? in my example, if changes from AAPL to TSLA, will the alert still be effective on AAPL?

          Comment


            #6
            Hello diabloooo0,

            If you change the instrument on a chart that has an indicator applied, you will be prompted if you want to move the alert to the new symbol.

            If you select Yes, the Alert moves to the new symbol, if you select No, the Alert is removed from the chart (and is no longer active on the previous symbol.)
            JimNinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Jim View Post
              Hello diabloooo0,

              If you change the instrument on a chart that has an indicator applied, you will be prompted if you want to move the alert to the new symbol.

              If you select Yes, the Alert moves to the new symbol, if you select No, the Alert is removed from the chart (and is no longer active on the previous symbol.)
              Thanks, that clarifies, so is there any way to set alerts that runs at the backend(i.e. the server side) even the instrument is not open on any window at the client side?

              Comment


                #8
                Hello diabloooo0,

                NinjaTrader would run on your PC, and the alert cannot be run "server-side."

                The Alert logic can be set up in a strategy, and the strategy could be added to the Control Center so it is not tied to a chart.

                If you wanted to use a Condition Builder to set up simple alerts (like the Chart Alerts) in a strategy, the Strategy Builder can be used.

                Strategy Builder 301 (publicly available resource) — https://www.youtube.com/watch?v=_KQF2Sv27oE

                Conditions examples — https://ninjatrader.com/support/help...on_builder.htm

                JimNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by geddyisodin, 04-25-2024, 05:20 AM
                8 responses
                60 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by jxs_xrj, 01-12-2020, 09:49 AM
                4 responses
                3,286 views
                1 like
                Last Post jgualdronc  
                Started by Option Whisperer, Today, 09:55 AM
                0 responses
                5 views
                0 likes
                Last Post Option Whisperer  
                Started by halgo_boulder, 04-20-2024, 08:44 AM
                2 responses
                22 views
                0 likes
                Last Post halgo_boulder  
                Started by mishhh, 05-25-2010, 08:54 AM
                19 responses
                6,189 views
                0 likes
                Last Post rene69851  
                Working...
                X