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

Date and Time

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

    Date and Time

    I have created the following indicator to highlight the bar of an economic announcement
    if(ToTime(Time[0]) == 223000)
    {BackColor = Color.PaleGreen;
    DrawText(
    "my tag6", "Employment", 0, High[0]+TickSize*10, Color.Black) ;
    }

    It works fine but now I wish to add two extra features
    1. the date eg 20081108
    2. the instrument eg es-1208

    I have not been able to find the functions that can help me with this.
    Suggestions would be appreciated.

    #2
    For the date of the bar,

    Time[0].ToString()

    for the instrument

    Instrument.FullName

    more info on the latter - http://www.ninjatrader-support.com/H...tFullName.html
    RayNinjaTrader Customer Service

    Comment


      #3
      Instrument and date

      Thanks Ray
      I looked through the help guide and also did a forum search and could not find how to use these functions you mentioned.
      I had a try but was not successful. Would appreciate your help

      if
      (ToTime(Time[0]) == 222500)&& Instrument.FullName=="ES 06-07" && Time[0].ToString()==20081109)
      {BackColor = Color.PaleTurquoise;
      DrawText(
      "my tag5", "Employment 5 min", 0, High[0]+TickSize*24, Color.Black) ;}

      Comment


        #4
        I thought you wanted to print out the text...

        The instrument check is fine, for date check out ToDay()

        RayNinjaTrader Customer Service

        Comment


          #5
          This code appears to not have errors. Are all the brackets that I have included necessary?

          if
          ((ToTime(Time[0]) == 222500) && (Instrument.FullName=="ES 06-07") && (ToDay(Time[0])== 20060915))
          {BackColor = Color.PaleTurquoise;
          DrawText(
          "my tagz", "Employment 5 min", 0, High[0]+TickSize*24, Color.Black) ;
          }

          I use IB as my broker. Is the Instrument names specific to IB or do I use
          Ninja Instrument manager symbols?
          If I wish to use the same code for a number of instruments what would be the best way to use Instrument.FullName
          ie is there a way to use Instrument.FullName to 2 or three instruments or do I need to repeat the code to achieve this.

          Thanks

          Craig
          Last edited by cptrader; 11-08-2008, 11:05 PM.

          Comment


            #6
            Instrument name is NinjaTrader's.

            If you want multiple instruments, you would also have to check for it:

            Code:
            [SIZE=2][FONT=Courier New][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2](ToTime(Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]]) == [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]222500[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] && ToDay(Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]])== [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]20060915[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] && (Instrument.FullName==[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"ES 12-08"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] || Instrument.FullName == [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"NQ 12-08"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] || Instrument.FullName == [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"YM 12-08"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]))
            {
            [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// Do something here 
            [/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]}
            [/SIZE][/FONT][/FONT][/SIZE]



            RayNinjaTrader Customer Service

            Comment


              #7
              Time Frames

              To my code I would like to specify the time frame eg 30 min
              What function would I use for this?
              I have noticed that to use backcolor for one min charts I need to use
              if(ToTime(Time[0]) = 130100 to high light the 130000 bar.
              To specify for a 5 min or 30 min bar what time stamp would I need?

              Comment


                #8
                cptrader,

                I don't think I follow. If you want to highlight the 130000 bar on a 1min you would not do 130100. The 130000 bar is built from 125900 to 130000. The 130100 is built from 130000 to 130100.

                It depends on which bar you want from a 30min bars.
                133000 would be the bar built from 130000 to 133000. 123000 to 130000 would be the 130000 bar.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Time Fames 2

                  Josh
                  I have looked closely at the bars with a accurate time clock.
                  A 133000 1 min bar closes at 133000. To high light a bar for an economic announcement I would thus need to high light the 133100 bar as this begins at 133000 and ends at 133100. My logic is that the 133000 bar starts at 133000 but thank you for clarifying the timing of the bars.

                  My first question related to the ninja function I would use to specify a time frame in my code eg 30 min time frame

                  Thanks

                  Comment


                    #10
                    You would need to add yourself a second time frame. Please note this only works for NinjaScript Strategies. http://www.ninjatrader-support.com/H...struments.html
                    Josh P.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by PaulMohn, Today, 12:36 PM
                    0 responses
                    2 views
                    0 likes
                    Last Post PaulMohn  
                    Started by love2code2trade, 04-17-2024, 01:45 PM
                    4 responses
                    38 views
                    0 likes
                    Last Post love2code2trade  
                    Started by alifarahani, Today, 09:40 AM
                    2 responses
                    14 views
                    0 likes
                    Last Post alifarahani  
                    Started by junkone, Today, 11:37 AM
                    3 responses
                    20 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by frankthearm, Yesterday, 09:08 AM
                    12 responses
                    44 views
                    0 likes
                    Last Post NinjaTrader_Clayton  
                    Working...
                    X