Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using ZigZag indicator to determine pivot points

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

  • redart1021
    replied
    Thanks UltraNIX for posting the answer. Helped with my situation

    Leave a comment:


  • UltraNIX
    replied
    Solved this with advice of NinjaTrader_Kate in another topic to use Strategy Builder for calling indicators.

    This determines a change in lower pivot (V)
    (((ZigZag(DeviationType.Points, 2, true).ZigZagLow[0] != ZigZag(DeviationType.Points, 2, true).ZigZagLow[2])) ? true : false)

    This determines a change in higher pivot (/\)
    (((ZigZag(DeviationType.Points, 2, true).ZigZagHigh[0] != ZigZag(DeviationType.Points, 2, true).ZigZagHigh[2])) ? true : false)

    In case anyone needed it in future.

    Leave a comment:


  • UltraNIX
    replied
    Anybody willing to help?

    Leave a comment:


  • UltraNIX
    replied
    Here, I am adding a marked screenshot. I cannot explain it any better. But your code really doesn't work as it suppose to.
    Attached Files

    Leave a comment:


  • UltraNIX
    replied
    Can you insert my print formula and paste fragment of output window results?

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello UltraNIX,

    I can't confirm any of these values.

    Everything is looking fine on my end. The high of the bar with the zig zags last high is spot on when comparing to the chart on my end..

    How do you know the values are wrong?
    What are you comparing with?

    Leave a comment:


  • UltraNIX
    replied
    Screenshot of what? NinjaScript output window? Chart?

    I mean whole logic should be, if the High[0] is the current High of Zigzag, then High[1] should be High of Zigzag of 1 bar ago, High[2] should be High of ZIgzag of 2 bars ago.

    So let's take this example from my previously stated NinjaScript Output window with print result, which I am going to re-paste:
    Code:
    2020-06-29 20:58:06 | ZigZag High[0]: 3039,5 | ZigZag High[1]: 3038,25 | ZigZag High[2]: 3036,5 2020-06-29 21:00:59 | ZigZag High[0]: 3039,5 | ZigZag High[1]: 3038,25 | ZigZag High[2]: 3036,5 2020-06-29 21:04:26 | ZigZag High[0]: 3039,5 | ZigZag High[1]: 3038,25 | ZigZag High[2]: 3036,5 2020-06-29 21:05:56 | ZigZag High[0]: 3037,75 | ZigZag High[1]: 3037 | ZigZag High[2]: 3037 2020-06-29 21:07:54 | ZigZag High[0]: 3037,75 | ZigZag High[1]: 3037 | ZigZag High[2]: 3037 2020-06-29 21:11:21 | ZigZag High[0]: 3037,75 | ZigZag High[1]: 3037 | ZigZag High[2]: 3037 2020-06-29 21:15:47 | ZigZag High[0]: 3037,75 | ZigZag High[1]: 3037 | ZigZag High[2]: 3037
    We have

    2020-06-29 20:58:06 | ZigZag High[0]: 3039,5 |
    2020-06-29 21:00:59 | ZigZag High[0]: 3039,5 |
    2020-06-29 21:04:26 | ZigZag High[0]: 3039,5 |

    So, according to the previously stated logic, if 2020-06-29 21:04:26 | ZigZag High[0]: 3039,5 |, then Zigzag High [1] should be the previous value of Zigzag High[0], or 3039,50 (value of 2020-06-29 21:00:59) and ZigZag High[2] should be the value of 2 bars ago, same 3039,5 (value of 2020-06-29 20:58:06). Instead, ZigZag High[1] returns 3038,25 (not 3039,50) and ZigZag High[2] returns 3036,5 (not 3039,50).

    I cannot explain it any better, however, I could provide you with additional information if needed. By the way, since it is no part of any strategy or script, you could check this code yourself, use my code for Print and you will get something similar.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello UltraNIX,

    What are you comparing to?

    Are you comparing to a chart?

    Can we see a screenshot? (use the crosshairs and databox to highlight the time and other values of the bar)

    Leave a comment:


  • UltraNIX
    replied
    I used prints and something must be off.

    Code:
    2020-06-29 20:58:06 | ZigZag High[0]: 3039,5 | ZigZag High[1]: 3038,25 | ZigZag High[2]: 3036,5
    2020-06-29 21:00:59 | ZigZag High[0]: 3039,5 | ZigZag High[1]: 3038,25 | ZigZag High[2]: 3036,5
    2020-06-29 21:04:26 | ZigZag High[0]: 3039,5 | ZigZag High[1]: 3038,25 | ZigZag High[2]: 3036,5
    2020-06-29 21:05:56 | ZigZag High[0]: 3037,75 | ZigZag High[1]: 3037 | ZigZag High[2]: 3037
    2020-06-29 21:07:54 | ZigZag High[0]: 3037,75 | ZigZag High[1]: 3037 | ZigZag High[2]: 3037
    2020-06-29 21:11:21 | ZigZag High[0]: 3037,75 | ZigZag High[1]: 3037 | ZigZag High[2]: 3037
    2020-06-29 21:15:47 | ZigZag High[0]: 3037,75 | ZigZag High[1]: 3037 | ZigZag High[2]: 3037
    If code worked correctly, High[0] of 2020-06-29 21:04:26 bar (3039,5) would be High[1] of next bar, i.e. 2020-06-29 21:05:56, but instead it returns 3037.

    Formula for Prints:
    Print(Time[0] + " | ZigZag High[0]: " + High[ZigZag(DeviationType.Points, 2, true).HighBar(0, 1, 100)] + " | ZigZag High[1]: " + High[ZigZag(DeviationType.Points, 2, true).HighBar(0, 1, 100) + 1] + " | ZigZag High[2]: " + High[ZigZag(DeviationType.Points, 2, true).HighBar(0, 1, 100) + 2]);

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello UltraNIX,

    Are you asking for help with logic or help with syntax?
    Are you asking how to declare a method?
    What do you mean by variable formulas?

    Below is a link to a forum post with helpful information about getting started with NinjaScript and C#.
    https://ninjatrader.com/support/foru...040#post786040

    Are you asking how to call the ZigZag indicator?

    Below is a link to the help guide.
    https://ninjatrader.com/support/help...nt8/zigzag.htm

    For example:
    Code:
    if (High[ZigZag(DeviationType.Points, 2, true).HighBar(0, 1, 100)] > High[ZigZag(DeviationType.Points, 2, true).HighBar(0, 1, 100) + 1] && High[ZigZag(DeviationType.Points, 2, true).HighBar(0, 1, 100) + 1] < High[ZigZag(DeviationType.Points, 2, true).HighBar(0, 1, 100)] + 2])

    Leave a comment:


  • UltraNIX
    started a topic Using ZigZag indicator to determine pivot points

    Using ZigZag indicator to determine pivot points

    Hello,

    I want to incorporate Pivot Point stop into my strategy. To achieve this, I would be using ZigZag indicator and 4 variables:
    1) Low_Pivot_Current - Current value of Pivot Low, i.e., whenever ZigZag stops going down and turns back up (does "V"), I would update it., I can think or such a calculation: (ZigZag[0]>ZigZag[1] && ZigZag[1]<ZigZag[2]), But I improvised with ZigZag name usage, It may be different and have additional parameters.
    2) Low_Pivot_Previous - Previous value of Pivot Low, i.e. whenever Low_Pivot_Current is updated, previous value of Low_Pivot_Current becomes current value of Low_Pivot_Previous.
    3) High_Pivot_Current - Current value of Pivot High, i.e., whenever ZigZag stops going up and turns back down (does "/"), I would update it., I can think or such a calculation: (ZigZag[0]<ZigZag[1] && ZigZag[1]>ZigZag[2]), But I improvised with ZigZag name usage, It may be different and have additional parameters.
    4) High_Pivot_Previous - Previous value of Pivot High, i.e. whenever High_Pivot_Current is updated, previous value of High_Pivot_Current becomes current value of High_Pivot_Previous.

    I use such settings for ZigZag:
    Deviation type: Points
    Deviation value: 2
    Use high low: True

    So how can I make 1), 2), 3), 4) variable formulas?

    And then my stop formula would be for longs: if (Close[0] <= Low_Pivot_Current, then ExitLong()
    For shorts: If (Close[0] >= High_Pivot_Current, then ExitShort()

Latest Posts

Collapse

Topics Statistics Last Post
Started by KarterGoff, Today, 08:52 AM
1 response
6 views
0 likes
Last Post NinjaTrader_ChrisL  
Started by AndreaBhs, Today, 08:30 AM
1 response
10 views
0 likes
Last Post NinjaTrader_PaulH  
Started by EnveousColnago, Today, 09:00 AM
0 responses
6 views
0 likes
Last Post EnveousColnago  
Started by hdge4u, Today, 07:50 AM
1 response
8 views
0 likes
Last Post NinjaTrader_ChrisL  
Started by sidlercom80, Today, 08:15 AM
0 responses
9 views
0 likes
Last Post sidlercom80  
Working...
X