Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

ZigZag misbehaving in Strategy

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

    ZigZag misbehaving in Strategy

    Hi,

    I added the Zigzag indicator into my strategy to find Highs and Lows, code below

    ZigZag1 = ZigZag(Close, DeviationType.Percent, 0.05, true);
    ZigZag1.Plots[0].Brush = Brushes.DodgerBlue;
    AddChartIndicator(ZigZag1);

    When i add the zigzag output in my chart I can see it's making unexpected highs and lows, I'm attaching a screenshot. When I use the same settings and add zigzag as an indicator, it's definitely not matching the output from the strategy. Is this something you guys can look at?

    Just for context, I use Zigzags barsAgo function to capture past highs and lows in my strategy.

    int first_high_barsAgo = ZigZag1.HighBar(0, 1, 999);
    int second_high_barsAgo= ZigZag1.HighBar(0, 2, 999);

    Is there another method you can suggest to capture past highs and lows since this hasn't worked for me perfectly?

    Thanks
    M
    Attached Files

    #2
    Hi mntemel,

    Thanks for your note.

    The code for ZigZag is available to view in the platform under the Indicator folder, studying the High/Lowbar methods could prove useful. What highs and lows do you need for your strategy? From what you posted, you just want the bar number of the most recent occurrence and the second to most recent occurrence of a high bar, is that correct?

    I look forward to your reply.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      hi Chris,

      I'm using the most recent four High and four Low occurrences, and yes all i need is the bar numbers for those occurrences.

      thanks
      M

      Comment


        #4
        Hello mntemel,

        Thanks for your reply.

        If you are not getting the output you need from High/LowBar then a custom method would need to be made to target the needed values of Zig Zag. You can open up the ZigZag indicator>Right click>"Save As" then save it under a different name, this will make a copy of ZigZag that you can modify as needed.

        Please let me know if I can assist any further.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Hi Chris,

          I don't think this is about getting the output I need. I think the problem is the "Use High Low" option of the indicator. If you add this indicator into a blank strategy and plot it (with "Use High Low"=True), and if you add it as an indicator as well, you'll see that they are generating a different outputs. If you False "Use High Low" in both strategy and indicator, then they generate the same output. I think this is a bug.

          Thanks
          M
          Last edited by mntemel; 05-21-2019, 04:28 PM.

          Comment


            #6
            Hello mntemel, thanks for your reply.

            I attached a script that will print out the same values as an applied indicator with the same settings, make sure that "Deviation Type" is the same. The default setting for this script is DeviationType.Percent.
            Attached Files
            Last edited by NinjaTrader_ChrisL; 05-22-2019, 10:23 AM.
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Thanks Chris!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by ZenCortexCLICK, Today, 04:58 AM
              0 responses
              1 view
              0 likes
              Last Post ZenCortexCLICK  
              Started by sidlercom80, 10-28-2023, 08:49 AM
              172 responses
              2,279 views
              0 likes
              Last Post sidlercom80  
              Started by Irukandji, Yesterday, 02:53 AM
              2 responses
              17 views
              0 likes
              Last Post Irukandji  
              Started by adeelshahzad, Today, 03:54 AM
              0 responses
              4 views
              0 likes
              Last Post adeelshahzad  
              Started by Barry Milan, Yesterday, 10:35 PM
              3 responses
              13 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Working...
              X