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

Using the PlotColor when Drawing

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

    Using the PlotColor when Drawing

    Hello,

    I put together an indicator using a Plot that shows a hash and the pricemarker for a higher SMA. For example: I can use it in a 1minute chart so it indicates the SMA20 of a 360min DataSeries. I am not interested in the actual line of that 360 SMA20. I just want to see where it's price is at. Works fine and I can adjust the color through the PlotColor.

    Add(new Plot(Color.LightBlue, PlotStyle.Hash, "RoundedSMA"));
    PlotColors[0][1] = Color.Transparent; // (I use this so it only shows 1 hash)

    Now I would like to add a label into the chart that tells me the timeframe being used. To do that I use DrawText as follows:


    DrawText("tag", false, BarsArray[1].Period.ToString(), -1, (SMA(BarsArray[1],20))[0], 0, textcolor, new Font ("Arial", 7, FontStyle.Regular),StringAlignment.Near, Color.Empty, Color.Empty, 0);

    My question is whether there are any possibilities to define the textcolor through the Plot color?


    sandman






    #2
    Hello sandman,

    The Plots[plot index].Pen.Color will have the color used for the plot. This can be supplied to the DrawText() method.
    https://ninjatrader.com/support/help.../nt7/plots.htm
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Chelsea, Thanks for the fast reply which sounds like it is possible.

      The references are unfortunately limited to Plots. They do not show how the DrawText() method can pull in the Plot colors.

      Is there a sample somewhere that shows more exactly how to do that (I am not a pro-programmer), or could you expand on what you said. In case it helps, I am including my indicator. This shows that currently the color has to be set twice: once for the plotting method which paints a hash and the pricemarker; and twice for the color of the label (using DrawText) and a limited horizontal line. I would want to get rid of the separate color choice and instead have it use the same color which the plot method uses.


      sandman

      Attached Files

      Comment


        #4
        Hello sandman,

        The Color object can be supplied anywhere a Color parameter is accepted.

        DrawText(string tag, string text, int barsAgo, double y, Color color)


        For example:
        DrawText("myText", "Some text", 0, High[0] + 2 * TickSize, Plots[0].Pen.Color);
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Chelsea,

          You make it sound so easy I needed to know that "Plots[0].Pen.Color" is the basic formula.

          Needless to say it works like a charm. Many thanks.

          Have a good day!
          sandman

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by ageeholdings, Today, 07:43 AM
          0 responses
          7 views
          0 likes
          Last Post ageeholdings  
          Started by pibrew, Today, 06:37 AM
          0 responses
          4 views
          0 likes
          Last Post pibrew
          by pibrew
           
          Started by rbeckmann05, Yesterday, 06:48 PM
          1 response
          14 views
          0 likes
          Last Post bltdavid  
          Started by llanqui, Today, 03:53 AM
          0 responses
          6 views
          0 likes
          Last Post llanqui
          by llanqui
           
          Started by burtoninlondon, Today, 12:38 AM
          0 responses
          12 views
          0 likes
          Last Post burtoninlondon  
          Working...
          X