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

Add horizontal lines to indicator in strategy script

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

    Add horizontal lines to indicator in strategy script

    Hello. In script I added indicator. And would like to add some horizontal levels to that indicator via script. How to do this?

    #2
    Hi Alexstox,

    Thank you for your post.

    This indicator that you added to the Strategy, is this a default indicator with NinjaTrader or one that you created on your own?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      This is ATR() with some additions. And levels of lines will show min and max value of ATR.

      Comment


        #4
        Alexstox,

        I would recommend that you create a double variable and assign it the MAX or MIN value of the ATR and then pass that value through a DrawHorizontalLine

        http://www.ninjatrader.com/support/h...aximum_max.htm
        http://www.ninjatrader.com/support/h...zontalline.htm
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          As I know this is not optimal solving =))
          As ATR changes through time, this MAX and MIN levels change too. So, this will be zigzag line trough history. Is it possible via indicator method?
          Last edited by alexstox; 12-17-2013, 12:48 PM.

          Comment


            #6
            Alexstox,

            If you want the zig zag effect you will need to create a plot class and then pass through the MAX or MIN values to the plot.
            Code:
            Add(new Plot(Color.Blue, PlotStyle.Line, "myPlot"));
            Code:
            myPlot.Set(MAX(ATR(14), 5)[0]);
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Cal View Post
              Alexstox,

              If you want the zig zag effect you will need to create a plot class and then pass through the MAX or MIN values to the plot.
              Code:
              Add(new Plot(Color.Blue, PlotStyle.Line, "myPlot"));
              Code:
              myPlot.Set(MAX(ATR(14), 5)[0]);
              Dear Cal, can you show me an example?

              Comment


                #8
                Sample is attached.
                Attached Files
                Cal H.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Cal View Post
                  Sample is attached.
                  I thought example is in Reference Samples =)))

                  2. Even if I use Draw, how can I add this zigzag line to indicator panel (window)?

                  Comment


                    #10
                    Alexstox,

                    I'm afraid you've lost me on the last post.

                    Can you elaborate further?
                    Cal H.NinjaTrader Customer Service

                    Comment


                      #11
                      I mean if I use DrawHorizontalLine, how can I add this lines in indicator chart (panel with indicator chart), not on main instrument chart?

                      Comment


                        #12
                        DrawOnPricePanel = false;

                        Put this in the Initialize() method.

                        http://www.ninjatrader.com/support/h...pricepanel.htm
                        Cal H.NinjaTrader Customer Service

                        Comment


                          #13
                          Well, thank you. I can use this in indicator scripting. But I code everything in strategy script. Will it work here? Because I draw other objects like short lines, arrows etc. on price panel.

                          Comment


                            #14
                            Alexstox,

                            You won't be able to use DrawOnPricePanel in the Strategy script. However, what you can do is create an indicator that does all this functionality and then call that indicator from the Strategy.

                            Example of adding the SMA to a Strategy -
                            Code:
                            Add(SMA(14));
                            Otherwise, you would need to use the plot option that I outlined in posts 6 and 8
                            Cal H.NinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_Cal View Post
                              Sample is attached.
                              Dear Cal, to import it via NT I tried to zip it, than import. NT shows message that everything imported OK. But I didn't find that indicator when tried to edit it from Tools-Edit. Than I just copy your file to NinjaTrader 7\bin\Custom\Indicator
                              Now I can Edut it, but can't add it to chart, because there is no "Test2" or something like it in indicators' list.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by AaronKoRn, Today, 09:49 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post AaronKoRn  
                              Started by carnitron, Today, 08:42 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post carnitron  
                              Started by strategist007, Today, 07:51 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post strategist007  
                              Started by StockTrader88, 03-06-2021, 08:58 AM
                              44 responses
                              3,975 views
                              3 likes
                              Last Post jhudas88  
                              Started by rbeckmann05, Today, 06:48 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post rbeckmann05  
                              Working...
                              X