Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT syntax help

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

    NT syntax help

    I've been trying to code this logic for one of the function -


    ef ul = SMA( High * (1 + 4 * (High - Low) / (High + Low)), length = 14);
    def vc1 = EMA(close(period = Hour) , 12) - ExpAverage(close(period = hour) , 26);
    def va1 = EMA(vc1, 9);

    def diff = (vc1 - va1); <-- expecting a double value

    Can someone help me with the syntax plz?

    #2
    Hello ark321,

    Thank you for your post.

    This looks to be in Thinkscript, is that correct?

    Below I am providing a link to a forum post with helpful information about getting started with NinjaScript.
    https://ninjatrader.com/support/foru...040#post786040

    I am happy to answer any specific questions you may have about NinjaScript if you decide to move forward with coding this yourself.

    This thread will remain open for any community members that would like to create this script as a convenience to you.

    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 our business development follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.

    Please let us know if we may be of further assistance to you.

    Comment


      #3
      I've figured out most of the stuff. Only question I've is how do i get high and low values of higher time frame bar (for example 1 hour) inside the lower time frame (for example) 5 min?

      Comment


        #4
        Hello ark321,

        Thank you for your reply.

        You would need to use AddDataSeries() to add the 1 hour (60 minute bar) to your script in the State == State.Configure section of the OnStateChange method:

        AddDataSeries(BarsPeriodType.Minute, 60);

        You would then need to specify the BarsArray index of the second series when referring to High/Low/Close/Open series for that. The primary series will have an index of 0, the first added series would have an index of 1, the second 2, and so on. So, for example:

        EMA(close(period = Hour) , 12) would become EMA(Closes[1] , 12); To refer to an individual Close price of the secondary series, you would use Closes[1][0] to get the close value of the most recent bar.

        Considerations for working with multi-series scripts may be found in our help guide here:



        Please let us know if we may be of further assistance to you.

        Comment


          #5
          thanks a lot. That helps

          Comment


            #6
            one other question: if the 2nd series is higher time frame - does Closes[1] gives previous candle's close ( since the current 5 min candle could be inside the current 60 min which is not closed yet)

            Comment


              #7
              Hello ark321,

              Thank you for your reply.

              Closes[1][1] would give you the close of the previous 60 minute bar. Basically it's Closes[BarsArray index][BarsAgo to get the price from].

              You'll want to be careful referring to series like High/Low/Open/Close when you're working with multiple data series. For example, if you're wanting to get, say the current close of the primary series, you'd want to make sure you use Closes[0][0] to specify that primary series close is the one you want, not the secondary series. The same would be true for high/low/open, you'd want to refer to Highs[0][0] or Lows[0][0] or Opens[0][0] to make sure you are getting the values from the correct series.

              This section of that page I previously linked gives a bit more detail:



              Please let us know if we may be of further assistance to you.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              574 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              333 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              553 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              551 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X