• 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

Question regarding NT8 code changes for the following snipets

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

    Question regarding NT8 code changes for the following snipets

    Hi. I was trying to convert one of the indicators I got from this support forum from NT7 script to NT8. However, I came across the following errors before compiling and I have been unable to solve them. Could you please tell how they change in NT8?

    1) public override void Plot(Graphics graphics, Rectangle bounds, double min, double max) >> 'Graphics' could not be found

    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 VAb
    {
    get { return Values[1]; }
    }
    >> 'DataSeries' could not be found

    3) [Description("Include Weekend Volume")]
    [Category("Parameters")]
    [Gui.Design.DisplayName ("\t\t\t\t\tInclWeekendVol")]
    >>'Design' does not exist in 'NinjaTrader.Gui'


    Please help. Thanks in advance.

    #2
    Hello,

    Thank you for the questions.

    I have moved this post into the NT8 forums for clairity,

    For your first question, this is because Plot is no longer used, NinjaTrader 8 now uses the SharpDX library for rendering and instead of Plot now uses OnRender. You can find this in the help guide, but do note that other types use OnRender as well so pay close attention to what part of the help guide you are reading. For example a DrawingObject has OnRender but so does an Indicator and have seperate help documentation. http://ninjatrader.com/support/helpG...htsub=onrender

    For any of the X and Y conversion methods you may have used in NT7, please see these pages:
    http://ninjatrader.com/support/helpG...artcontrol.htm
    http://ninjatrader.com/support/helpG...chartscale.htm

    DataSeries is no longer used in NT8, you can see this in the Code Breaking Changes document along with what should be used instead:
    http://ninjatrader.com/support/helpG...ng_changes.htm

    In this document you will find: DataSeries Class Series<double> DataSeries class has been replaced, you can click the links on that page for specific examples of the different syntax.
    http://ninjatrader.com/support/helpG...s/?seriest.htm

    Regarding the Properties specifically, I would suggest reviewing one of the already made indicators to see what is currently used for their properties.

    For example the SMA has the following property:

    Code:
    [Range(1, int.MaxValue), NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Period", GroupName = "NinjaScriptParameters", Order = 0)]
    public int Period { get; set; }
    This would need modified to your own purpose or :

    Code:
    [Range(1, int.MaxValue), NinjaScriptProperty]
    [Display(Name = "tInclWeekendVol", GroupName = "NinjaScriptParameters", Order = 0)]
    public int tInclWeekendVol{ get; set; }
    Instead of using the \t you can now set the order of the parameters.

    Please let me know if I may be of additional assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Still clueless with regard to how to replace Plot Method

      Hi Jesse. Thanks for your feedback. I somehow managed to sort out errors 2 and 3 but I am still at a loss with regards to the first error.

      Even though I can replace Plot with OnRender, 4 things are passed to the Plot class according to the NT7 script i.e. Graphics(I could not find this in help documentation), Rectangle(I guess this changes in NT8 script) and 2 doubles while the OnRender class only has 2 things passed to it. How I do make the switch from Plot to OnRender in this case? What is the NT8 equivalent to Graphics? My knowledge of C# and my programming skills are low so I do not know how to make the transition. Please advise. Thanks in advance.

      Comment


        #4
        Hello,

        Thank you for the reply.

        The Graphic object was only used in NT7 and is only used with Winforms applications, because NinjaTrader is a WPF application and utilizes the SharpDX library, you can basically forget what you know about the Graphics object and instead use the RenderTarget.

        I would suggest reviewing the SampleCustomPlot indicator that comes with the platform for a more detailed sample of the basic concepts of OnRender. Also the DrawingTools all use OnRender so they can also be reviewed as samples of using SharpDX/OnRender.

        The NinjaTrader methods you are already used to will still exist like converting bars/prices to coordinates but the objects you are used to have likely changed I.E. X and Y conversion methods are split between ChartControl and ChartScale now, also the Graphics object would be replaced with RenderTarget.

        Likely your current math would be able to transition but the remainder of the code you have would go through and check for items that are no longer valid like Graphics and then either search for the specific item you are trying to do or ask for assistance on the forums here.

        For example if you wanted to draw a Rectangle you could either look in the included indicators / drawing tools for one that draws a rectangle, search the help guide for RenderTarget to view the help guide samples or ask on the forums if you are unable to locate anything specific or helpful and we can detail it further.

        For a rectangle you could see this example here: http://ninjatrader.com/support/helpG...=drawrectangle


        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by rwilliam, Today, 03:14 PM
        0 responses
        3 views
        0 likes
        Last Post rwilliam  
        Started by rwilliam, Today, 03:10 PM
        1 response
        3 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by rontronimous, Today, 03:04 PM
        2 responses
        4 views
        0 likes
        Last Post rontronimous  
        Started by zacharydw00, Today, 03:14 PM
        0 responses
        2 views
        0 likes
        Last Post zacharydw00  
        Started by junkone, 09-12-2019, 07:10 PM
        11 responses
        79 views
        0 likes
        Last Post cnecorp
        by cnecorp
         
        Working...
        X