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

2 questions for Ninja Trader support

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

    2 questions for Ninja Trader support

    I've gotten Slope to produce a result. However, it only shows as a lower study. Is there a way to have it applied to an MA? If so, how? The help guide doesn't tell how it can be applied to an MA.

    Second question: Is Ninjascript coding script absolute? Meaning, do you have to use NJ's methods and correctly or your code won't work even if it complies? I've tried to find work arounds for my coding problems. The code complies, but code gets ignored. For example, I've coded if current bar is greater than bar 10 bars ago plot MA UpColor, If current bar is less than bar 10 bars ago plot MA DnColor. else plot MA RangeColor. The code complies, but when I apply it to a chart it ignores the first 2 conditions and goes straight to the "else" condition even when it's obvious the current bar is greater than the bar 10 bars ago. I really don't get it. It seems like Ninja Traders coding script is overriding C#.

    #2
    Hello,

    Thank you for your note.

    The slope can use any series such as an indicator like SMA() or price series such as the High or Close series.

    Below is a public link to the help guide.
    https://ninjatrader.com/support/help...n-us/slope.htm

    Calling SMA() would return an ISeries<double>.

    The example in the help guide demonstrates.
    Taken directly from the help guide;
    Code:
    Print(Slope(SMA(20), 10, 0));

    Any code you have must be valid C#. And the script must be the structure of a NinjaScript... But if you conditions are not evaluating as true, this is likely because the values used in the conditions are not what you are expecting.

    Use prints along with the time of the bar to find out why your conditions are not evaluating as true.

    Below is a public link to a forum post that demonstrates using prints to understand behavior.
    http://ninjatrader.com/support/forum...979#post510979

    Please include the print code and the output and we can assist in analyzing why the condition did not evaluate as true.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I've read the Slope() section in the help guide. I've tried to follow what it says and even research code for slope in NJ7 for pointers. When I execute the code, the indicator shows as a lower study line. I don't want that. can you show me an example of a slope() code that isn't in the help guide?

      Comment


        #4
        Hello jamestrader21x,

        The Slope() method is not an indicator and does not make plot. Are you setting the value returned by slope to plot or something?

        The slope gets a series, and returns a double that represents the slope between two bars on that series, selected with bars ago values.

        Here is an example that uses the Close series.

        Print(Slope(Close, 10, 0));

        This would print the value of the slope on the close series from 10 bars ago to the current bar. This would print to the output window.

        Are you looking at the output window for the prints?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          The following code complies and returns a lower study on a chart whether IsOverlay is true or false.



          Value[0] = (CurrentBar == 0 ? Input[0] : Input[0] * (2.0 / (1 + Period)) + (1 - (2.0 / (1 + Period))) * Value[1]);


          double SlopeEMA = Slope(EMA(15), 5, 0); //slope of last 5min using 15SMA


          double degreesOutput = Math.Atan(SlopeEMA) * ((180 / Math.PI));


          Values[0][0] = degreesOutput;

          if (Value[0] > Values[0][0]);
          {
          PlotBrushes[0][0] = UpColor;
          }
          if (Value[0] < Values[0][0]);
          {
          PlotBrushes[0][0] = DnColor;
          }

          Comment


            #6
            Hello jamestrader21x,

            Can you clarify your meaning when you say 'returns a lower study'?

            Are you saying that value plotted is lower than you expecting?

            If so, have you used prints to find which values are the unexpected values?

            Are you finding the Slope() is returning an incorrect value for the EMA over 5 bars?


            Are you saying that you want the indicator in different panel?

            If so, what is the Panel selection in the Indicator parameters?

            What panel do you want it in?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              returns a lower study mean, the indicator you see on the screen is a lower study...like an RSI or a Stochastic.

              I am trying to make an EMA with a built in Slope parameter. when x positive degrees is reached, the MA plots a color. when x negative degrees is reached, the MA plots a different color. If neither is reached, then the MA plots a color different than the two that have condition parameters. Slope() in the help guide doesn't tell you if you can incorporate it ( the slope) into an MA. I'd like to know what you can and can not do with Slope() method. If I can't use it. I'd like to know how I can create my own slope method.

              Comment


                #8
                Hello jamestrader21x,

                You can make you own indicator out of the slope of the sma if you would like.

                Value[0] is the same as Values[0][0].

                So the coloring will probably never change with this logic. But I would still expect the slope to be plotted.

                The first plot is Value which is the first added plot to the Values collection.




                You are comparing the first bar's current bar to itself. It won't be higher or lower than itself.

                The slope will give the slope and will sometimes be negative.

                Are you finding the value of the plot is incorrect?

                Did you print the value of the slope?
                Are you finding this is incorrect?

                Did you print the value of the degreesOutput?
                Are you finding this is incorrect?

                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by jamestrader21x View Post
                  [SIZE=12px][FONT=arial]]
                  I just code a slope MA for somebody, check it out.

                  Attached Files

                  Comment


                    #10
                    I haven't figured out how to incorporate 'Slope' into the indicator I want to create. However, I have created a momentum EMA using an RSI parameter which does pretty much what I'd like to see on a chart. Coding is hard if you're a newbie. But I'm glad I hung in there and got a pay off. I will check out that indicator. Thank you.

                    Period = 5;
                    UpColor = Brushes.LimeGreen;
                    DnColor = Brushes.Red;
                    NeuColor = Brushes.Navy;
                    AddPlot(Brushes.Orange, "MAColor");



                    Value[0] = (CurrentBar == 0 ? Input[0] : Input[0] * (2.0 / (1 + Period)) + (1 - (2.0 / (1 + Period))) * Value[1]);

                    if(RSI(5, 1)[0] > 60)
                    {if(IsRising(Value))
                    PlotBrushes[0][0] = UpColor;
                    } else if (RSI(5, 1)[0] < 40)
                    {if(IsFalling(Value))
                    PlotBrushes[0][0] = DnColor;
                    } else
                    {
                    PlotBrushes[0][0] = NeuColor;
                    }

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by BarzTrading, Today, 07:25 AM
                    2 responses
                    17 views
                    1 like
                    Last Post BarzTrading  
                    Started by devatechnologies, 04-14-2024, 02:58 PM
                    3 responses
                    20 views
                    0 likes
                    Last Post NinjaTrader_BrandonH  
                    Started by tkaboris, Today, 08:01 AM
                    0 responses
                    4 views
                    0 likes
                    Last Post tkaboris  
                    Started by EB Worx, 04-04-2023, 02:34 AM
                    7 responses
                    163 views
                    0 likes
                    Last Post VFI26
                    by VFI26
                     
                    Started by Mizzouman1, Today, 07:35 AM
                    1 response
                    10 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Working...
                    X