NexusFi: Find Your Edge


Home Menu

 





ZigZag issue


Discussion in NinjaTrader

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




 
Search this Thread

ZigZag issue

  #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?
About a successful futures trader who didnt know anythin …
Psychology and Money Management
Trade idea based off three indicators.
Traders Hideout
ZombieSqueeze
Platforms and Indicators
Better Renko Gaps
The Elite Circle
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
  #2 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,103

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


© 2024 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 - Privacy Policy - Downloads - Top
no new posts