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

Indicator Draw Dots Disapear

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

    Indicator Draw Dots Disapear

    I have and indicator saved in a chart template and when I load the chart the draw dots do not show up, it resets the color to empty and I have to go in and manually change the colors back each time I load a chart... why is this happening? I need the indicator and it's maddening...

    Thanks for any help

    #2
    I think the problem in code maybe here? The Color.Empty lines?

    DrawDot(CurrentBar.ToString(), 0, currDotValue, currDotColor);
    DrawText("dot"+CurrentBar.ToString(), true, dotText, 0, currDotValue, yPixels, currDotColor, pfont,
    StringAlignment.Center, Color.Empty, Color.Empty, 10) ;

    Comment


      #3
      Originally posted by tshirtdeal View Post
      I think the problem in code maybe here? The Color.Empty lines?

      DrawDot(CurrentBar.ToString(), 0, currDotValue, currDotColor);
      DrawText("dot"+CurrentBar.ToString(), true, dotText, 0, currDotValue, yPixels, currDotColor, pfont,
      StringAlignment.Center, Color.Empty, Color.Empty, 10) ;
      I presume that currDotColor is a user-input?

      In that case you have to serialize the color, in order for it to be saved with the template. Do a forum search for "serialize color", with or without the quotes, and you should find out how to do so.

      Comment


        #4
        Hi tshirtdeal,

        Are there any error messages in log tab of control center? If it's serialization as Koganam suggests, the following post can help with serializing color inputs.

        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Thanks for the help...

          There are no errors in the log... Do I simply add the serialization as a code snippet?

          Thanks!
          R.T.

          Comment


            #6
            If there are issues with serialization, there will be errors in the log tab of the control center. I would first isolate one problem to solve at a time with one line of code.

            From the first post there are essentially two issues with your two lines of code:
            Dots don't display
            Color preferences don't save in a template.

            Use only one of those draw statements at a time until you know which is contributing to what problem. Please let us know if you would like assistance once you've narrowed it down to a specific line of code with a specific problem.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Okay, i changed this part of the code :
              {
              currDotValue = Low[1];
              currDotColor = SupportColor;

              To....

              {
              currDotValue = Low[1];
              currDotColor = Color.Red;

              and now it saves the color in chart templates and works, but I have to go into the code whenever I want to change the color, no biggie but perhaps you see an easy complete fix such as creating a default "SupportColor" in the script?

              Thanks for the help,
              R.T.

              Comment


                #8
                Yeah, for custom color inputs use this link here as a guide:


                It's fairly straightforward. You have to setup the properties section just like the sample for the serialization.

                Variables:
                Declare currDotColor in variables region and assign an initial value.
                Code:
                private color currDotColor = Color.Red;
                Properties region:
                Link the lower case color to an Uppercase one that's displayed in your indicator parameters.
                Code:
                [XmlIgnore()]
                [Description("Color for painted region")]
                [GridCategory("Parameters")]
                public Color CurrDotColor
                {
                get { return currDotColor ; }
                set { currDotColor  = value; }
                }
                Add the serialization lines:


                Code:
                [Browsable(false)]
                public string PaintColorSerialize
                {
                     get { return NinjaTrader.Gui.Design.SerializableColor.ToString(currDotColor); }
                     set { currDotColor = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
                }
                Then can use it in OnBarUpdate() with CurrDotColor.
                Ryan M.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by DJ888, Today, 10:57 PM
                0 responses
                1 view
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by MacDad, 02-25-2024, 11:48 PM
                7 responses
                158 views
                0 likes
                Last Post loganjarosz123  
                Started by Belfortbucks, Today, 09:29 PM
                0 responses
                7 views
                0 likes
                Last Post Belfortbucks  
                Started by zstheorist, Today, 07:52 PM
                0 responses
                7 views
                0 likes
                Last Post zstheorist  
                Started by pmachiraju, 11-01-2023, 04:46 AM
                8 responses
                151 views
                0 likes
                Last Post rehmans
                by rehmans
                 
                Working...
                X