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

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:
     
     
     [FONT=Courier New][FONT=Courier New]Add([/FONT][/FONT][COLOR=#0000FF][FONT=Courier New][COLOR=#0000FF][FONT=Courier New][COLOR=#0000FF][FONT=Courier New]new[/FONT][/COLOR][/FONT][/COLOR][/FONT][/COLOR][FONT=Courier New][FONT=Courier New] Plot([/FONT][/FONT][COLOR=#0000FF][FONT=Courier New][COLOR=#0000FF][FONT=Courier New][COLOR=#0000FF][FONT=Courier New]new[/FONT][/COLOR][/FONT][/COLOR][/FONT][/COLOR][FONT=Courier New][FONT=Courier New] Pen(Color.Navy, [/FONT][/FONT][COLOR=#800080][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080][FONT=Courier New]2[/FONT][/COLOR][/FONT][/COLOR][/FONT][/COLOR][FONT=Courier New][FONT=Courier New]), PlotStyle.Bar, [/FONT][/FONT][COLOR=#800000][FONT=Courier New][COLOR=#800000][FONT=Courier New][COLOR=#800000][FONT=Courier New]"Diff"[/FONT][/COLOR][/FONT][/COLOR][/FONT][/COLOR][FONT=Courier New][FONT=Courier New]));[/FONT][/FONT]
     [FONT=Courier New][FONT=Courier New][/FONT][/FONT][FONT=Courier New][FONT=Courier New]
     
    [/FONT][/FONT]
    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 ghoul, Today, 06:02 PM
        3 responses
        14 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        44 views
        0 likes
        Last Post jeronymite  
        Started by Barry Milan, Yesterday, 10:35 PM
        7 responses
        20 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by AttiM, 02-14-2024, 05:20 PM
        10 responses
        180 views
        0 likes
        Last Post jeronymite  
        Started by DanielSanMartin, Yesterday, 02:37 PM
        2 responses
        13 views
        0 likes
        Last Post DanielSanMartin  
        Working...
        X