Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ZigZag Issues

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

    ZigZag Issues

    Hello All!

    I'm working on translating some code from Metastock to Ninjatrader 8.

    So MS function TroughBars(1,C,2) finds the most recent (1) Trough with 2 percent (2) deviation from Close dataseries (C).

    Ninjatrader function ZigZag(Close,DeviationType.Percent,2.0,false).LowB ar(0,1,1000) does the same. (1000 - is look back period)

    Should do. But actually it works different it seems, as you can see. Also it is clear that MS function is correct, but NT not.

    Please, help to understand the origin of difference and how to fix it.

    Thanks in advance

    P.S. Functions find the number of bars since trough was find
    Attached Files
    Last edited by makhmout; 12-24-2020, 06:14 AM.

    #2
    Hello makhmout, thanks for writing in.

    It's possible these two indicators are fundamentally different. I do not have MetaStock available so I can not take a look at what the code is doing there. If you are able to see the source code for it, you would need to compare the Zig Zag from NinjaTrader and TroughBars from MetaStock to see where the difference is coming from.

    Please let me know if I can assist any further.

    Comment


      #3
      Thank you for your responce.

      Metastock formula works as:
      SYNTAX troughbars( Nth, DATA ARRAY, % MINIMUM CHANGE)

      FUNCTION Plots the number of bars that have passed from the Nth. This uses the Zig Zag function to determine the. If Nth is 1, then this will return the number of bars that have passed since the most recent. If Nth is 2, this will return the number of bars that have passed since the 2nd most recent and so on.

      EXAMPLE troughbars(1,close,5)

      So, is there any another ways to make this logic in NT code?

      Comment


        #4
        Another view attached.
        ZigZag (2percent) and indicator with ZigZag(Close,DeviationType.Percent,2,false).LowBar (0, 1,1000) plotted
        So indicator counts from random bars offen.
        How can I fix it?
        Attached Files
        Last edited by makhmout; 12-24-2020, 09:47 AM.

        Comment


          #5
          Hello Mahmoud thanks for your reply.

          Any kind of calculation can be done with NinjaScript. You would need to look at the Metastock code that needs to be converted and convert it into NinjaScript code. Unfortunately, I do not have enough details on troughbars to give any sort of insight on how it works.

          Please let me know if I can assist any further.

          Comment


            #6
            Hello Mahmoud,
            I found this conversion I did in the past of a Metastock script from the April 2020 Stocks and Commodities article. You must have the article or a subscription to Stocks and Commodities to view the Metastock code. It could serve as a good reference on how to convert a script from Metastock to NinjaScript:
            OBVM https://ninjatraderecosystem.com/use...l-2020-sc-nt8/

            The original article is available here:
            Technical Analysis of Stocks & Commodities magazine is the savvy trader's guide to profiting in any market. Every month, we provide serious traders with information on how to apply charting, numerical, and computer trading methods to trade stocks, bonds, mutual funds, options, forex and futures.

            The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.

            Comment


              #7
              Ok. Thank you!

              Regardless MS, but NT only: comparing ZigZag indicator and core ZigZag(Close,DeviationType.Percent,2.0,false).LowB ar(0,1,1000) function (at attachment Indicator below chart) - why differences have place? According to LowBar method it should fit to ZigZag pivots?

              Thank you! Click image for larger version

Name:	image_63593.jpg
Views:	399
Size:	192.4 KB
ID:	1133774

              Comment


                #8
                Hello makhmout,

                Please see the demonstration video and test script for testing the ZigZag indicator, LowBar/HighBar methods, and comparing with the chart.

                Demo - https://drive.google.com/file/d/1Uaw...w?usp=drivesdk

                We look forward to assisting.
                Attached Files

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                612 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                355 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                105 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                561 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                564 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X