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

Using a formula or variable as an input to an Indicator

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

    Using a formula or variable as an input to an Indicator

    I cannot seem to pass a variable as an input to an indicator. Can "IDataSeries" only be Open, High, Low or close ?

    #2
    Please be specific. What do you want to code?

    Comment


      #3
      I want an an EMA of the average of O+H+L+C multiplied by a variable.

      Comment


        #4
        I see. You would need to code your own indicator to achieve that. This indicator would stuff <variable> *(O+H+L+C) into a DataSeries which you then could stuff into EMA. Something like (in pseudo code):
        Code:
        Intilialize()
        {
            bufferSeries = new DataSeries(this);
        }
        
        OnBarUpdate()
        {
            bufferSeries.Set(variable* (Open[0]+High[0]...));
            Value.Set(EMA(bufferSeries, 14)); // 14 period EMA on your series
        }
        Please check out e.g. ADX implementation for details (e.g. dmPlus series).

        Comment


          #5
          protected override void Initialize()
          {
          Add(new Plot(Color.Orange, PlotStyle.Line, "Plot0"));
          TInput = new DataSeries(this);
          }


          protected override void OnBarUpdate()
          {
          TInput.Set((Open[0]+High[0]+Low[0]+Close[0]) *.25) ;
          Plot0.Set(EMA(TInput,3));
          }

          The above is still giving the Errors:

          The best overloaded method match for 'NinjaTrader.Data.DataSeries.Set(double)' has some invalid arguments
          Argument '1': cannot convert from 'NinjaTrader.Indicator.EMA' to 'double'

          Comment


            #6
            Should be:

            Plot0.Set(EMA(TInput,3)[0]);
            RayNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by timko, Today, 06:45 AM
            2 responses
            12 views
            0 likes
            Last Post NinjaTrader_ChristopherJ  
            Started by habeebft, Today, 07:27 AM
            0 responses
            4 views
            0 likes
            Last Post habeebft  
            Started by Tim-c, Today, 03:54 AM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by rocketman7, Today, 01:00 AM
            1 response
            10 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by wzgy0920, 04-23-2024, 09:53 PM
            3 responses
            76 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Working...
            X