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

Sentiment As an Indicator

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

    #31
    Hello randl,

    Thank you for your response.

    Can you provide your updated code so I may investigate this matter further?

    I look forward to your response.

    Comment


      #32
      Originally posted by randl View Post
      Thank you Patrick and thank you for your patience (believe it or not, I am taking the Script Education from Ninja, but it is slow going I guess). What you gave me worked but I cold not get it to plot. This is what I was doing for plotting:

      Add(new Plot(Color.White, "MTEMA"));

      But then, I had a similar statement for plotting MT and, I dont know how the interpreter can tell the difference or assign on or the other.

      Add(new Plot(Color.Red, "MT"));

      See the attached plot and Properties figure.
      The compiler does not assign values to Plots: you do. The computer merely does whatever you ask. You assign the value to the Plot in the code, and the computer plots it.

      Comment


        #33
        Sentiment as an Indicator

        Here is the code Patrick.
        Attached Files

        Comment


          #34
          Hello randl,

          Thank you for your response.

          Please remove this line from the Initialize() method and re-compile your indicator:
          Code:
          Add(new Plot(Color.White, "MTEMA"));

          Comment


            #35
            I took the line out and recompiled but no change. The first and only Parameter is "EMA 8" but there are no choices for colors or anything which is sort of strange. The only change was, the last line of the Properties window (in my previous attachment) is no longer there.

            Comment


              #36
              Randl,

              Thank you for the reply.

              Just to clarify, you are wanting to plot the MTEMA on the chart correct?
              Cal H.NinjaTrader Customer Service

              Comment


                #37
                I want to plot 2 things on the indicator:
                1. The market thrust which is plotting already (in Red)
                2. The Exponential Moving Average of the Market Thrust (8 being the default)
                Thanks

                Comment


                  #38
                  Randl,

                  Thank you for the info.

                  You will need to set the MTEMA how you want it plot on the chart -
                  Code:
                  MTEMA.Set(EMA(mT, 10)[0]);
                  This will take the EMA 10 period of the Market Thrust Data Series and plot it on the chart.

                  You will need to also add a properties for the Plot of the MTEMA

                  Add this line to the Properties region of the code -
                  Code:
                  [Browsable(false)]
                  [XmlIgnore()]
                  public DataSeries MTEMA
                          {
                              get { return Values[1]; }
                          }
                  This will allow you to have them setup as properties to adjust color and size in the indicators parameters window.

                  Let me know if this is the answer you are looking for
                  Cal H.NinjaTrader Customer Service

                  Comment


                    #39
                    Patrick, clarify for me. What are you referring to as "mT"?

                    The EMA URL says:

                    Syntax
                    EMA(int period)
                    EMA(IDataSeries input, int period)

                    Returns default value
                    EMA(int period)[int barsAgo]
                    EMA(IDataSeries input, int period)[int barsAgo]

                    So mT is probably a DataSeries, but I dont have one with that name.
                    Thanks for all your help.

                    Comment


                      #40
                      Apologies, the correct one is called Values.

                      You would change the mT to Values[1][0]

                      Should look like this -

                      MTEMA.Set(EMA(Values[1][0], 10));

                      The Values will access the first plot set that you call MT or Value.Set() in the OnBarUpdate.
                      Cal H.NinjaTrader Customer Service

                      Comment


                        #41
                        Here is the code in that area:

                        protected override void OnBarUpdate()
                        {

                        // Use this method for calculating your indicator values. Assign a value to each
                        // plot below by replacing 'Close[0]' with your own formula.
                        if(CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired || CurrentBars[2] <= BarsRequired || CurrentBars[3] <= BarsRequired || CurrentBars[4] <= BarsRequired)
                        return;
                        Value.Set((Closes[1][0] * Closes[3][0]) - (Closes[2][0] * Closes[4][0]));
                        Print(Value[0].ToString());

                        mTEMA.Set(EMA(Values[1][0],8)); //This is Line 61

                        mTEMA was defined in Variable: private DataSeries mTEMA;

                        And this is in the middle:
                        protected override void Initialize()
                        {

                        Add("^ADV", PeriodType.Minute, 1);
                        Add("^DECL", PeriodType.Minute, 1);
                        Add("^UVOL", PeriodType.Minute, 1);
                        Add("^DVOL", PeriodType.Minute, 1);
                        mTEMA = new DataSeries(this);
                        Add(new Plot(Color.Red, "MT"));
                        BarsRequired = 1;
                        Add(new Line(Color.Yellow, 0, "Lower"));
                        Overlay = false;


                        Here are the errors: All are from this - "Indicator\MarketThrust.cs" delete below for clarity.

                        1. The best overloaded method match for 'NinjaTrader.Indicator.Indicator.EMA(NinjaTrader.D ata.IDataSeries, int)' has some invalid arguments CS1502 - Line 61 Column 23

                        2. Argument '1': cannot convert from 'double' to 'NinjaTrader.Data.IDataSeries' NT1503 - Line 61 Column 27

                        3. The best overloaded method match for 'NinjaTrader.Data.DataSeries.Set(double)' has some invalid arguments CS1502 - Line 61 Column 13

                        4. Argument '1': cannot convert from 'NinjaTrader.Indicator.EMA' to 'double' CS1503 - Line 61 Column 23

                        Comment


                          #42
                          You won't need the [0] in the Values[1].
                          Cal H.NinjaTrader Customer Service

                          Comment


                            #43
                            Good guess but I still get:

                            1. The best overloaded method match for 'NinjaTrader.Indicator.Indicator.EMA(NinjaTrader.D ata.IDataSeries, int)' has some invalid arguments CS1502 - Line 61 Column 23

                            2. Argument '1': cannot convert from 'double' to 'NinjaTrader.Data.IDataSeries' NT1503 - Line 61 Column 27

                            Any other ideas?

                            Comment


                              #44
                              Originally posted by randl View Post
                              Here is the code in that area:

                              protected override void OnBarUpdate()
                              {

                              // Use this method for calculating your indicator values. Assign a value to each
                              // plot below by replacing 'Close[0]' with your own formula.
                              if(CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired || CurrentBars[2] <= BarsRequired || CurrentBars[3] <= BarsRequired || CurrentBars[4] <= BarsRequired)
                              return;
                              Value.Set((Closes[1][0] * Closes[3][0]) - (Closes[2][0] * Closes[4][0]));
                              Print(Value[0].ToString());

                              mTEMA.Set(EMA(Values[1][0],8)); //This is Line 61

                              mTEMA was defined in Variable: private DataSeries mTEMA;

                              And this is in the middle:
                              protected override void Initialize()
                              {

                              Add("^ADV", PeriodType.Minute, 1);
                              Add("^DECL", PeriodType.Minute, 1);
                              Add("^UVOL", PeriodType.Minute, 1);
                              Add("^DVOL", PeriodType.Minute, 1);
                              mTEMA = new DataSeries(this);
                              Add(new Plot(Color.Red, "MT"));
                              BarsRequired = 1;
                              Add(new Line(Color.Yellow, 0, "Lower"));
                              Overlay = false;


                              Here are the errors: All are from this - "Indicator\MarketThrust.cs" delete below for clarity.

                              1. The best overloaded method match for 'NinjaTrader.Indicator.Indicator.EMA(NinjaTrader.D ata.IDataSeries, int)' has some invalid arguments CS1502 - Line 61 Column 23

                              2. Argument '1': cannot convert from 'double' to 'NinjaTrader.Data.IDataSeries' NT1503 - Line 61 Column 27

                              3. The best overloaded method match for 'NinjaTrader.Data.DataSeries.Set(double)' has some invalid arguments CS1502 - Line 61 Column 13

                              4. Argument '1': cannot convert from 'NinjaTrader.Indicator.EMA' to 'double' CS1503 - Line 61 Column 23
                              Again, the errors tell the story. Line 61 should read:
                              Code:
                              mTEMA.Set(EMA(Values[1],8)[0]); [B][COLOR=Red]//This is Line 61[/COLOR][/B]
                              The Set statement requires a double; you fed it with a DataSeries.

                              Comment


                                #45
                                what does it mean "you fed it with a DataSeries."? Is that a region? if so where is it?

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by ttrader23, 05-08-2024, 09:04 AM
                                9 responses
                                42 views
                                0 likes
                                Last Post ttrader23  
                                Started by ZeroKuhl, Yesterday, 04:31 PM
                                8 responses
                                43 views
                                0 likes
                                Last Post ZeroKuhl  
                                Started by reynoldsn, Today, 07:04 PM
                                0 responses
                                8 views
                                0 likes
                                Last Post reynoldsn  
                                Started by puapwr, Today, 06:09 PM
                                0 responses
                                4 views
                                0 likes
                                Last Post puapwr
                                by puapwr
                                 
                                Started by franciscog21, Today, 05:27 PM
                                0 responses
                                13 views
                                0 likes
                                Last Post franciscog21  
                                Working...
                                X