• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ZigZag barsAgo

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

  • mntemel
    started a topic ZigZag barsAgo

    ZigZag barsAgo

    Hi I've been trying to define previous highs and lows by using ZigZag's inbuilt barsAgo function but haven't been able to succeed. Here is the link for the definition in case anyone's interested

    https://ninjatrader.com/support/help...us/?zigzag.htm

    Attached is a simple strategy that plots the ZigZag indicator and prints with bars ago numbers for the previous highs and lows. My understanding is on each bar you can tell "how many bars ago you had the previous high, or the one before that, etc..) I'm applying this to a CL 07-19 contract 200 volume chart in case you want to replicate the case.

    In the attached image, you'll see I marked the Bar at 18:51:59. According to the Print, while at that bar, the previous high was 7 bars ago which seems correct, but the print says the high before that was 12 bars ago which seems incorrect.

    Could you please tell me where i'm going wrong here?

    Thanks
    M
    Attached Files

  • mntemel
    replied
    Hi Chelsea, yes when testing your script; highBarsAgo2 (blue dot) was appearing on a Zigzag high which later on turns out to be false high.

    Thanks
    M

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello M,

    You would need custom logic to change the tag name only when the new leg is set for the new bar.

    When testing the example I provided, did you find the highBarsAgo2 was incorrect?

    Leave a comment:


  • mntemel
    replied
    Hi Chelsea,

    Thanks for sharing the script, I modified it by adding "+CurrentBar" into the draw.dot objects so that we can see the printed dots historically, otherwise dots are moving. Here below is the modification; I'm also attaching the script in case you want to run it in your NT.

    Draw.Dot(this, "high1"+CurrentBar, true, highBarsAgo1, High[highBarsAgo1] + 3 * TickSize, Brushes.Green);
    Draw.Dot(this, "high2"+CurrentBar, true, highBarsAgo2, High[highBarsAgo2] + 7 * TickSize, Brushes.Blue);

    I'm also attaching a screenshot, you'll see how blue and green dots are stored as Highs which were never confirmed in the end. I understand the green dot which is HighBarsAgo1, it might move but even 2 High bars ago are being confirmed as the highs (blue dot) which were actually not Highs. I'm getting false Highs even for 2 high bars ago. If you add this attached strategy on a 10 second NQ chart with 0.05 ZigZag, let it run for 5 mins and you'll see the issue very clearly.

    I feel like I'm repeating myself here I used to use this BarsAgo function up until your v17 release without any issues, I saw the release notes and ZigZag was modified during that update and since then it's not behaving the way it's supposed to be. I would really appreciate if the developer who modified it can also look into this?

    Thanks

    M

    Click image for larger version  Name:	zigzag_dots_3.JPG Views:	1 Size:	147.3 KB ID:	1060432
    Attached Files

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello M,

    Script attached.
    Attached Files

    Leave a comment:


  • mntemel
    replied
    Hi Chelsea, thanks for taking the time to record the video, I tried to replicate your code but I'm not getting the same output, do you mind sharing the code?

    Also, in your video we see that ZigZag is making two highs in a row without making a low, that's not the behavior you see when you use ZigZag as an indi, do you think there might be a bug there?

    THanks
    M

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello M,

    From the help guide:
    "The ZigZag indicator highlights trends based on user defined threshold values and helps filtering the noise in price charts, it's not a classical indicator but more a reactive filter showing extreme price points. In processing it's calculations it can update it's current direction and price extreme point based on newly incoming data, the current developing leg should be thought of temporary until a new leg in opposite direction has been set."
    https://ninjatrader.com/support/help...-us/zigzag.htm

    In other words, it will continue to update until that leg is set. Once a leg is set, and a new leg is forming, the previous set legs no longer update.

    Below is a link to a short video that demonstrates.
    https://drive.google.com/file/d/1KaY...w?usp=drivesdk

    In the video we see the green dot marking the most recently fully set high, and the blue dot marking the second most recently set high.
    We print the time of the bar these dots are over. The most recent high is at 6:48 and the previous is at 6:43.
    In real-time we see that as new bars are appearing on the chart, the barsAgo values increase as the dots need to be drawn further back to mark the bar, however the time of those bars remains the same.
    The time of the dots remain the same until the current zigzag leg finishes building and is set at 7:07. At that moment, as the building leg is set the most recent high is updated to the 7:06 bar and the second most recent is moved to 6:48 as expected.

    Leave a comment:


  • mntemel
    replied
    Hi Paul,

    Thanks for picking this up. I understand that ZigZag repaints the first high bars ago and first low bars ago locations and they are always moving until the price makes a new turn. But what I don't understand is even the second high bars ago and second low bars ago locations are moving. I followed your advice and put draw dot command in my bars ago test strategy. I'm attaching the strategy for your reference. Here you'll see I'm drawing a dot on "second" high bars ago and "second" low bars ago locations. I'm also attaching a screenshot, you'll see these locations keep moving as well, meanwhile ZigZag is printing its lines where you can see the highs and lows.

    I was using this ZigZag's BarsAgo function up until your v.17 update, since then I'm not able to define the highs and lows. Could you please show me how exactly I need to use the ZigZag BarsAgo to define the past highs and lows so that I can integrate it in my strategy.

    thanks
    M
    Attached Files

    Leave a comment:


  • NinjaTrader_PaulH
    replied
    Hello mntemel,

    Thanks for your reply.

    The ZigZag indicator will redraw and I suspect that is what is causing the confusion. To help visualize this, add a Draw.Dot() statement like:

    Draw.Dot(this, "test"+CurrentBar, true, first_high_barsAgo, High[first_high_barsAgo]+3 * TickSize, Brushes.Gold);

    Once added, rerun the strategy and you will see what looks like orphan dots that indicate where a high once existed but no longer does. Please note that this code will place many dots (one per bar) and they will be placed on top of each other so this is only for diagnostics and I would remove the code once you have satisfied the performance.

    Additional comments to help. Please do not name a strategy or indicator using the name of an exiting strategy or indicator as this can be confusing. In this case you named the strategy ZigZag which is the same as the indicator, you could use something like ZigZagtest instead. Please keep the filename, the class name and the name= field as the same name, again this will help you to avoid confusion.

    Leave a comment:


  • mntemel
    replied
    Josh, 7 and 12 at 18:51:59 was just an example line I gave, it wasn't the last print in the output. Here attached you'll see the last print was at 18:54:34 with first high 7 and second high 9 bars ago. So according to what you just said these numbers should match the ZigZag on the chart right now.
    Attached Files

    Leave a comment:


  • NinjaTrader_JoshG
    replied
    mntemel,

    ZigZag lines change in real time, so it only really matters with what you can see on the chart in your screenshot.
    Last edited by NinjaTrader_JoshG; 05-23-2019, 03:49 PM.

    Leave a comment:


  • mntemel
    replied
    Hi Josh, but 7 and 12 were printed at 18:51:59 (the bar I marked with the white arrow).

    Leave a comment:


  • NinjaTrader_JoshG
    replied
    mntemel,

    It is indeed the case in your screenshot. I have attached a modified version of your screenshot to illustrate.
    Attached Files

    Leave a comment:


  • mntemel
    replied
    Thanks for looking into this Josh, so in that case the bars between first high and the second high should be 12 bars, but that doesn't seem to be the case in that chart.

    Leave a comment:


  • NinjaTrader_JoshG
    replied
    mntemel,

    Sorry, I missed it underneath the image. Posting the .cs file is fine. You can also format it directly into your comment.

    Code:
    Print(Time[0].ToString()                
                     +" - first_high_barsAgo:"+first_high_barsAgo
                     +" - second_high_barsAgo:"+second_high_barsAgo
                     +" - first_low_barsAgo:"+first_low_barsAgo
                     +" - second_low_barsAgo:"+second_low_barsAgo
                     );
    The 7 bars ago High is from the current bar. The 12 Bars ago High would be relative to the most recent zig zag high on your chart and not from the Current Bar. This would be expected output.

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by Dert66, Today, 12:11 PM
0 responses
5 views
0 likes
Last Post Dert66
by Dert66
 
Started by jjanguda, Today, 10:04 AM
0 responses
178 views
0 likes
Last Post jjanguda  
Started by sambo81, Today, 09:20 AM
1 response
12 views
0 likes
Last Post sambo81
by sambo81
 
Started by TopGunNote, 05-14-2019, 01:12 PM
3 responses
78 views
0 likes
Last Post dpaulw
by dpaulw
 
Started by Grano, Today, 06:07 AM
0 responses
6 views
0 likes
Last Post Grano
by Grano
 
Working...
X