Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Duplicating and then Modifying an Indicator

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

    Duplicating and then Modifying an Indicator

    I'm trying to duplicate an indicator so that I can keep the original and then make some modifications to the new one. I opened the existing indicator in the ninjascript editor and then did "Save As" saved as new name. Tried to compile and got some errors regarding duplicate public enum. I commented those out. It compiled ok but when trying to apply to the chart I get this error "Unhandled exception: Unable to cast object of type NinjaTrader.NinjaScript.Indicators.NewIndicatorNam e to type NinjaTrader.NinjaScript.Indicators.OldIndicatorNam e.

    Any ideas or perhaps my duplication method was bad. The indicator I'm attempted to modify is https://ninjatraderecosystem.com/use...indicator-nt8/
    I like how it's made but just am altering the pivot calculations.

    #2
    Hello synthhokie,

    Thanks for your post.

    This error indicates that it is likely that a TypeConverter in the script is causing the error to occur.

    I have created a copy of the NTSvePivots indicator named NTSvePivotsMod, commented out the enums that thew a duplicate enum error, and renamed the TypeConverter around line 33 to use the name of the script copy instead of the original script name. See below.

    The TypeConverter was as follows:
    [TypeConverter("NinjaTrader.NinjaScript.Indicators.NTSvePivotsTypeConverter")]

    We must change this to use the same name as our copy.
    [TypeConverter("NinjaTrader.NinjaScript.Indicators.NTSvePivotsModTypeConverter")]

    See the attached script, NTSvePivotsMod which is a copy of the NTSvePivots indicator.

    Let us know if we may assist further.
    Attached Files
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      This worked perfect. Thank you! Only strange thing is the values for the pivots are slightly off. When example yesterdays (9-14-21) ES 12-21 high = 4479.50 low = 4425.25 close = 4434.75. When I input these in to the "user defined" HLC it works but when using the daily or intraday calculations it doesn't work. I realize this is not your script. Any help would be greatly appreciated. I can also open a new thread.

      Comment


        #4
        Hello synthhokie,

        Thanks for your note.

        When testing the NTSvePivots indicator, I am able to see the indicator working using any HLCCalculation Mode (intraday data, daily bars, and user-defined values). I have attached the indicator to an ES 12-21 Daily chart.

        See the attached screenshot of the indicator working and the settings used.

        Are you able to see the indicator working when using the same settings?

        Let us know if we may assist further.
        Attached Files
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          Yeah it's working fine however after I edited the pivot values they just aren't aligning to calculator math unless I input them as user defined. Here are my pivots. Unless I input C = 4434.75 H = 4479.50 and L = 4425.25. These are the values I see on the daily chart from yesterday. With any calculation mode but user defined they are slightly shifted. Example would be BURH should be 4420.

          Code:
          r = currentHigh - currentLow;
          but2 = currentHigh / currentLow * currentClose;
          bels = currentClose + (r * (1.1 / 2));
          berl = currentClose + (r * (1.1 / 4));
          but1 = bels + (1.168 * (bels - berl));
          berh = bels - (bels - berl) / 2;
          burh = currentClose - (r * (1.1 / 4));
          buls = currentClose - (r * (1.1 / 2));
          bet2 = currentClose - (but2 - currentClose);
          burl = burh - (burh - buls) / 2;
          bet1 = buls - (1.168 * (burh - buls));

          Comment


            #6
            Hello synthhokie,

            Thanks for your note.

            If you are wanting to modify pivot levels, you could try modifying the current pivot levels in the indicator.

            These pivot levels can be found around line 204 in the script and are seen below.

            Also, I am attaching an example script that demonstrates modifying these pivot levels

            Code:
            pp = (currentHigh + currentLow + currentClose) / 3;
            s1 = 2 * pp - currentHigh;
            r1 = 2 * pp - currentLow;
            s2 = pp - (currentHigh - currentLow);
            r2 = pp + (currentHigh - currentLow);
            s3 = pp - 2 * (currentHigh - currentLow);
            r3 = pp + 2 * (currentHigh - currentLow);
            pl = currentLow;
            s1m = (pp - s1) / 2 + s1;
            r1m = (r1 - pp) / 2 + pp;
            s2m = (s1 - s2) / 2 + s2;
            r2m = (r2 - r1) / 2 + r1;
            s3m = (s2 - s3) / 2 + s3;
            r3m = (r3 - r2) / 2 + r2;
            ph = currentHigh;
            If you are wanting to add additional pivot levels to the script, you could use a DiffChecker to compare the NTSvePivots indicator code to the original Pivots indicator code to see how additional pivot levels are added.

            Here is a publicly available line to a DiffChecker: https://www.diffchecker.com/diff

            Let us know if we may assist further.
            Attached Files
            <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

            Comment


              #7
              I was able to modify them and it works other than calculation difference between when using the intraday/daily calc vs the user defined calculation. It's as if it's not getting the previous day data correctly. They are close but off buy a few ticks/points. Have to wonder if the indicator is maybe using the settlement as the close or something. I don't know enough about the code to really say.

              Comment


                #8
                Hello synthhokie,

                Thanks for your note.

                Are you using the PriorDayOHLC indicator to visually get the high, low, and close from the previous day to type in the correct UserDefinedHigh, UserDefinedLow, and UserDefinedClose values?

                The currentHigh, currentLow, and currentClose calculations in the NTSvePivots script can be seen around line 227 and use the prior day high, low, and close values when UserDefined values are not specified.

                Something you could do is add prints to your script to print out UserDefinedHigh, high, UserDefinedLow, low, UserDefinedClose, and close. These values could then be compared to see if the same values are being used for calculations.

                Let us know if we may assist further.
                <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                637 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                366 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                107 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                569 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                572 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X