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 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, 03: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 gemify, 11-11-2022, 11:52 AM
                        6 responses
                        803 views
                        2 likes
                        Last Post ultls
                        by ultls
                         
                        Started by ScottWalsh, Today, 04:52 PM
                        0 responses
                        3 views
                        0 likes
                        Last Post ScottWalsh  
                        Started by ScottWalsh, Today, 04:29 PM
                        0 responses
                        7 views
                        0 likes
                        Last Post ScottWalsh  
                        Started by rtwave, 04-12-2024, 09:30 AM
                        2 responses
                        22 views
                        0 likes
                        Last Post rtwave
                        by rtwave
                         
                        Started by tsantospinto, 04-12-2024, 07:04 PM
                        5 responses
                        70 views
                        0 likes
                        Last Post tsantospinto  
                        Working...
                        X