• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator not plotting

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

    Indicator not plotting

    Greetings,

    I have an indicator that I coded and I simply want one variable within that indicator to plot on a chart. When applying the indicator to a chart nothing plots at all...I don't understand why. The variable I want to plot is called "VarStok".

    In my "Initialize" area I have this code:

    Add(new Plot(Color.FromKnownColor(KnownColor.PaleTurquoise ), PlotStyle.Line, "VarStoK"));

    In my "OnBarUpdate" area I have this code:

    StVarK = SMA(myDataSeries, sl)[0]; Print("Current StVarK = " + StVarK);

    myDataSeries3.Set(StVarK);
    double VarStoK = SMA(myDataSeries3, D)[0];
    myDataSeries4.Set(VarStoK); Print("Current VarStoK = " + VarStoK);

    In my "Properties" area I have this code:

    #region Properties
    [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
    [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
    public DataSeries VarStoK
    {
    get { return Values[0]; }
    }

    Any help appreciated...

    #2
    Maybe you could use that before anything in the OnBarUpdate():

    if (CurrentBar < periodofyourindicator) return;

    ?

    Comment


      #3
      Thank you. But I already have as the first line of code withing "OnBarUpdate" the following:

      if(CurrentBar < 20){return;}

      Comment


        #4
        I find your code a bit weird, what are you exactly trying to do here?

        From what I can see, you should have at least somewhere in your code something like that:

        VarStoK.Set(indicvalues);

        Comment


          #5
          Thank you for the reply. I didn't post all the code within "OnBarUpdate", only that which applies to that particular variable calculation...can you explain a bit about your suggestion you have written?

          Comment


            #6
            What I suggest is within the code you put, there is nowhere where you asign a value to your indicator VarStoK...
            I might miss something here probably...

            Comment


              #7
              Thanks but does not this line assign a value to the variable?:

              double VarStoK = SMA(myDataSeries3, D)[0];

              It assigns the result of the simple moving average of "myDataSeries3" for the period of "D" to the variable VarStok...does it not?

              Comment


                #8
                Well after some thoughts, I think you can use:

                VarStoK.Set(SMA(SMA(myDataSeries, sl), D)[0]);

                instead of your big block.
                Last edited by ryker; 12-06-2007, 02:02 PM.

                Comment


                  #9
                  Thank you for your information. You mean I should REPLACE this line:

                  double VarStoK = SMA(myDataSeries3, D)[0];

                  With this line (what you wrote):

                  VarStoK.Set(SMA(myDataSeries3, D)[0]);

                  If that is correct do I have to add the variable definition into the "Initialize" area (i.e. double VarStok)?

                  Comment


                    #10
                    I mean this big block:

                    StVarK = SMA(myDataSeries, sl)[0]; Print("Current StVarK = " + StVarK);

                    myDataSeries3.Set(StVarK);
                    double VarStoK = SMA(myDataSeries3, D)[0];
                    myDataSeries4.Set(VarStoK); Print("Current VarStoK = " + VarStoK);
                    and nothing in initialize.

                    But, I can be wrong, I have just started using NT and I haven't done any C# for years, just trying to help and understand also how it works :-).

                    Comment


                      #11
                      Well, I was able to make your suggested changes and that seems to have made a big difference--I now have the indicator plotting...

                      I thank you immensely for your time and help...you get a star for the day!

                      Regards

                      Comment


                        #12
                        Great :-).

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by saltminer, Today, 05:19 PM
                        0 responses
                        3 views
                        0 likes
                        Last Post saltminer  
                        Started by martyn73, Today, 04:18 PM
                        0 responses
                        2 views
                        0 likes
                        Last Post martyn73  
                        Started by aprendiz, Today, 03:42 PM
                        0 responses
                        2 views
                        0 likes
                        Last Post aprendiz  
                        Started by 1001111, Today, 09:10 AM
                        1 response
                        18 views
                        0 likes
                        Last Post NinjaTrader_ChrisL  
                        Started by usero86, Today, 06:02 AM
                        1 response
                        12 views
                        0 likes
                        Last Post NinjaTrader_ChrisL  
                        Working...
                        X