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

Creating a simple Chicago and country clocks in charts Sintaxis Problem

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

    Creating a simple Chicago and country clocks in charts Sintaxis Problem

    "Greetings, I am currently in the process of familiarizing myself with the syntax of NinjaTrader. As a novice coder, I am endeavoring to create a program that displays a simple clock at the top of the chart, featuring two time stamps. However, I am consistently encountering errors during the compilation process."

    code is:



    using System;
    using System.Linq;
    using System.Windows.Forms;
    using NinjaTrader.Core;
    using NinjaTrader.Gui.Chart;

    namespace MyClocks
    {
    public class Maclock : Indicator
    {
    private DateTime chicagoTime;
    private DateTime madridTime;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = "My Indicator";
    Name = "Maclock";
    }
    else if (State == State.DataLoaded)
    {
    chicagoTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTim e.Now, TimeZoneInfo.Local.Id, "Central Standard Time");
    madridTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTim e.Now, TimeZoneInfo.Local.Id, "Central European Standard Time");
    }
    }

    protected override void OnPaint(ChartPaintEventArgs e)
    {
    base.OnPaint(e);

    chicagoTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTim e.Now, TimeZoneInfo.Local.Id, "Central Standard Time");
    madridTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTim e.Now, TimeZoneInfo.Local.Id, "Central European Standard Time");

    var timeChicago = chicagoTime.ToString("HH:mm");
    var timeMadrid = madridTime.ToString("HH:mm");
    var text = "Chicago: " + timeChicago + " Madrid: " + timeMadrid;

    e.Graphics.DrawString(text, new System.Drawing.Font("Arial", 12), new System.Drawing.SolidBrush(System.Drawing.Color.Bla ck), new System.Drawing.PointF(ChartControl.CanvasRight - e.Graphics.MeasureString(text, new System.Drawing.Font("Arial", 12)).Width - 10, ChartControl.CanvasTop + 10));
    }

    }
    }




    get foolwing errors
    The type or namespace name 'ChartPaintEventArgs' could not be found (are you missing a using directive or an assembly reference?)
    The type or namespace name 'Core' does not exist in the namespace 'NinjaTrader' (are you missing an assembly reference?)
    The type or namespace name 'Indicator' could not be found (are you missing a using directive or an assembly reference?)


    any idea how solve it? thnak you for your support

    #2
    Hello GAVETSO,

    NinjaScript is written in C# and uses the syntax of C#.

    Below is a link to a forum post with helpful resources on getting started with C#.


    The namespace is not correct. Create the indicator using the NinjaScript Editor which will automatically create the frame and will use the proper namespaces.

    NinjaTrader 8 does not have an override method called OnPaint.

    You may be looking for OnRender() which renders using SharpDX.

    Below are links to the help guide.



    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello GAVETSO,

      We have found that you have both sent an email to support and posted on the forums, causing two members of our support to be assigned to your inquiry.

      While we are happy to assist on the forums or with you privately through email with our scriptingsupport [at] ninjatrader [dot] com address, we respectfully ask that you only create one inquiry. This can be privately in email or can be a public thread on the forum.

      If you would no longer like to communicate publicly on the forums, please let us know so and we will be happy to converse solely through email.

      Creating both a forum thread and also sending an email to our support email address will create two separate tickets and may cause multiple technicians to start at the beginning of reviewing your inquiry, tying up resources with our platform support and delaying our ability to respond to all customers in a timely manner.​

      That said, we will close your email support ticket and follow up with you here on the forum. Please let us know if you would prefer to work through private email instead of on the forum.


      Your code appears to be a mixture of NinjaTrader 8 code that will only work in NinjaTrader 8 and NinjaTrader 7 code that will only work in NinjaTrader 7. However, this thread is in the NinjaTrader 7 section of the forums.

      Is this script made for NinjaTrader 8 or is this script made for NinjaTrader 7?

      Below is a link to a forum post on porting scripts.
      Chelsea B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by gentlebenthebear, Today, 01:30 AM
      0 responses
      2 views
      0 likes
      Last Post gentlebenthebear  
      Started by samish18, Yesterday, 08:31 AM
      2 responses
      9 views
      0 likes
      Last Post elirion
      by elirion
       
      Started by Mestor, 03-10-2023, 01:50 AM
      16 responses
      389 views
      0 likes
      Last Post z.franck  
      Started by rtwave, 04-12-2024, 09:30 AM
      4 responses
      31 views
      0 likes
      Last Post rtwave
      by rtwave
       
      Started by yertle, Yesterday, 08:38 AM
      7 responses
      30 views
      0 likes
      Last Post yertle
      by yertle
       
      Working...
      X