Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cannot convert 'System.Date.Time' to 'int'

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

    Cannot convert 'System.Date.Time' to 'int'

    Im new to Ninjatrader coding and programming in general. The goal of this indicator is to plot rays on previously closing bars. So far in previous iterations I have gotten lines to show up on the chart with the help of chat GPT, but I'm having a hard time plotting rays.

    Some recurring issues:

    Cannot convert 'System.Date.Time' to 'int'
    Cannot convert 'System.Date.Time' to 'int'
    Cannot convert from 'Float' to 'int'

    My goals after this are to leave the last set after a new set of trendlines are formed so only two sets show up at once.

    I apologize if the code is bad, maybe there is an easier way to plot custom rays.
    ​​
    Attached Files

    #2
    Time[1], High[1], // Starting point: previous bar high
    Time[0], High[0], // Directional hint: current bar high
    HighRayColor, DashStyleHelper.Solid, RayWidth);

    Draw.Ray(this, "LowRay",
    false,
    Time[1], Low[1], // Starting point: previous bar low
    Time[0], Low[0], // Directional hint: current bar low
    LowRayColor, DashStyleHelper.Solid, RayWidth);​

    Here is the snippet that give me the most issues.

    Comment


      #3
      Hello BigCoco,

      Welcome to the NinjaTrader forums.

      If you are using an external AI tool, please note that those generally cannot create valid NinjaScript, I have included some information about that below.

      Regarding the compile errors it would seem that you are supplying the wrong parameters for the overload you are using.

      Draw.Ray(NinjaScriptBase owner, string tag, bool isAutoScale, int startBarsAgo, double startY, int endBarsAgo, double endY, Brush brush, DashStyleHelper dashStyle, int width)

      Below you are supplying a time inputs (which are of type DateTime) when it is expecting an integer type for startBarsAgo and endBarsAgo, and you have defined RayWidth as a float when width should be an integer.

      Draw.Ray(this, "HighRay", false,Time[1], High[1], Time[0], High[0], HighRayColor, DashStyleHelper.Solid, RayWidth);

      https://ninjatrader.com/support/helpGuides/nt8/draw_ray.htm​


      From our experience at this time, ChatGPT and other AI models are not adequate at generating valid NinjaScript code that function as the user has intended. We often find that these tools generate code that will call non-existent properties and methods, use improper classes or inheritance, and may have incorrect logic. Using these tools for general NinjaScript learning information may also provide incorrect responses. We highly encourage that you create a new NinjaScript yourself using the NinjaScript Editor and avoid any AI based coding tools.

      While it would not be within our support model to assist with scripts generated or checked by ai tools, we would be happy to provide insight for any direct specific inquiries you may have if you would like to create this script yourself. Our support is able to assist with finding resources in our help guide as well as simple examples, and we are happy to provide guidance on how you can debug the script while running it on your machine. To start learning NinjaScript I would suggest the following link as a starting point.

      https://support.ninjatrader.com/s/article/Developer-Guide-Getting-Started-with-NinjaScript

      You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.
      Last edited by NinjaTrader_Gaby; 11-21-2024, 02:29 PM.

      Comment


        #4
        Hello Gaby,

        Thank you for your response. I think I will look at a consultation to save time, and i'm sure its a fairly simple indicator that shouldn't be too costly at a fixed price. I would like to see some recommendations for programmers please.

        Comment


          #5
          Hello BigCoco,

          You can search our extensive library of NinjaScript consultants through the link below. Simply enter a consultant name or search by using our filter categories. Once you have identified your consultants of choice, please visit each consultant's site for more information or contact them directly to learn more!
          Programming Services - https://ninjatraderecosystem.com/sea...mming-services
          Educators - https://ninjatraderecosystem.com/sea...ures=education

          You can locate the contact information for the consultants on their direct websites for any additional questions you may have. Since these consultants are third party services for NinjaTrader all pricing and support information will need to be obtained through the consultant.

          This NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The companies and services listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.

          Please let me know if you have any questions, or if I can provide any further assistance.​
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            BigCoco I'm a professional software engineer (I can provide a link to my LinkedIn profile upon request). I'd be willing to write this for you for a reasonble consulting fee

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            637 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            366 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            107 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            569 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            571 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X