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

How to reference a Plot or a Line

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

    How to reference a Plot or a Line

    In the attached code, I'm trying to color the Zeroline based on the value of "Diff". On lines 90 and 96 of the code, the PlotColors are referencing Index 4. Index 4 is an "Add" statement to add a line in the "Initialize" section. Are Add lines and Add Plots different from an Indexing point of view?

    I've been looking at this for a long time and can't figure it out. When Diff is positive I want to color the line Green, when the Diff is negative, I want to color the line Red.

    I'd appreciate it if someone can point me in the right direction.

    Thanks...
    Taddypole...
    Attached Files

    #2
    Taddypole, in the code you posted, there are only four Add() references. Please change PlotColors[4][0] to PlotColors[3][0] and see if that fixes it.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Austin,

      I tried all values from 0 to 3 and the only one that made any difference is 2. Using 2 for a reference changed the color of the Difference oscillator but not the zeroline. Refer to the attached picture.

      I'm totally stumped on this one...
      Attached Files

      Comment


        #4
        Taddypole, sorry I overlooked this earlier, but to change the color of a line, it must be created as a plot. Please try creating a zero "line" as a plot with a value of 0 every bar and changing that plot color.
        AustinNinjaTrader Customer Service

        Comment


          #5
          Also, in case you haven't seen it, here is the reference sample for how to color plots with the NT7 approach.
          AustinNinjaTrader Customer Service

          Comment


            #6
            Originally posted by Taddypole View Post
            In the attached code, I'm trying to color the Zeroline based on the value of "Diff". On lines 90 and 96 of the code, the PlotColors are referencing Index 4. Index 4 is an "Add" statement to add a line in the "Initialize" section. Are Add lines and Add Plots different from an Indexing point of view?

            I've been looking at this for a long time and can't figure it out. When Diff is positive I want to color the line Green, when the Diff is negative, I want to color the line Red.

            I'd appreciate it if someone can point me in the right direction.

            Thanks...
            Taddypole...
            Code:
            if (Diff > 0) Lines[int index].Pen.Color = Color.Green;
            else if (Diff < 0) Lines[int index].Pen.Color = Color.Red;
            where int index is the index of the line whose color you want to change.

            Comment


              #7
              Thank you Austin and koganam...

              I now have both methods working.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by CortexZenUSA, Today, 12:53 AM
              0 responses
              1 view
              0 likes
              Last Post CortexZenUSA  
              Started by CortexZenUSA, Today, 12:46 AM
              0 responses
              0 views
              0 likes
              Last Post CortexZenUSA  
              Started by usazencortex, Today, 12:43 AM
              0 responses
              2 views
              0 likes
              Last Post usazencortex  
              Started by sidlercom80, 10-28-2023, 08:49 AM
              168 responses
              2,262 views
              0 likes
              Last Post sidlercom80  
              Started by Barry Milan, Yesterday, 10:35 PM
              3 responses
              10 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Working...
              X