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

Color EMA

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

    Color EMA

    hi,
    i tried to rebuild the "plot color" definition from the turorial -

    protected override void Initialize()
    {
    // Add two plots
    Add(new Plot(Color.Blue, PlotStyle.Line, "Upper"));
    Add(new Plot(Color.Orange, PlotStyle.Line, "Lower"));
    }

    protected override void OnBarUpdate()
    {
    // Sets values to our two plots
    Upper.Set(SMA(High, 20)[0]);
    Lower.Set(SMA(Low, 20)[0]);

    // Color the Upper plot based on plot value conditions
    if (Rising(Upper))
    PlotColors[0][0] = Color.Blue;
    else if (Falling(Upper))
    PlotColors[0][0] = Color.Red;
    else
    PlotColors[0][0] = Color.Yellow;

    // Color the Lower plot based on plot value conditions
    if (Rising(Lower))
    PlotColors[1][0] = Color.Blue;
    else if (Falling(Lower))
    PlotColors[1][0] = Color.Red;
    else
    PlotColors[1][0] = Color.Yellow;
    }
    but i'm still receiving the error message **"upper" ist not existing**.
    what am i doing wrong?
    i guess it has something to do with the "set value" section?

    on the other side:
    the indicator: "EMA_Slope_Color" is working fine.

    but as i want to implement it into my existing indicator, without rewriting everything:
    how can i reference to the EMA i'd needed ?

    - I have added a new plot into my indicator: (Add (new Plot (Color.Green, PlotStyle.Line, "EMA1"));
    - than: set CurrentBar <3
    - and than set: EMA1.Set (EMA_Slope_Color (14) [0]);

    but i'm again receving the error message "name "EMA1" not existing"


    thanks for your ideas !!
    Last edited by Tradexxx; 04-11-2015, 03:46 AM.

    #2
    "but i'm still receiving the error message **"upper" ist not existing**.
    what am i doing wrong?
    i guess it has something to do with the "set value" section?"



    You probably haven't defined Upper (or misspelled it). The convention is to put the definition in the Properties region. eg:

    #region Prorerties

    [Browsable(false)]
    [XmlIgnore()]
    public DataSeries Upper
    {
    get { return Values[0]; }
    }

    #endregion

    Comment


      #3
      srvsrv,
      thx so far!
      one problem is solved.
      therefore i now receive the message: "overload" on
      Upper.Set (EMA_Slope_Color (14) [0]);

      Using only on the EMA (but that'S not the indicator i'd like use!) is working
      ???

      Comment


        #4
        Tradexxx,

        Is it possible that the error message you received was something like: "no overload method for EMA_Slope_Color takes n arguments"?

        If the exact same parameter list used with EMA() works but does not work with EMA_Slope_Color() then the later requires either more or different parameters ( no matching signature.)

        If you post all the relevant code I'll take a look at it but, no promises!

        Hope this helps.

        Comment


          #5
          hi srvsrv,
          thank you again for your help!!

          Is it possible that the error message you received was something like: "no overload method for EMA_Slope_Color takes n arguments"?
          exactly, that's displayed! with n = 1 argument
          error message CS-1501.

          but: using any kind of indicator:
          i'll have to put the settings for this indicator i want to have in. otherwise the indicator doesn't know if i want to use it with the seeting of 14 or 23 e.g.

          If the exact same parameter list used with EMA() works but does not work with EMA_Slope_Color() then the later requires either more or different parameters ( no matching signature.)
          EMA-Slope_Color attached. i can't find a misstake if i compare it with the EMA.

          If you post all the relevant code I'll take a look at it but, no promises!

          Hope this helps.
          problem is: i can't export it, due to the errors. think about how to solve this and come back
          Attached Files
          Last edited by Tradexxx; 04-12-2015, 01:40 AM.

          Comment


            #6
            Hi Tradexxx,

            The code for EMA_Slope_Color requires an additional input parameter which is a bool (true or false.)

            I think the easiest way for you to see this is to add the EMA_Slope_Color indicator
            to a chart and look at the "Parameters" section of the Grid.
            Its possible you'll have to scroll to the top of the grid to see the Parameters section.

            Notice that there are two user-settable parameters, the first has the display name:
            "01. Colorcode the EMA?"
            The display name of the second parameter is: "Period"

            When using an Indicator in a Strategy (and without additional effort on your part,) any required input parameter to display an Indicator on a chart must be passed by a Strategy to the Indicator, even if the parameters is not used.

            Using the Strategy Wizard: I added EMA_Slope_Color and found that it will automatically pass the default parameters to the indicator unless you change it, either in the wizard or manually in the code.

            NT's promise that you can develop Strategies without programming knowledge or experience is in my opinion valid, but only if you stick with the "Strategy Wizard" and don't modify the wizard generated code.

            This is not the case regarding Indicators.

            I hope this helps.

            Comment


              #7
              hi srvsrv,

              The code for EMA_Slope_Color requires an additional input parameter which is a bool (true or false.)

              I think the easiest way for you to see this is to add the EMA_Slope_Color indicator
              to a chart and look at the "Parameters" section of the Grid.
              Its possible you'll have to scroll to the top of the grid to see the Parameters section.

              Notice that there are two user-settable parameters, the first has the display name:
              "01. Colorcode the EMA?"
              The display name of the second parameter is: "Period"
              ok, i've seen.
              When using an Indicator in a Strategy (and without additional effort on your part,) any required input parameter to display an Indicator on a chart must be passed by a Strategy to the Indicator, even if the parameters is not used.

              Using the Strategy Wizard: I added EMA_Slope_Color and found that it will automatically pass the default parameters to the indicator unless you change it, either in the wizard or manually in the code.

              NT's promise that you can develop Strategies without programming knowledge or experience is in my opinion valid, but only if you stick with the "Strategy Wizard" and don't modify the wizard generated code.

              This is not the case regarding Indicators.
              in other words (and if i understand you):
              even setting the expression to:
              EMA1.Set (EMA_Slope_Color (14, true) [0]);
              means it won't work (EMA is drawn, but not colorized......)

              so what do you suggest than ?
              Last edited by Tradexxx; 04-13-2015, 01:12 PM.

              Comment


                #8
                even setting the expression to:
                EMA1.Set (EMA_Slope_Color (14, true) [0]);
                means it won't work (EMA is drawn, but not colorized......)
                I'm guessing the compiler error went away.

                I see the same display as you do; no color changes on a chart when the indicator is plotted from within a strategy.
                Someone more experienced with NT might have an easier solution than anything I can think of -- and experimenting with it is more than I can do right now..

                However, the color changes do display when using the Strategy Analyzer.

                As a workaround: you can add the indicator to a chart when you want to see it; if you do this you might want to regenerate the strategy choosing "false" in the "plot on chart" fields.

                Comment


                  #9
                  hello srvsrv,

                  thanks for your help!
                  i guess - like so often - it's just a small pice of code that's missing or wrong.
                  so i will have run it as seperate indicator.
                  but the idea was to create one indicator, having all the needed indicators included.

                  anyone else any ideas ?
                  thx.

                  Comment


                    #10
                    even setting the expression to:
                    EMA1.Set (EMA_Slope_Color (14, true) [0]);
                    means it won't work (EMA is drawn, but not colorized......)

                    so what do you suggest than ?
                    Your statement is setting the value of EMA1. It says nothing regarding its color. Why would you expect that setting a value would have any effect on the color of the plot?

                    If you want to change the color of the EMA1 plot, then you must explicitly set the color of your EMA1 plot to the color of the indicator that you want to use as the color for the setting.

                    Code:
                    PlotColors[0]0] = EMA_Slope_Color (14, true).Plots[0].Pen.Color;

                    Comment


                      #11
                      koganam, thx for your feedback !

                      Originally posted by koganam View Post
                      Your statement is setting the value of EMA1. It says nothing regarding its color. Why would you expect that setting a value would have any effect on the color of the plot?
                      as EMA_Slope_Color is drawing colors for raising / falling EMA i thought it would be enough to set the value i'd like to use. (caused by small knowledge...)

                      If you want to change the color of the EMA1 plot, then you must explicitly set the color of your EMA1 plot to the color of the indicator that you want to use as the color for the setting.

                      Code:
                      PlotColors[0]0] = EMA_Slope_Color (14, true).Plots[0].Pen.Color;
                      looks like this takes me to the point where i started this thread and the definition "upper" wasn't working...
                      :-(
                      Last edited by Tradexxx; 04-14-2015, 07:26 AM.

                      Comment


                        #12
                        Originally posted by Tradexxx View Post
                        looks like this takes me to the point where i started this thread and the definition "upper" wasn't working...
                        :-(
                        That was a very different issue: in that case you had not defined the accessors for Upper, so there was nothing to access.

                        There is no relationship, other than your expectation that the computer would do what you intend, rather than what you instruct. (That IS a joke, or at any rate, is meant to be).

                        Comment


                          #13
                          ahaaaaaaaaaaaaaa;
                          and how does this accessors have to look like ? and where do i have to place it?

                          (belief i used in the variables section: private dataseries upper)

                          Comment


                            #14
                            anybody else who can help me out?
                            thx

                            Comment


                              #15
                              and how does this accessors have to look like ? and where do i have to place it?

                              (belief i used in the variables section: private dataseries upper)
                              To simplify a bit, "accessors" is a term that refers to the get and set "Properties."

                              Checkout http://www.ninjatrader.com/support/h...me_version.htm

                              At the bottom left of the window is a menu -- navigate as follows: NinjaScript->Educational Resources->Basic Programming Concepts

                              You'll save yourself much time and aggravation if you read what the NT folks have prepared for us, it really is a good place to start with NT.
                              (Other "educational resources" specific to NT are available.)
                              Especially at first you might not understand everything in the help guide; that's good time to ask questions.

                              If you're trying to implement a working strategy I suggest you stay with the strategy wizard and forget about developing custom indicators or "hand coding" strategies.

                              If you intend to risk real money and need something that is not available "off the shelf" I advise you take some of that risk capital and hire a programmer.
                              In the long run it'll save you money.

                              Peace

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by frslvr, 04-11-2024, 07:26 AM
                              6 responses
                              105 views
                              1 like
                              Last Post NinjaTrader_BrandonH  
                              Started by trilliantrader, 04-18-2024, 08:16 AM
                              6 responses
                              26 views
                              0 likes
                              Last Post trilliantrader  
                              Started by arvidvanstaey, Yesterday, 02:19 PM
                              5 responses
                              14 views
                              0 likes
                              Last Post NinjaTrader_Zachary  
                              Started by Rapine Heihei, Yesterday, 08:25 PM
                              1 response
                              12 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by Mongo, Yesterday, 11:05 AM
                              6 responses
                              27 views
                              0 likes
                              Last Post Mongo
                              by Mongo
                               
                              Working...
                              X