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 3rd Party indicators in a NinjaScript

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

    Calling 3rd Party indicators in a NinjaScript

    I'm experimenting with some NS and ran into a problem. If I'm using a Moving Average in a Script, I can write

    Code:
    private SMA smaFast;
    and there is no problem. But if I call a 3rd party MA and write"

    Code:
    private amaEHMA amaehmaFast
    where amaEHMA is the Exponential HMA written by Harry, I get an error that says

    'NinjaTrader.NinjaScript.Strategies.Strategy.amaEH MA(int)' is a 'method' but is used like a 'type'
    So why can I call the SMA indicator with no problem, but get an error when I call amaEHMA?

    TIA

    #2
    Hello dmking,
    Thanks for your post

    I would not expect an error from the snippet you provided. I expect this is the result of something else.

    Can you show us where you are creating the indicator inside OnStateChange()?
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Here ya go Josh:

      Code:
         
      public class LMACross : Strategy
          {
              ///private HMA hmaFast;
              private HMA hmaSlow;
              private amaEHMA amaehmaFast;
      
              protected override void OnStateChange()
              {
                  if (State == State.SetDefaults)
                  {
                      Description    = NinjaTrader.Custom.Resource.NinjaScriptStrategyDescriptionSampleMACrossOver;
                      Name           = "LMACross";
                      Fast            = 8;
                      Slow            = 21;
                      //Adj            = 13;
                      // This strategy has been designed to take advantage of performance gains in Strategy Analyzer optimizations
                      // See the Help Guide for additional information
                      IsInstantiatedOnEachOptimizationIteration = false;
                  }
                  else if (State == State.DataLoaded)
                  {
                      AMAehmaFast     = amaEHMA(Fast);                
                      hmaSlow             = HMA(Slow);
                      //hmaFast            = HMA(Fast);
      
                      AMAehmaFast.Plots[0].Brush     = Brushes.Red;
                      hmaSlow.Plots[0].Brush              = Brushes.Cyan;
                      //AMAehmaAdj.Plots[0].Brush     = Brushes.Yellow;
      
                      AddChartIndicator(AMAehmaFast);
                      AddChartIndicator(hmaSlow);
      //                AddChartIndicator(AMAehmaAdj);
                  }
              }

      Comment


        #4
        dmking,

        It tough to say where exactly the error is occurring here, I do see an error in the spelling/casing of your amaEHMA:

        You created the variable here
        Code:
        private amaEHMA amaehmaFast;
        and then go to instantiate it here but it is not spelled correctly

        Code:
        AMAehmaFast     = amaEHMA(Fast)
        it should look like this instead:

        Code:
        amaehmaFast= amaEHMA(Fast)
        Josh G.NinjaTrader Customer Service

        Comment


          #5
          Thanks Josh, I fixed up the sloppy coding as you suggested, but that's doesn't appear to be where the problem lies. I looks like line 44:
          private amaEHMA amaehmaFast; is the offending code. If I replace amaEHMA with SMA and replace amaehmaFast with SMAFast, the error goes away. Recall that amaEHMA is a 3rd party indicator and is not one of the core NT indicators. D

          Comment


            #6
            Whenever there is an error with a 3rd party indicator (esp with an indicator you paid for) you should always start your quest for support with that 3rd party.

            Harry would clear this up in a heartbeat, I'm sure.

            Comment


              #7
              When you have any question regarding an "ama"-indicator, please contact me via private message or send a notice to LizardIndicators support.

              If you wish to call the Exponential Hull Moving Average amaEHMA, you need to add a line to the "Using declarations":

              Code:
              "using NinjaTrader.NinjaScript.Indicators.LizardIndicators;"
              That should fix the problem.

              Comment


                #8
                David,

                Thanks for responding. Harry has reached out and his suggestion fixed everything.

                D

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NRITV, Today, 01:15 PM
                2 responses
                6 views
                0 likes
                Last Post NRITV
                by NRITV
                 
                Started by frankthearm, Today, 09:08 AM
                7 responses
                30 views
                0 likes
                Last Post NinjaTrader_Clayton  
                Started by maybeimnotrader, Yesterday, 05:46 PM
                5 responses
                25 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by quantismo, Yesterday, 05:13 PM
                2 responses
                18 views
                0 likes
                Last Post quantismo  
                Started by adeelshahzad, Today, 03:54 AM
                5 responses
                33 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Working...
                X