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 futtrader, 04-21-2024, 01:50 AM
          4 responses
          41 views
          0 likes
          Last Post futtrader  
          Started by Option Whisperer, Today, 09:55 AM
          1 response
          11 views
          0 likes
          Last Post bltdavid  
          Started by port119, Today, 02:43 PM
          0 responses
          1 view
          0 likes
          Last Post port119
          by port119
           
          Started by Philippe56140, Today, 02:35 PM
          0 responses
          3 views
          0 likes
          Last Post Philippe56140  
          Started by 00nevest, Today, 02:27 PM
          0 responses
          2 views
          0 likes
          Last Post 00nevest  
          Working...
          X