• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Why is this plotting only one line?

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

    Why is this plotting only one line?

    I'm trying to write a lot of 'simple' code modules for myself to get better at this.

    It's not working.

    Why does this only plot one line and not 3 nearly parallel ones? Actually, it seems to print all 3 lines right on top of each other...

    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.DarkGreen), PlotStyle.Line, "WaveHi"));
    Add(new Plot(Color.FromKnownColor(KnownColor.DimGray), PlotStyle.Line, "WaveMid"));
    Add(new Plot(Color.FromKnownColor(KnownColor.DarkRed), PlotStyle.Line, "WaveLow"));
    PriceTypeSupported = true;
    Overlay = true;
    }

    protected override void OnBarUpdate()
    {
    WaveHi.Set(CurrentBar == 0 ? High[0] : High[0] * (2.0 / (1 + wavePeriod)) + (1 - (2.0 / (1 + wavePeriod))) * Value[1]);
    WaveMid.Set(CurrentBar == 0 ? Close[0] : Close[0] * (2.0 / (1 + wavePeriod)) + (1 - (2.0 / (1 + wavePeriod))) * Value[1]);
    WaveLow.Set(CurrentBar == 0 ? Low[0] : Low[0] * (2.0 / (1 + wavePeriod)) + (1 - (2.0 / (1 + wavePeriod))) * Value[1]);

    }

    #2
    Hello Darth_Trader,

    Thank you for your post.

    The indicator code is plotting three separate lines on the Price Panel of the Input Series without issue on my end.

    Can you provide a screenshot of what you are seeing on your chart?

    I look forward to your response.
    Patrick H.NinjaTrader Customer Service

    Comment


      #3
      It DOES show 3 lines, but it should be the Raghee Horner 34 EMA wave of 3 34-EMAs one plotted to close[0], one to high[0] and one to low[0].


      These are all right on top of each other. My code is in the first post.

      How do you set the "WaveHi.Set" to the high[0]? I guessed, and it doesn't seem to be working.

      What it SHOULD look like is the second image.

      The point to this, btw, is not to download someone else's indicator...I'm sure this has been done over 1,000 times. I just want to program an easy thing myself...but it's never easy.
      Attached Files
      Last edited by Darth_Trader; 06-24-2015, 06:39 AM.

      Comment


        #4
        Hello,

        It looks like your code is working as expected from the standpoint of drawing the plots, but there may be something wrong with the formulas you are using for your wave calculations. When I set wavePeriod to 34 in my code, I'm seeing what you are seeing, but when I substitute a smaller number, such as 3 or 4, the waves look much more like your second screenshot.

        I believe I may have found the source of the issue, but I cannot be certain without knowing exactly what the formula should be for this type of wave pattern. I notice that the final step in all three formulas is to multiply by Value[1], which would be the value of the WaveHi plot one bar ago. When I changed this to represent the value of each specific plot one bar ago (Values[0][1] for WaveHi, Values[1][1] for WaveMid, Values[2][1] for WaveLow), then I'm seeing something much more smooth using 34 as the wavePeriod value.

        Below you can see a screenshot of my chart after making that change, with wavePeriod = 34:

        http://screencast.com/t/8z5YsQo5
        Dave I.NinjaTrader Product Management

        Comment


          #5
          the calculation is simply (3) 34-period EMA's

          1) set to High[0]
          2) set to Close[0]
          3) set to Low[0]

          That's it.

          Comment


            #6
            BTW, I simply cut n pasted those from the EMA indicator.

            Then changed Input{0] to either High/Close/Low.

            Comment


              #7
              It gives me an error.

              WaveHi.Set(CurrentBar == 0 ? High[0] : High[0] * (2.0 / (1 + wavePeriod)) + (1 - (2.0 / (1 + wavePeriod))) * Value[0][1]);
              WaveMid.Set(CurrentBar == 0 ? Close[0] : Close[0] * (2.0 / (1 + wavePeriod)) + (1 - (2.0 / (1 + wavePeriod))) * Value[1][1]);
              WaveLow.Set(CurrentBar == 0 ? Low[0] : Low[0] * (2.0 / (1 + wavePeriod)) + (1 - (2.0 / (1 + wavePeriod))) * Value[2][1]);

              Comment


                #8
                You should be using Values (plural), rather than Value. You can see more information about Value and Values at the links below:

                http://ninjatrader.com/support/helpG...nt7/?value.htm

                http://ninjatrader.com/support/helpG...t7/?values.htm

                If you really only need an EMA, then you might consider using the EMA() indicator method, instead, like so:

                Code:
                Edited:
                WaveHi.Set(EMA(High, 34)[0]);
                WaveMid.Set(EMA(Close, 34)[0]);
                WaveLow.Set(EMA(Low, 34)[0]);
                Last edited by NinjaTrader_DaveI; 06-24-2015, 11:57 AM.
                Dave I.NinjaTrader Product Management

                Comment


                  #9
                  New Errors...

                  THIS is my problem...no matter what I copy/paste/etc...I get errors and try to find out why in the manual...all to no avail usually.
                  Attached Files

                  Comment


                    #10
                    Originally posted by NinjaTrader_Dave View Post
                    You should be using Values (plural), rather than Value. You can see more information about Value and Values at the links below:

                    http://ninjatrader.com/support/helpG...nt7/?value.htm

                    http://ninjatrader.com/support/helpG...t7/?values.htm

                    If you really only need an EMA, then you might consider using the EMA() indicator method, instead, like so:

                    Code:
                    WaveHi.Set(EMA(High[0], 34));
                    WaveMid.Set(EMA(Close[0], 34));
                    WaveLow.Set(EMA(Low[0], 34));
                    Your indexer is misplaced.
                    Code:
                    WaveHi.Set(EMA(High, 34)[0]); //etc.

                    Comment


                      #11
                      Koganam is right, as usual. You will need to pass in the data series to the EMA method, then add the indexer at the end, the way that he shows below. The way that I had it, we were passing in an index of the data series, rather than the data series itself.
                      Dave I.NinjaTrader Product Management

                      Comment


                        #12
                        Thank You!

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by TonyParisi, Today, 07:38 AM
                        1 response
                        5 views
                        0 likes
                        Last Post NinjaTrader_Kate  
                        Started by tgn55, 09-24-2019, 06:34 AM
                        12 responses
                        46 views
                        0 likes
                        Last Post tgn55
                        by tgn55
                         
                        Started by jasphere, Today, 07:37 AM
                        4 responses
                        20 views
                        0 likes
                        Last Post jasphere  
                        Started by w0lverine, Today, 07:06 AM
                        1 response
                        7 views
                        0 likes
                        Last Post NinjaTrader_PaulH  
                        Started by aslane, Today, 07:17 AM
                        3 responses
                        9 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Working...
                        X