Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Price Oscilator Indicator - Zero Line

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

    Price Oscilator Indicator - Zero Line

    Hello!

    I've tried using "Alert" when Price Oscilator "touches" zero line, but not possible. NinjaTrader Alert doesn't recognize "zero line", so it's not possible use this variable.

    Please, anybody could help me do code this indicator?
    Attached Files

    #2
    Hello TRADER_F,

    Because the 0 line is just a value of 0 you can configure the alert to use a numeric value of 0 in the condition, you don't need to reference the line at all. Alerts only use Plots so any indictors which specific values like that would need to be configured as a numeric value in the condition.

    Comment


      #3
      Hello Jesse!

      Thank you for your reply!

      I've followed your suggestion, but didn't work.

      Please, see attached file!
      Attached Files

      Comment


        #4
        Hello TRADER_F,

        Checking equals for prices won't work in NinjaScript. You would need to use Less than or equal to or greater than or equal to depending on the situation. Alternatively you can check a crossing of the price and 0 which would be able to work. NinjaTrader uses the C# type double to store numbers, doubles cannot be compared for equality. There is some information about why that happens in the following page:



        One possible solution for checking if the value equals 0 in the alert would be to form 2 conditions. If the price is less than 0.1 and greater than -0.1, that gives a margin of error so when the value is near 0 it would alert.

        Comment


          #5
          Hello Jesse!

          Instead just "Equals" I added "Cross above" and "Cross below".

          It works!

          Thank you

          Comment


            #6
            Hello Jesse!

            I wanna create an alert or indicator for following situations using Price Oscilator:
            - when price goes up and Price Oscilator goes down
            - when price goes down and Price Oscilator goes up

            Any clue how to create these alerts or create an indicator?

            Comment


              #7
              Hello TRADER_F,

              You would have to use price conditions for that. For example to know the price is going down you can set up any number of conditions comparing a bar to the previous bar. That could be as simple as checking if the 0 bars ago price is less than the 1 bars ago price. You can repeat that as many times as needed if you wanted to find a trend, for example if you wanted 3 bars in a row you would have 3 conditions and the bars ago would be [0] < [1] and [1] < [2] and [2] < [3].

              The same concept would be used to find if the oscillator is rising, you would compare if the current bar value is greater than the previous bar value and so on for as many bars as you wanted to check. Each set of basr ago needs an individual condition so that they are all true to find the specific price situation you wanted.

              Comment


                #8
                Hello Jesse!

                This would be an alert or an indicator?

                Could you help me build this alert or code this indicator?

                Comment


                  #9
                  Hello TRADER_F,

                  You can do that in the alerts window or also an indicator. The main take away here is that you need to form multiple price conditions to check if the Close is rising/falling and also if the indicator value is rising/falling. I would suggest starting simple to just check for a down bar and an up bar. That would be:

                  For the price series such as close a you would check if the Close of 0 bars ago s Lower than the close of 1 bars ago.
                  For the indicator plot you would check if the plot of 0 bars ago is greater than the plot of 1 bars ago.

                  Comment


                    #10
                    Hello Jesse!

                    I really don't know how to code it.

                    I think it's better ask if any member here could help me!

                    Thank you anyway!

                    Comment


                      #11
                      Hello TRADER_F,

                      You don't need to code anything, you would just need to make those type of conditions in your alert. When you select price series or indicators you can specify the number of bars ago which you want data for. To know if a bar is up or down you can check if the close of the current bar is greater/lesser than the previous bar.

                      Comment


                        #12
                        Hello Jesse, how are you?

                        I was able to build some alerts following your instructions. Thank you!

                        But I noticed there is no way to save alerts (I mean, save templates).

                        So how my I save these alerts? I've created MANY for each timeframe.

                        Regards!

                        Comment


                          #13
                          Hello TRADER_F,

                          At this time there is not a way to save alerts as templates due to how alerts are tied to the tool being used. Alerts heavily rely on the manual modifications in the tool being used. For example you manually apply indicators to a chart and only then the alert knows about those indicators to be able to use them. To be able to save templates for alerts you would need to use NinjaScript instead and make an indicator. That would let you define any indicators or prices being used in code so that the tool being used has those items for the alert. Additional steps like adding user inputs would let you further control the indicator based on a template you saved so you could make 1 indicator and apply it in many different ways by using a template to control its properties.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                          0 responses
                          647 views
                          0 likes
                          Last Post Geovanny Suaza  
                          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                          0 responses
                          368 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by Mindset, 02-09-2026, 11:44 AM
                          0 responses
                          108 views
                          0 likes
                          Last Post Mindset
                          by Mindset
                           
                          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                          0 responses
                          571 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by RFrosty, 01-28-2026, 06:49 PM
                          0 responses
                          573 views
                          1 like
                          Last Post RFrosty
                          by RFrosty
                           
                          Working...
                          X