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 FrazMann, Today, 11:21 AM
                0 responses
                3 views
                0 likes
                Last Post FrazMann  
                Started by geddyisodin, Yesterday, 05:20 AM
                8 responses
                51 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by cmtjoancolmenero, Yesterday, 03:58 PM
                10 responses
                36 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by DayTradingDEMON, Today, 09:28 AM
                4 responses
                24 views
                0 likes
                Last Post DayTradingDEMON  
                Started by George21, Today, 10:07 AM
                1 response
                19 views
                0 likes
                Last Post NinjaTrader_ChristopherJ  
                Working...
                X