• 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

Histogram in Windows forms

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

    Histogram in Windows forms

    hi,

    what is the best way to display a histogram in NT 7. I was thinking of using using System.Windows.Forms.DataVisualization.Charting; but am I correct in thinking that this is not an option? What would be the alternatives?


    Thanks

    #2
    Hello,

    Thank you for contacting us regarding your inquiry.


    In order to add a histogram, you first would have to put the data in the form of an indicator. If you don't have this accomplished yet, or an indicator doesn't already exist, you could use the indicator wizard to do so.


    I have included a link that reviews plot statements in indicators:
    Within the indicator you would use a Plot statement. Lets use the standard MACD for example:
    Code:
     
     
     Add(new Plot(new Pen(Color.Navy, 2), PlotStyle.Bar, "Diff"));
     
     
    
    Please let us know if we can be of further assistance.
    Last edited by NinjaTrader_PatrickH; 09-03-2015, 10:02 AM.
    Matt L.NinjaTrader Customer Service

    Comment


      #3
      Hi Matt,

      OK so I dont need to program a custom windows form which is great.

      What im trying to do is plot the difference of the close and SMA of the close for the last 500 ticks, so,
      Code:
      Close[0] -  SMA(Close[0], 500) 
      Close[1] -  SMA(Close[0], 500) 
      Close[2] -  SMA(Close[0], 500) 
      .
      .
      .
      Close[500] - SMA(Close[0], 500)
      The question is how would I achieve this . in a loop maybe,
      Code:
      for( i = 0; i < 500; i++)
      {
           // Calculate value
           value = Close[i] - SMA(Close[0])
      
           // Print value on histogram
           // how would i achieve this?
      }

      Comment


        #4
        Hello,

        I have provided the code that you will need to complete your histogram. You wont need a for loop, as the OnBarUpdate() method will continually calculate each bar.

        (------- lines designate each different area of code to make changes... don't include them, etc)

        #region Variables
        privatedouble difference = 0;
        #endregion

        ----------------------------------


        protectedoverridevoid Initialize()

        {

        Overlay = false;

        Add(new Plot(new Pen(Color.Navy, 2), PlotStyle.Bar, "Diff"));

        Add(new Line(Color.DarkGray, 0, "Zero line"));

        }
        -------------------------------------------

        protectedoverridevoid OnBarUpdate()
        {
        difference = Close[0]- SMA(Close,500)[0];
        Values[0].Set(difference);
        }


        Please let us know if we can assist you further.
        Matt L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mykro, Yesterday, 04:58 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_PaulH  
        Started by akuntysh, Today, 02:43 AM
        0 responses
        5 views
        0 likes
        Last Post akuntysh  
        Started by thgamey, Today, 02:05 AM
        0 responses
        8 views
        0 likes
        Last Post thgamey
        by thgamey
         
        Started by tpdk2012, Today, 12:51 AM
        1 response
        13 views
        0 likes
        Last Post NinjaTrader_ChrisSch  
        Started by simonerg, Today, 12:13 AM
        0 responses
        9 views
        0 likes
        Last Post simonerg  
        Working...
        X