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

new ..Auto AndrewsPitchfork indicator

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

    new ..Auto AndrewsPitchfork indicator

    I have been drawing the AndrewsPitchfork for years using the ninja draw tools to drag it where I want on a chart, but recently I decided I would why not just have it automatically drawn by tweaking and adding the necessary code to either the Swing or Zigzag indicator already installed in out NT8 platform. Unlike the Swing and Zigzag that plot to the beginning of a chart because of MaximumBarsLookBack.Infinite. I would only want to have the last 5 max instance's of it drawn so as not to over-clutter my charts with rays shooting everywhere.
    I have two questions for any Ninjatrader coding expert's that may want to answer.... which of these two indicators would be a better base to build this from ? and would it be better to use the Draw.AndrewsPitchfork method or add new plots with the math equations that create the same appearance?

    I appreciate any feedback..

    Quantismo

    #2
    Hello quantismo,

    Thank you for the post.

    I wanted to first clarify, is there a specific reason for choosing the swing or zigzag indicators? I wasn't able to pick out from your description that you use either of these indicators in positioning the drawing object. When you manually position the object do you use the swing or zigzag?

    The base you use would be best started as whatever indicator you base your manual drawing on. If you use the swing, logically the swing would be the best candidate to make that process automatic. If you don't use either of those indicators manually, I wouldn't suggest using them as a starting place as they are both fairly complex indicators. If you are looking to do a similar drawing style, that is possible to extract those parts for a new script as well.

    As far as using a plot or drawing object, that is also going to be your preference. Plots would make the indicator more suitable for use in other tools like the superdom, market analyzer or a strategy for signals. Drawing objects are more of a visual for the chart and your reference.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      I was wondering if someone could share at least a small piece of code on how to make a plot in a indicator make a line from the( Lowest Low) in lets say the past 90 bars to the (Highest High) .
      I do not want to use the draw method just the plot method as was suggested for more versatile access by strategies and other stuff. This is my attempt to start from scratch in making a Auto-Andrew's-Pitchfork indicator , I would like to post it up download section of this forum when its done. If I can wrap my head around the basics of making the plot for at least the B,C line I should be able to figure how to plot the A and then the line that goes from A to intersect at the 50% between B and C. I know I need to code a filter to determine what swing sizes to use also. anyhow if someone has a starter piece of code I would appreciate it. This is more advanced but if the B,C line plot into the future 90 bars instead of a endless ray like the draw method does , that will make this a much better indicator especially if I give it the ability to plot historically.

      Thanks for any help
      Quantismo

      Comment


        #4
        Hello

        You could use the LowestBar and HighestBar for this:




        The help guide shows samples for accessing the prices of the lowest and highest bars. This also would give you the BarsAgo in case you wanted any other values from that point in time.
        Instead of using Bars.BarsSinceNewTradingDay, you could use a number of bars you choose like 90.


        I look forward to being of further assistance.


        JesseNinjaTrader Customer Service

        Comment


          #5
          Can someone provide a small piece a code on how to only go back 90 bars instead of Bars.BarsSinceNewTradingDay ? I couldn't see how this was accomplished in the prior reference.

          Comment


            #6
            quantismo,

            I believe the option Jesse gave would look something like this: By replacing
            • Bars.BarsSinceNewTradingDay with [90], This tells the script to look for the lowest bar back from the initial bar.

            protected override void OnBarUpdate()
            {
            // store the lowest bar ago value
            int lowestBar = LowestBar(Low[90]);

            //evaluate low price from lowest bar ago value
            double lowestPrice = Low[lowestBar];

            //Printed result: Lowest price of the session: 2087.25 - occurred 362 bars ago
            Print(string.Format("Lowest price of the session: {0} - occurred {1} bars ago", lowestPrice, lowestBar));
            }

            Let me know if this helps you at all,
            Cheers

            Comment


              #7
              Hello,

              Thank you for the reply.

              You are correct chrisca but the sample needs to be modified. you would need to place the 90 where the Bars.BarsSinceNewTradingDay is in the sample:

              Code:
              int lowestBar = LowestBar(Low, [B]90[/B]);
              double lowestPrice = Low[lowestBar];         
              Print(string.Format("Lowest price of the session: {0} - occurred {1} bars ago", lowestPrice, lowestBar));
              If you are looking in the help guide, you can also see the inputs for various methods which is helpful when comparing our samples. This one is not directly apparent from that sample the Bars.BarsSinceNewTradingDay is used as the Period, but Period is noted in the methods signature.

              The method's signature looks like this:
              Code:
              LowestBar(ISeries<double> series, int period)
              I look forward to being of further assistance.
              JesseNinjaTrader Customer Service

              Comment


                #8
                Thanks both of you!

                I discovered you need to have this little piece of code in there also for it to be able to plot on a chart
                if (CurrentBar < 90)
                return;

                Thanks
                Quantismo

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by judysamnt7, 03-13-2023, 09:11 AM
                4 responses
                59 views
                0 likes
                Last Post DynamicTest  
                Started by ScottWalsh, Today, 06:52 PM
                4 responses
                36 views
                0 likes
                Last Post ScottWalsh  
                Started by olisav57, Today, 07:39 PM
                0 responses
                7 views
                0 likes
                Last Post olisav57  
                Started by trilliantrader, Today, 03:01 PM
                2 responses
                21 views
                0 likes
                Last Post helpwanted  
                Started by cre8able, Today, 07:24 PM
                0 responses
                10 views
                0 likes
                Last Post cre8able  
                Working...
                X