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

no indicator on the chart

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

    no indicator on the chart

    I code an indicator and get the message "indicator successfully generated", but I just cannot see anything on my chart. The following is my codes.


    public class divwp2 : Indicator
    {
    #region Variables
    // Wizard generated variables
    // User defined variables (add any user defined variables below)
    private DataSeries dVWAP;
    private DataSeries fastdVWAP;
    private DataSeries slowdVWAP;
    private DataSeries Vvmacd;
    private DataSeries Vvavg;
    private DataSeries Vvdiff;
    #endregion
    /// <summary>
    /// This method is used to configure the indicator and is called once before any bar data is loaded.
    /// </summary>
    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "Vvmacd"));
    Add(new Plot(Color.FromKnownColor(KnownColor.DarkViolet), PlotStyle.Line, "Vvavg"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Navy), PlotStyle.Bar, "Vvdiff"));
    Add(new Plot(Color.FromKnownColor(KnownColor.DarkGray), PlotStyle.Line, "Zeroline"));
    CalculateOnBarClose = true;
    Overlay = false;
    PriceTypeSupported = false;
    dVWAP = new DataSeries(this);
    fastdVWAP = new DataSeries(this);
    slowdVWAP = new DataSeries(this);
    Vvmacd = new DataSeries(this);
    Vvavg = new DataSeries(this);
    Vvdiff = new DataSeries(this);
    }
    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.
    double vVWAP = VWAP().VWAPLine[0];
    dVWAP.Set((Close[0] - vVWAP) / vVWAP);
    double edVWAP = EMA(dVWAP,12)[0];
    double eddVWAP = EMA(dVWAP,26)[0];
    fastdVWAP.Set(edVWAP);
    slowdVWAP.Set(eddVWAP);
    Vvmacd.Set(fastdVWAP[0] - slowdVWAP[0]);
    Vvavg.Set(EMA(Vvmacd,9)[0]);

    Vvdiff.Set(Vvmacd[0] - Vvavg[0]);

    }
    #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 Vmacd
    {
    get { return Values[0]; }
    }
    [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 Vavg
    {
    get { return Values[1]; }
    }
    [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 Vdiff
    {
    get { return Values[2]; }
    }
    [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 Zeroline
    {
    get { return Values[3]; }
    }
    #endregion
    }
    }

    #2
    Hello,

    I'd work backward from your .Set statements and Print() all the input values to see if they are giving you what you think they should.

    I looked over it quickly and didn't see anything that stuck out to me. I am sorry we don't really debug entire systems for people. I you have a specific question, I can help with that.
    DenNinjaTrader Customer Service

    Comment


      #3
      Hello,

      My specific question is that I cannot see those .Set statements getting plot on chart, and also nothing showing up in the Databox. That is why I need your guys help.

      Comment


        #4
        randomwalker,

        The reason is because you aren't setting the values to the plots. You are setting values to DataSeries objects which do not chart. They are just internal objects for you to store values on. If you want to actually plot them you need to use the plot's DataSeries objects.

        According to your code in the Properties region the name for those plots are Vmacd, Vavg, Vdiff, and Zeroline. In OnBarUpdate() you are not setting to any of those plots. You are setting to Vvmacd, Vvavg, and Vvdiff which are different.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Josh View Post
          randomwalker,

          The reason is because you aren't setting the values to the plots. You are setting values to DataSeries objects which do not chart. They are just internal objects for you to store values on. If you want to actually plot them you need to use the plot's DataSeries objects.

          According to your code in the Properties region the name for those plots are Vmacd, Vavg, Vdiff, and Zeroline. In OnBarUpdate() you are not setting to any of those plots. You are setting to Vvmacd, Vvavg, and Vvdiff which are different.

          Thank you very much ,Josh and Ben, it works now.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by rdtdale, Today, 01:02 PM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by alifarahani, Today, 09:40 AM
          3 responses
          16 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by RookieTrader, Today, 09:37 AM
          4 responses
          19 views
          0 likes
          Last Post RookieTrader  
          Started by PaulMohn, Today, 12:36 PM
          0 responses
          10 views
          0 likes
          Last Post PaulMohn  
          Started by love2code2trade, 04-17-2024, 01:45 PM
          4 responses
          41 views
          0 likes
          Last Post love2code2trade  
          Working...
          X