Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Serializing Indicator

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

    #16
    That WORKED and now it saves in Templates.

    Comment


      #17
      Curious Plots

      The following code is not plotting dots as I would like.
      It is supposed to plot a dot when the FATL line crosses above the SATL line.
      FATL and SATL are DataSeries from added Plots in the Initialize section.

      Add(new Plot(Color.Gray, PlotStyle.Line, "FATL")); Values[0] plots the line
      Add(new Plot(Color.Gray, PlotStyle.Line, "SATL")); Values[2]
      Add(new Plot(Color.Gray, PlotStyle.Dot, "FATLDots"));Values[4] plots dots on the line
      FATL and FATLDots are SET to the same values.

      if (CrossAbove(FATL,SATL,1)== true)
      {
      Plots[4].Pen.Color = crossUpColor;
      Plots[4].Pen.Width = fatColorWidth;
      } else Plots[4].Pen.Color = Color.Transparent;

      Print(Time[0].ToString()+" FATL="+ FATL[0]+" SATL="+SATL);
      Print(Time[0].ToString()+" If FAT Xover SAT, bool="+CrossAbove(FATL,SATL,1));

      The Print statements verify that the 'if' statement is giving correct T and F readings,
      However, when the code is as shown above, NO dots print (ie thay are all transparent).

      If I "// out" the else statement with
      } // else Plots[4].Pen.Color = Color.Transparent;

      then dots appear on EVERY bar.

      I must be missing something . Is there an easy fix?

      Comment


        #18
        magnumdbl, for changing plot colors dynamically, please use NT7's PlotColors method in your code -

        Comment


          #19
          Thanks,
          I rewrote it using
          PlotColors[4][0] = Color.FromArgb(defaultColorOpacity,crossUpColor);

          because I serialized my colors.

          Since I borrowed that piece of code, I'm not sure if I have to put in Opacity for a
          Serialized color or if that was just something that the other developer needed.
          Can anyone tell me?

          Comment


            #20
            Believe you would need that here, as the opacity is a component of the from ARGB derived color you create for your script.

            Comment


              #21
              Originally posted by NinjaTrader_RyanM View Post
              Hello DaveN,

              The most common property to serialize is user defined color inputs. Details on serializing color inputs are here:


              If you can share the properties region of your code we can tell if it's a different property causing this.
              I'm getting "Indicator could not be serialized", and there are user defined colors in the indicator. I would love to view the thread linked above! Alas, the link appears to be broken. Please advise.

              Thanks!

              Comment


                #22
                Originally posted by Style View Post
                I'm getting "Indicator could not be serialized", and there are user defined colors in the indicator. I would love to view the thread linked above! Alas, the link appears to be broken. Please advise.

                Thanks!
                If you search the forum for the phrase: "serialize color", you should eventually come upon this thread: http://www.ninjatrader.com/support/f...ead.php?t=4977

                Comment


                  #23
                  Originally posted by koganam View Post
                  If you search the forum for the phrase: "serialize color", you should eventually come upon this thread: http://www.ninjatrader.com/support/f...ead.php?t=4977
                  Thanks! I went through that thread and did what it said, but I'm still getting the error. I'm attaching the code. Any ideas what I'm doing wrong? Thanks again!
                  Attached Files

                  Comment


                    #24
                    Style, do you have the [XmlIgnore()] for your Color properties added as well, to signify you do custom serialization for those?

                    I also believe your public struct will need custom serialization...

                    Comment


                      #25
                      Originally posted by NinjaTrader_Bertrand View Post
                      Style, do you have the [XmlIgnore()] for your Color properties added as well, to signify you do custom serialization for those?
                      I believe I'm now using [XmlIgnore()] correctly, yet the issue remains. See the attached code.

                      Originally posted by NinjaTrader_Bertrand View Post
                      I also believe your public struct will need custom serialization...
                      I'm not sure what you mean.

                      Thanks for your help!
                      Attached Files

                      Comment


                        #26
                        Yes Style, the coloring inputs should be fine, this is not what breaks it I think - the problem area is the public struct I feel, something we could also not support in our wrapper generation in NinjaScript. If you recode this area to use an enum instead you should be fine.

                        Comment


                          #27
                          Originally posted by Style View Post
                          I believe I'm now using [XmlIgnore()] correctly, yet the issue remains. See the attached code.



                          I'm not sure what you mean.

                          Thanks for your help!
                          Not to contradict Bertrand, but your struct, while declared public, is not a Property of the class, so is unlikely to be causing a problem with the NT wrappers. I use structs pretty liberally myself, declared either as public or protected and have no issue there, unless I try to use the struct as a property, which causes a different issue actually.

                          It seems that the problem may be in your declaration of your DataSeries as public. If you want to access DataSeries outside of the class, you should define the access using a Property referring to a private backing store, not declare the DataSeries as public access in the code.
                          Last edited by koganam; 07-20-2012, 06:29 AM. Reason: Corrected language to use proper programming lingo

                          Comment


                            #28
                            Thanks koganam, I missed those public DataSeries without an associated property...that's it.

                            Comment


                              #29
                              Originally posted by koganam View Post
                              It seems that the problem may be in your declaration of your DataSeries as public. If you want to access DataSeries outside of the class, you should declare them as a Property, not as public access in the code.
                              That did the trick. Thanks!

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              606 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              353 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              105 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              560 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              561 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X