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

Why doesn't it work?

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

    Why doesn't it work?

    protected override void OnBarUpdate()
    {
    if (ChartBars == null) return;

    Print(ChartBars.GetTimeByBarIdx(ChartControl, CurrentBar));
    //or
    Print(Bars.GetTime(CurrentBar));
    }

    #2
    It should work in OnRender, hope it helps!

    Comment


      #3
      Yeah I know but I need it in OnBarUpdate.
      Here is an example in guide, it's used in OnBarUpdate: https://ninjatrader.com/support/help...mebybaridx.htm

      Comment


        #4
        Thanks for sharing the link, its working for me, see snapshot. Attaching code for reference. Hope it helps!
        Attached Files

        Comment


          #5
          Your indicator works. But it doesn't work if I put this code into my strategy. Looks like some NT limitations. I need time value to output it with StreamWriter in my strategy. So indicator won't help me.
          Last edited by Leeroy_Jenkins; 04-23-2021, 03:10 AM.

          Comment


            #6
            Check this out!
            Attached Files

            Comment


              #7
              Doesn't work.

              Comment


                #8
                can you share your strategy, what i shared was working for me.

                Comment


                  #9
                  See my 1st post. I tried put this into separate strategy. Same problem.
                  I updated my NT8 to the latest version cuz I used old one. Still nothing.

                  Comment


                    #10
                    Can you please clarify this:
                    1. When you try to print as I shared with your strategy, it works or not. Be sure not to include rest of your strategy, follow step by step to debug.
                    2. You said you're using StreamWriter in Post #5, can I assume it will output string. For the time being don't use this as yo need to be sure you're on right track.
                    3. Go step by step, line by line & see what exactly is not working, comment out what is not working & confirm what works.
                    Keep only 1 line in your code & see if it works so you will find where exactly your code is not working & it can then be fixed. I am suspecting one simple miss & believe it can be fixed easily. No hurries, sit relax then go line by line. Hint: if you need string to output in StramWriter, it may not work.

                    Comment


                      #11
                      Well, example from this link https://ninjatrader.com/support/help...mebybaridx.htm doesn't work for me in a simple strategy. There is nothing to debug. Looks like a bug to me.
                      Attached Files

                      Comment


                        #12
                        Glad to say your code is working at my end, see snapshot of output window.

                        Comment


                          #13
                          Let me also share StreamWriter working (as strategy for you).
                          Reference: https://ninjatrader.com/support/help..._resources.htm
                          Attached Files

                          Comment


                            #14
                            I think I should have asked this earlier, anyways may I ask you if you've enabled the strategy after adding ?
                            If not, that's the only problem, do this from strategy dialog box or control center -> Strategies tab.
                            Hope it helps!

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by ScottWalsh, Today, 04:52 PM
                            0 responses
                            1 view
                            0 likes
                            Last Post ScottWalsh  
                            Started by ScottWalsh, Today, 04:29 PM
                            0 responses
                            5 views
                            0 likes
                            Last Post ScottWalsh  
                            Started by rtwave, 04-12-2024, 09:30 AM
                            2 responses
                            22 views
                            0 likes
                            Last Post rtwave
                            by rtwave
                             
                            Started by tsantospinto, 04-12-2024, 07:04 PM
                            5 responses
                            70 views
                            0 likes
                            Last Post tsantospinto  
                            Started by cre8able, Today, 03:20 PM
                            0 responses
                            7 views
                            0 likes
                            Last Post cre8able  
                            Working...
                            X