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

multi time frame EMA

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

    multi time frame EMA

    Hi,

    I tweaked a multi time frame EMA indicator a bit. Depending on chart TF it throws errors. I think it has to do with the number of bars loaded in the chart.

    Any help appreciated.

    Cheers

    Thomas
    Attached Files

    #2
    Hello td_910,
    I can run the indicator fine at my end. Can you please let me know the exact steps to replicate the scenario.

    I look forward to assisting you further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Hi Joydeep,

      it's regarding this line:

      if (CurrentBar < 800) return;

      I did trial and error to come up with 800. I had 200, but this gave errors for sessions with larger bar numbers. E.g. RTH 5min (81 bars) always worked fine with 200, but everything with more bars like ETH does not. ETH seems to work with numbers >270.

      How do I calculate an exact number? Is there a way to have this a more "correct" code?

      Cheers

      Thomas

      Comment


        #4
        Hello td_910,
        Thanks for the information.

        If you replace the code with the below code then can you get the indicator to work.
        Code:
        if (CurrentBars[0] < 1 || CurrentBars[1] < 1 || CurrentBars[2] < 1) return;


        Please refer to this post which discusses in further the reason for the errors
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Hi Joydeep,

          many thanks. It works. But what is the difference to:

          if (CurrentBar < 200) return;

          Doesn't this line of code does exactly the same, because it is called for all Bars objects (0, 1, 2) ?

          Thanks

          Thomas

          Comment


            #6
            Hello Thomas,
            No, they are not the same.

            You can have 200 one minute bar, but that does not guarantees you that a daily bar has formed. However you are trying to access a daily bar (with Closes[2][0]). This will throw an error.
            JoydeepNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Jimmyk, 01-26-2018, 05:19 AM
            6 responses
            835 views
            0 likes
            Last Post emuns
            by emuns
             
            Started by jxs_xrj, 01-12-2020, 09:49 AM
            6 responses
            3,291 views
            1 like
            Last Post jgualdronc  
            Started by Touch-Ups, Today, 10:36 AM
            0 responses
            10 views
            0 likes
            Last Post Touch-Ups  
            Started by geddyisodin, 04-25-2024, 05:20 AM
            11 responses
            62 views
            0 likes
            Last Post halgo_boulder  
            Started by Option Whisperer, Today, 09:55 AM
            0 responses
            9 views
            0 likes
            Last Post Option Whisperer  
            Working...
            X