NexusFi: Find Your Edge


Home Menu

 





ZigZag issue


Discussion in NinjaTrader

Updated
    1. trending_up 2,112 views
    2. thumb_up 3 thanks given
    3. group 2 followers
    1. forum 1 posts
    2. attach_file 2 attachments




 
Search this Thread
  #1 (permalink)
 
makhmout's Avatar
 makhmout 
Russia, Kazan
 
Experience: Advanced
Platform: NinjaTrader
Broker: NinjaTrader Brokerage
Trading: CL, ES
Posts: 9 since Feb 2012
Thanks Given: 4
Thanks Received: 1

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)and calculate number of bars since it.

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.
Or may be there is another way to calculate it exactly.

Thanks in advance


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Hungary Called for Magyar at 97pct, Ending 16-Year Orban …
Prediction Markets & Event Contracts
Kraken Becomes First US Digital Asset Bank With Direct F …
Cryptocurrency
Ripple Prime Joins Nodal Clear as Clearing Member -- $3 …
Cryptocurrency
Day 96 Missiles Hit Kuwait and Bahrain: June 15 Peace at …
Prediction Markets & Event Contracts
Five Days Until the Gap Dies -- CME Goes 24/7 on All Dig …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #2 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader
Broker: Interactive Brokers
Trading: Futures & Stocks
Posts: 9,887 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,114

The MetaTrader indicator is repainting.It does not start counting from every low bar, but only starts counting when there is a final low. However, the final low can only be identified with hindsight knowledge.

Often it is not understood that the Zigzag indicator is a repainting plot itself. The last leg which is printed can be extended, and the new leg in the opposite direction is only drawn once the selected minimum deviation - 2 percent in your example - has been exceeded. Extension of the current leg requires redrawing the entire leg. Adding a new leg in the opposite direction requires drawing the new leg across several data points.

The NinjaTrader indicator does not wait until the final high point or low point is drawn, but starts counting from each preliminary swing high or swing low. It is non-repainting.
By the way you can easily created a repainting version of the LowBar function to match the MetaTrader algorithm.

In my opinion both concepts are insatisfactory for determining the size of a swing leg. There is a better way of doing this. I would count the number of bars of a swing leg from the revelation point (the price bar for which it is revealed that the prior high or low has becomes a final swing high or swing low) to the next revelation bar. To understand that concept, it is useful to add a two percent trailing stop to the zigzag indicator. The chart attached shows the MetaTrader count which can only be identified with hindsight, and compares it to the actual direction of the current swing leg, which only changes direction once the 2% threshold has been exceeded.

It is all about repainting or non-repainting plots.



ES 03-21 (D-Renko T20) 2021_01_04 (01_08_16)


Reply With Quote




Last Updated on January 3, 2021


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts