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

How to call time in ninjascript?

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

    How to call time in ninjascript?

    How do I write "If time >= 0830 and time <= 1200" in ninjacript?

    Thanks.

    #2
    Hello AdeptistJune,

    Code:
    if (ToTIme(Time[0]) > 083000 && ToTime(Time[0]) <= 120000)
    Below is a link to forum post with helpful information about getting started with NinjaScript in NinjaTrader 7. I recommend the Strategy Wizard 301 video.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks a lot.

      Comment


        #4
        When I tried to compile the code, it says: The name "ToTime" does not exist in the current content.

        What does this mean?

        Comment


          #5
          Hello AdeptistJune,

          Below is a link to the help guide on ToTime(). It is a valid method for indicators and strategies.
          https://ninjatrader.com/support/help...nt7/totime.htm

          Did you add this within OnBarUpdate()?

          Try using the strategy wizard to generate the condition.

          May I have a screenshot of the error?
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            I deleted the indicator.

            Give me a second to re-create it.

            Comment


              #7
              I created an indicator in Tradestation's easylanguage: Var:
              HighLowRange(0),
              BreakoutHigh(0), BreakoutLow(0),
              HighestClose(0), LowestClose(0);

              If time >= 0830 and time <= 1200 then
              begin

              BreakoutHigh = highest(high,15);
              BreakoutLow = Lowest(low,15);
              HighestClose = Highest(Close,15);
              LowestClose = Lowest(Close,15);

              end;

              HighLowRange = BreakoutHigh - BreakoutLow;

              plot14(Breakouthigh,"HourBreakoutHigh",blue);
              plot15(BreakoutLow,"HourBreakoutLow",Red);
              plot16(HighestClose,"HighestClose",magenta);
              plot17(LowestClose,"LowestClose",Green);

              I would like to create this same indicator in ninjascript.

              Comment


                #8
                Hello AdeptistJune,

                I wouldn't be able to help with the EasyLanguage code.

                But it is possible to add a plot in an indicator.

                Below is a link to the help guide on AddPlot().


                And the Value series / collection of Values series.



                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9

                  Comment


                    #10
                    I still can't get my code to compile. I set a screenshot of the error message.

                    Do you have any suggestions?

                    Comment


                      #11
                      The spelling , if (ToTIme(Time[0]) > 083000 && ToTime(Time[0]) <= 120000). The First 'ToTIme' needs to corrected to 'ToTime'. I hope this helps.

                      Comment


                        #12

                        Comment


                          #13
                          Emma,

                          You were correct about the correction in the script. Now, I'm receiving this error message.

                          Comment


                            #14
                            Are you coding in NinjaScript 7 or 8?.'Highbreakout ' is not a reserved word. It needs to be declare before its is used within the code.

                            Comment


                              #15
                              I'm coding in NinjaScript 8. But do I declare it as a private or public var? And where do I declare it?

                              And thank you so much for helping me out. I only know to code in easylanguage. This is my first day with Ninja Trader.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by pechtri, 06-22-2023, 02:31 AM
                              10 responses
                              124 views
                              0 likes
                              Last Post Leeroy_Jenkins  
                              Started by judysamnt7, 03-13-2023, 09:11 AM
                              4 responses
                              59 views
                              0 likes
                              Last Post DynamicTest  
                              Started by ScottWalsh, Yesterday, 06:52 PM
                              4 responses
                              36 views
                              0 likes
                              Last Post ScottWalsh  
                              Started by olisav57, Yesterday, 07:39 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post olisav57  
                              Started by trilliantrader, Yesterday, 03:01 PM
                              2 responses
                              22 views
                              0 likes
                              Last Post helpwanted  
                              Working...
                              X