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 do I vary the color of a dot on open?

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

    How do I vary the color of a dot on open?

    I'm new to this coding stuff. It seems that what I'd like to do should be simple, but nothing I try seems to work.

    On a daily chart, I'd like to be able to have the color of a large dot placed on the open charge according to the relationship of the Open to the prior day's trading. As a simple example, if Open[0] >=Close[1] the dot color should be green. If not then it would be red.

    Can someone kindly get me started?

    #2
    Hello,

    The easiest way (since you are new) is to do something like this:

    if(...condition1....)
    {
    //draw dot of color x
    }
    else if(...condition2...)
    {
    //draw dot of color y
    }
    etc....

    If you are using NT7 there is a "better" way to do it using PlotColors[][], but you may or may not thing it is easier:


    Last edited by mountainclimber; 05-07-2010, 10:34 AM.

    Comment


      #3
      I can get the following to compile, but it doesn't plot anything. I think I must be missing something pretty basic here.

      Can anyone help?

      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

      protected override void Initialize()
      {
      Add(new Plot(Color.FromKnownColor(KnownColor.Lime), PlotStyle.Dot, "HighProb"));
      Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Dot, "LowProb"));

      CalculateOnBarClose = false;
      Overlay = true;
      PriceTypeSupported = false;
      }

      protected override void OnBarUpdate()
      {
      if (Open[0]<Close[1])
      {
      HighProb.Set(Open[0]);
      }
      else
      {
      LowProb.Set(Open[0]);
      }
      }

      Comment


        #4
        Hello,

        Thank you for your note.

        We recieved the message and someone will follow up with you at the latest Monday.

        Thank you for your patience.

        Comment


          #5
          Try putting this at the top of your OnBarUpdate block

          if(CurrentBar < 1) return;

          Comment


            #6
            Yep - that did it!

            Thank you very much.

            I assume that without the CurrentBar check the code attempts to run on the first bar, but can't, so it doesn't run any further?

            Would that be considered a correct assessment?

            Comment


              #7
              basically yes. On the first bar of the chart (far left) the index "1" historical bar does not exist.

              Ask NT support for their link that explains it in detail....I don't have the link handy right now.

              Comment


                #8
                I believe the link being discussed would be this one: http://www.ninjatrader-support2.com/...ead.php?t=3170
                Josh P.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by algospoke, 04-17-2024, 06:40 PM
                6 responses
                48 views
                0 likes
                Last Post algospoke  
                Started by arvidvanstaey, Today, 02:19 PM
                4 responses
                11 views
                0 likes
                Last Post arvidvanstaey  
                Started by samish18, 04-17-2024, 08:57 AM
                16 responses
                61 views
                0 likes
                Last Post samish18  
                Started by jordanq2, Today, 03:10 PM
                2 responses
                9 views
                0 likes
                Last Post jordanq2  
                Started by traderqz, Today, 12:06 AM
                10 responses
                19 views
                0 likes
                Last Post traderqz  
                Working...
                X