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

Plot High Low

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

    Plot High Low

    Hello,

    I have the following problem:

    I finished an indicator and I need to plot its High and Low

    if (FirstTickOfBar)
    {
    dsOpen.Set( lastvalueINDICATOR );
    hi = lastvalueINDICATOR;
    lo = lastvalueINDICATOR;
    }

    hi = Math.Max( hi, lastvalueINDICATOR );
    lo = Math.Min( lo, lastvalueINDICATOR );

    dsClose.Set( lastvalueINDICATOR );
    dsHigh.Set( hi );
    dsLow.Set( lo );

    ok this works well, I have checked on Output window

    How can I plot dsHigh.Set and dsLow.Set simultaneously?

    I am trying:

    DrawLine("INDICATOR"+CurrentBar, true , 0, dsLow[0], 0, dsHigh[0], Color.FromArgb(255,255,255,255), DashStyle.Solid, 2);

    but unfortunately began when I enter the oscillator, it don't plot the historical data sets on dsHigh.Set and dsLow.Set

    Thanks for your help

    #2
    Hello merzo,

    To plot values you will need to add a new plot to your indicator and then set the values for that plot.

    The plot will appear on the chart connecting the points of each bar automatically when the script is enabled.

    http://ninjatrader.com/support/helpGuides/nt7/add.htm

    Code:
    Add(new Plot(Color.Blue, "dsHigh"));
    Add(new Plot(Color.Orange, "dsLow"));
    Code:
    Values[0].Set(dsHigh[0]);
    Values[1].Set(dsLow[0]);

    If you want to draw a line, you can do this but it would not be a plot that contains a value for each bar. You would need to use a different bars ago value for the start and end bars ago to see the line. (A line need to be drawn between two or more bars).

    DrawLine(string tag, int startBarsAgo, double startY, int endBarsAgo, double endY, Color color)
    Code:
    DrawLine("dsHighLine"+CurrentBar, true , [B]5[/B], dsHigh[0], [B]0[/B], dsHigh[0], Color.FromArgb(255,255,255,255), DashStyle.Solid, 2);
    DrawLine("dsLowLine"+CurrentBar, true , [B]5[/B], dsLow[0], [B]0[/B], dsLow[0], Color.FromArgb(255,255,255,255), DashStyle.Solid, 2);
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your help ChelseaB

      Unfortunately it's not what I'm looking for
      I would get a graph like HiLo

      No suggestions?

      Comment


        #4
        Hi merzo,

        Ok, I can understand that. You'd like to draw a line on a single bar to mark a point on that bar at a specific price (similar to the HiLo chart style). Is this correct?

        To achieve this you would need to draw lines or rectangles using the Plot override at very specific x and y points.

        The HeikenAshi indicator also does custom rendering over the bar.
        (Tools -> Edit NinjaScript -> Indicator... -> HeikenAshi -> OK)

        Line 256:
        graphics.FillRectangle(brushDown, x - barPaintWidth / 2, y1, barPaintWidth, y4 - y1);

        You could use the graphics library from GDI+ that is provided from the Plot override in NinjaTrader.
        public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)

        This path of custom rendering is not documented in the help guide. However, the HeikenAshi provides a very good example of how this would be done and can be opened from the NinjaScript editor.

        The HiLo chart style (and all chart styles) also use this graphics GDI+ library to render on the chart. However, these cannot be opened in the NinjaScript Editor and must be opened in a 3rd party text editor (I suggest VisualStudio).
        These can be found in:
        Documents\NinjaTrader 7\bin\Custom\Type\@ChartStyles.cs
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi ChelseaB,

          yes, it is correct!

          Thanks for your tips

          Tomorrow I will study the script HeikenAshi


          Best

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by adeelshahzad, Today, 03:54 AM
          5 responses
          32 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by stafe, 04-15-2024, 08:34 PM
          7 responses
          32 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by merzo, 06-25-2023, 02:19 AM
          10 responses
          823 views
          1 like
          Last Post NinjaTrader_ChristopherJ  
          Started by frankthearm, Today, 09:08 AM
          5 responses
          19 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by jeronymite, 04-12-2024, 04:26 PM
          3 responses
          43 views
          0 likes
          Last Post jeronymite  
          Working...
          X