Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Color Plotting

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

    Color Plotting

    I can't seem to get multiple color on my plot. It will plot in one color only instead of changing based on the LR0 and LR1 values. I've included the code below. Can anyone point me in the right direction?

    ------------------------------

    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));

    ...

    if (LR0 > LR1)
    {
    Plots[
    0].Pen = new Pen(Color.Green);
    }
    if (LR0 < LR1)
    {
    Plots[
    0].Pen = new Pen(Color.Red);
    }
    if (LR0 == LR1)
    {
    Plots[
    0].Pen = new Pen(Color.Orange);
    }

    Plot0.Set (LR0);

    #2
    Plots can only have one color so you will have to employ an approach where you use two plots. Following is a referenfce sample that will show you just how to do that.

    http://www.ninjatrader-support.com/v...ead.php?t=3227
    RayNinjaTrader Customer Service

    Comment


      #3
      I used the suggested code almost verbatim. It is included below. I now get errors:
      "The name "RisePlot" does not exist in the current context.
      Cannot apply indexing with [] to an expression of type 'double'

      -------------

      protectedoverridevoid Initialize()
      {
      Add(
      new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "Rise"));
      Add(
      new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "Fall"));
      Add(
      new Plot(Color.FromKnownColor(KnownColor.Yellow), PlotStyle.Line, "Neutral"));
      CalculateOnBarClose =
      false;
      Overlay =
      false;
      PriceTypeSupported =
      false;
      }
      ///<summary>
      /// Called on each bar update event (incoming tick)
      ///</summary>
      protectedoverridevoid 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 (LR0 > LR1)
      {
      RisePlot.Set(
      1, LR0[1]);
      RisePlot.Set(LR0[
      0]);
      }

      }

      Comment


        #4
        Replace RisePlot with:

        Value.Set(1, LR0[1]);
        Value.Set(LR0[
        0]);
        RayNinjaTrader Customer Service

        Comment


          #5
          Ray, I've done a lot of coding in my life and this language has got to be the most esoteric and confusing one I have ever run across.

          I don't understand what Value.Set does or how that will let me plot different colors based on rise, fall and neutral.

          Also, there must be some very subtle but strict structure necessary because now I go back to create a new version and just typing an "If" statement causes it to declare that a ";" is expected, but I'm using exactly the same statements I used earlier with success. Further to my point, I used the same statements that the example multi-color plot program used, but I get the errors I noted earlier. Goofy stuff, it is. Sigh.

          Comment


            #6
            You can tell Bill Gates that you don't like C#!

            On a serious note, have you checked out our Indicator tutorials in the Help Guide?
            RayNinjaTrader Customer Service

            Comment


              #7
              Touche'

              By the way, I think he is no longer with Microsoft (except of course for owning the company).

              I'll check it out.

              Thanks,
              Paul

              Comment


                #8
                Originally posted by Lambo View Post
                if (LR0 > LR1)
                {
                Plots[0].Pen = new Pen(Color.Green);
                }
                I just want to point out that the property Plots[x].Pen.Color is a useful way to access color x of a multi-color indicator. If you have a bunch of different colors, you will need a bunch of different plots. If you want to change the color of a price bar when one particular color (say for plot i) appears in the indicator, then

                BarColor = Plots[i].Pen.Color;

                ...will do the trick. It's a nice way to combine an indicator and a paintbar into the same indicator.

                -Alex
                Last edited by anachronist; 08-29-2008, 05:56 PM.

                Comment


                  #9
                  Originally posted by Lambo View Post
                  Ray, I've done a lot of coding in my life and this language has got to be the most esoteric and confusing one I have ever run across.
                  Actually, your reference to RisePlot didn't work because you didn't create any plot by that name. Instead, you created a plot called Rise. If you didn't create the code template through the Wizard (and I suggest you do this for better understanding), then you will have to create a definition of Rise and its return value in the properties block.
                  I don't understand what Value.Set does or how that will let me plot different colors based on rise, fall and neutral.
                  All of these are synonymous: Values[0].Set(x), Values[0][0] = x, Rise.Set(x), Rise[0] = x (assuming that Rise is your first [index 0] plot). Sometimes it's convenient to set multiple plot values inside a loop, in which case you can use the Values[] array instead of referencing each individual plot by name. Note Values[] is plural, not singular Value. The singular word refers only to the first plot, I think.
                  Goofy stuff, it is. Sigh.
                  I suggest starting over with the Wizard to define all your inputs and plots, and then look at what it did in the properties block at the end of the code. After you do this enough times, you'll know what is expected when you code indicators by hand, or if you need to add or delete parameters or plots from the indicator.

                  -Alex
                  Last edited by anachronist; 08-29-2008, 02:31 PM.

                  Comment


                    #10
                    Thanks for the comments Alex, helpful.
                    RayNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by WeyldFalcon, Today, 02:07 PM
                    1 response
                    8 views
                    0 likes
                    Last Post NinjaTrader_ThomasC  
                    Started by hfwiley, Today, 03:02 PM
                    1 response
                    12 views
                    0 likes
                    Last Post NinjaTrader_Melissa  
                    Started by pdennis, Today, 02:34 PM
                    1 response
                    9 views
                    0 likes
                    Last Post NinjaTrader_ChrisL  
                    Started by tonynt, Today, 01:47 PM
                    3 responses
                    15 views
                    0 likes
                    Last Post NinjaTrader_Kate  
                    Started by WesFoster, Today, 12:39 PM
                    1 response
                    9 views
                    0 likes
                    Last Post NinjaTrader_Dennis  
                    Working...
                    X