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

Calling an indicator within an indicator

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

    Calling an indicator within an indicator

    I want to call an indicator within an indicator and am testing via print first to see if the indicator compiles and is recognised and outputs the correct results
    Is there a different method required for calling a Standard Ninjatrader 8 indicator such as MACD versus an indicator in the list written by Ninjatrader Staff such as bwFractal or an indicator written by myself. eg.

    Print (string.Format ("MACD Diff is {0}", MACD(12, 26, 9).Diff[0])); // compiles and works

    Print (string.Format ("Lower is {0}", bwFractal(2,1,False,False).Lower[0])); // does not compile
    Print (string.Format ("Upper is {0}", bwFractal(2,1,bool,bool).Upper[0])); // does not compile

    The compiler recognises that it requires (int,int,bool,bool) but neither option works

    Thank you in advance for your assistance. Ray

    #2
    Hello Ray12345,

    Are you getting a compile error?

    If so, what is the entire error message?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea

      I thought I was doing something obviously wrong.

      1. The name 'False' does not exist in the current context
      2. Invalid expression term 'bool'

      Comment


        #4
        Hello Ray12345,

        false needs to be lowercase.

        May I have a screenshot of the errors so that I may read the entire error message?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi Chelsea

          Okay thanks. It compiles now as:

          Print (string.Format ("MACD Diff is {0}", MACD(12, 26, 9).Diff[0]));
          Print (string.Format ("Upper is {0}", bwFractal(false,false,2,1).Upper[0]));
          Print (string.Format ("Lower is {0}", bwFractal(false,false,2,1).Lower[0]));

          However the output is okay for MACD but not for bwFractal

          MACD Diff is 0.0638176638174627
          Upper is 0
          Lower is 0
          MACD Diff is -0.0273088692456076
          Upper is 0
          Lower is 0
          MACD Diff is 0.0445584780034842
          Upper is 0
          Lower is 0
          MACD Diff is 0.150900605015946
          Upper is 0
          Lower is 0
          MACD Diff is 0.0814793016211956
          Upper is 0
          Lower is 0

          Comment


            #6
            Hello Ray12345,

            Is this an indicator you have written yourself or one that you have imported?

            If this is a 3rd party script you have imported, I recommend you reach out to the vendor that creates the script for information about the expected values.

            If you add this indicator directly to the same chart using the same parameter values, what values do you see in the databox for those plots?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi Chelsea

              Thankyou for your patience. I want to call the bwFractal indicator inside another indicator. At the moment I am just testing if I am calling it correctly with the right syntax and results.

              It compiles but does not output the actual data so I dont know if I have set it up correctly or I need to add something somewhere to allow it. I notice the little icon on the standard Ninjatrader indicators like MACD are blank or locked, and the MACD works everytime with results. If I use the bwFractal indicator which was converted to NT8 by NinjaTrader_Paul the icon comes up with a lot of lines in it like a self written or 3rd party indicator and it doesn't print the results (just zero) like the MACD does.

              If you want to test it just add those 3 print lines AFTER OnBarUpdate() on ANY indicator and the output window will give you the same result as I am getting.

              I don't know what I need to tweak to get the results to output correctly. Or the same thing needs to be done for all non standard Ninjatrader 8 indicators. The link to the bwFractal indicator (Fractals By Bill Williams) as converted by NinjaTrader_Paul

              This is a conversion of the NT7 indicator Fractals by Bill Williams. Please contact the original author for any questions or comments. 09-13-2021: – Added call to Update() in outputs to improve use in a strategy 11/02/15: – Added rays to connect last two fractal points and extend right – Added ability to set ray/text […]




              Comment


                #8
                Hello Ray12345,

                As far as I can tell, this script does not set a plot value on every bar.

                Use the DataBox and add the indicator to a chart.

                Note the n/a on some bars.

                This appears to be how this script is designed to work.
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by wzgy0920, 04-20-2024, 06:09 PM
                2 responses
                26 views
                0 likes
                Last Post wzgy0920  
                Started by wzgy0920, 02-22-2024, 01:11 AM
                5 responses
                32 views
                0 likes
                Last Post wzgy0920  
                Started by wzgy0920, Yesterday, 09:53 PM
                2 responses
                49 views
                0 likes
                Last Post wzgy0920  
                Started by Kensonprib, 04-28-2021, 10:11 AM
                5 responses
                192 views
                0 likes
                Last Post Hasadafa  
                Started by GussJ, 03-04-2020, 03:11 PM
                11 responses
                3,234 views
                0 likes
                Last Post xiinteractive  
                Working...
                X