• 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

Not able to Plot() some lines

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

    Not able to Plot() some lines

    I need some help with the code/syntax. Cannot get it to plot any of the lines.
    Thanks in advance...

    protected override void Initialize()
    {
    Overlay = true;
    Add(new Plot(new Pen(Color.Green, 2), PlotStyle.Square, "high2DA"));
    Add(new Plot(new Pen(Color.Red, 2), PlotStyle.Square, "low2DA"));
    Add(new Plot(new Pen(Color.Blue, 2), PlotStyle.Square, "highMON"));
    Add(new Plot(new Pen(Color.Violet, 2), PlotStyle.Square, "lowMON"));
    Plots[0].Pen.DashStyle = DashStyle.Dash;
    Plots[1].Pen.DashStyle = DashStyle.Dash;
    Plots[2].Pen.DashStyle = DashStyle.Dash;
    Plots[3].Pen.DashStyle = DashStyle.Dash;
    }

    protected override void OnBarUpdate()
    {
    if(Bars.FirstBarOfSession) {
    sessionCount++;
    }
    if (sessionCount < 2)
    return;
    if(Time[0].DayOfWeek == DayOfWeek.Monday) {
    bar = CurrentBar;
    }
    double highSOD = CurrentDayOHL().CurrentHigh[0];
    double lowSOD = CurrentDayOHL().CurrentLow[0];

    high2DA = PriorDayOHLC().PriorHigh[Bars.BarsSinceSession + 1];
    low2DA = PriorDayOHLC().PriorLow[Bars.BarsSinceSession + 1];

    if (bar !=0 ) {
    highMON = PriorDayOHLC().PriorHigh[CurrentBar - bar];
    lowMON = PriorDayOHLC().PriorLow[CurrentBar - bar];
    }

    #2
    2Look4me, I would not expect to see any values plotted for your snippet as you never .Set any value to your series here.

    Did you mean to use something like -

    Code:
    high2DA.Set(PriorDayOHLC().PriorHigh[Bars.BarsSinceSession + 1]);
    low2DA.Set(PriorDayOHLC().PriorLow[Bars.BarsSinceSession + 1]);
    BertrandNinjaTrader Customer Service

    Comment


      #3
      I have defined:

      #region Variables
      private double highSOD, lowSOD, high2DA, low2DA, highMON, lowMON;
      #endregion

      and I am getting the compiling error: 'double' does not contain a definition for 'Set' and no extension method 'Set' ...

      Comment


        #4
        Right, you have defined double variables here - for plotting usage you want a plot value of double dataseries values.

        How the plots should be visualized you have already defined in the Initialize() method via the Add() statement, now you should just need to define the actual series holding the values in your properties section -

        Code:
        [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 high2DA
                {
                    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 low2DA
                {
                    get { return Values[1]; }
                }
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Thanks Bertrand, now I understand. Your explanations are so simple and thorough compared to the help manual!

          In seeing the lines plotted (please see screenshot for Monday 1/12/15 & 1/19/15); how can it be coded so that the Monday High and Low are also calculated on Monday, therefore plotted the rest of the week as well? Presently it doesn't calculate that on Mondays.
          Attached Files

          Comment


            #6
            Hello 2Look4me,

            Thank you for your response.

            You could use DayOfWeek to check that it is Monday, for example:
            Code:
            			if(Time[0].DayOfWeek == DayOfWeek.Monday)
            			{
            				// Set your values
            			}
            Patrick H.NinjaTrader Customer Service

            Comment


              #7
              Your suggestion to use DayOfWeek to check that is Monday is precisely what I have in the code. Just that when it's Monday, the respective High/Low are not calculated, but some other random HL as see in the screenshot and this is were I have a hard time figuring it out

              protected override void OnBarUpdate()
              {
              // Calculate The Bar Number for Monday
              if(Bars.FirstBarOfSession) {
              sessionCount++;
              }
              if (sessionCount < 2)
              return;
              if(Time[0].DayOfWeek == DayOfWeek.Monday){
              bar = CurrentBar;
              }
              // High and Low for Monday
              if (bar !=0 ) {
              highMON.Set(PriorDayOHLC().PriorHigh[CurrentBar - bar]);
              lowMON.Set(PriorDayOHLC().PriorLow[CurrentBar - bar]);
              }
              }

              Comment


                #8
                PriorDayOHLC() refers to PriorDay, which can never be Monday on a Monday. Try using MAX() and MIN().

                Comment


                  #9
                  Hello 2Look4me,

                  CurrentDayOHL() can pull that session's Open, High, or Low as long as you reference the barsAgo value that falls in the session.
                  Patrick H.NinjaTrader Customer Service

                  Comment


                    #10
                    Thanks for the suggestions, I'll go back to the drawing board.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by timcjpfx, Today, 01:18 PM
                    1 response
                    4 views
                    0 likes
                    Last Post NinjaTrader_Tyler  
                    Started by lordvader34, Today, 12:48 PM
                    2 responses
                    11 views
                    0 likes
                    Last Post lordvader34  
                    Started by Newtrader101, Today, 11:06 AM
                    1 response
                    10 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by Newtrader101, Today, 11:03 AM
                    2 responses
                    9 views
                    0 likes
                    Last Post Newtrader101  
                    Started by rickyblah12, Today, 09:57 AM
                    1 response
                    10 views
                    0 likes
                    Last Post NinjaTrader_PaulH  
                    Working...
                    X