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

Any help ? struggle to code this price channel in NT8

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

    Any help ? struggle to code this price channel in NT8

    I'm tithing 2 weeks to code this in NT8 , but no result yet , any help?

    I can't adopt price series to get this done.
    Thanks in advance
    Last edited by Lyubomir Kratinov; 05-06-2024, 02:23 PM.

    #2
    Hello Lyubomir Kratinov,

    Thank you for the post, and welcome to the NinjaTrader forum.

    I see you are looping through all of the bars on the chart. NinjaTrader will do this for you automatically when you load your indicator onto the cart, I call it the "historical run". All you have to do is put your logic in OnBarUpdate and NinjaTrader will run that logic for each bar of the chart (with OnBarClose). For an example of this look at the source code for a simple indicator like the ATR. All of the OnBarUpdate logic is processed when the indicator is loaded, so you see the historical values of ATR.

    Please try moving the logic from within the FOR loop and place that within OnBarUpdate. Also replace any 'i' indexes with a '0' referencing the most current bar.

    I can take a look at the full code as well if you would like.

    I look forward to hearing of your results.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Here is the code : // but not works as well


      Last edited by Lyubomir Kratinov; 05-06-2024, 02:23 PM.

      Comment


        #4
        Hello Lyubomir Kratinov,

        Thank you for the reply.

        I added a CurrentBars check at the beginning of OnBarUpdate and your plots worked after that. Remember to check the Log tab of your Control Center if you apply an indicator to your chart and receive no results CurrenBars counts upward from the leftmost bar of the chart, so the problem was you were accessing LineHigh[1] when the script only had bar 0 to work with.

        protected override void OnBarUpdate()
        {
        if(CurrentBar < 1)
        return;

        //rest of the code.

        Please let me know if I can assist further.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Hello Lyubomir,

          Thanks for the reply.

          Could you please post the NT7 code so I can take a look?

          I look forward to your reply.
          Chris L.NinjaTrader Customer Service

          Comment


            #6
            This indicator is awesome! I love it!
            Though I've never coded C# and hardly code at all I accomplished it to add:

            private double Deviation1;
            Deviation1 = Deviation1 * Bars.Instrument.MasterInstrument.TickSize;

            in order to be able to use the indicator on instruments like CL, ES or GC which don't have 1 tick as one 1.00 like YM for e.g.

            After trading a while with it I recognized that it misses every 20th wick or so in its calculation. There seems to be no regularity. Just rarely it ignores a wick but it does it sometimes, unfortunately.
            Lyubomir Kratinov did you already solved this or do you guys have an idea what might be the matter?

            Comment


              #7
              Bar highs and lows are missed sometimes, because of basing the high and low price tests on close, instead of high and low. These two changes will fix the problem:
              Code:
              //            if (Close[0] > aaMax[1])
                          if (High[0] > aaMax[1])
                              aaTrend[0] = 1;
              
              //            if (Close[0] < aaMin[1])
                          if (Low[0] < aaMin[1])
                              aaTrend[0] = -1;

              Comment


                #8
                Indeed that fixed it. Very nice. Thank you Lector!
                Makes sense with the Close vs High/Low

                Comment


                  #9
                  Even though the indicator works properly with those changes, it wastes lots of memory due to poor design. A much more efficient version is attached.

                  HLchannel.zip
                  Last edited by caveat_lector; 06-12-2020, 03:38 PM.

                  Comment


                    #10
                    Great.

                    I digged a little into the code and added an edge area by 2 additional lines and a trend indicating background.
                    Attached Files
                    Last edited by seykool; 06-17-2020, 11:43 AM. Reason: Now with the correct file. No idea how it could have been empty. Thanks for noting.

                    Comment


                      #11
                      seykool, the file you posted above contains "Using declarations" and "NinjaScript generated code" regions, but no indicator code.

                      Comment


                        #12
                        Awesome! I made the indicator in the end exactly like you have it, just with a transition background, and trade always this one system. I love it, it's a beauty! I am so happy somebody did the coding I couldn't do.
                        And finally I know how the system is actually called, haha.

                        Comment


                          #13
                          Hi LK, where can I download please?

                          Regards,
                          Jag

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by cummish, Today, 08:43 PM
                          0 responses
                          5 views
                          0 likes
                          Last Post cummish
                          by cummish
                           
                          Started by Option Whisperer, Today, 07:58 PM
                          4 responses
                          18 views
                          0 likes
                          Last Post Option Whisperer  
                          Started by ETFVoyageur, 05-07-2024, 07:05 PM
                          13 responses
                          86 views
                          0 likes
                          Last Post ETFVoyageur  
                          Started by cupir2, Today, 07:44 PM
                          0 responses
                          9 views
                          0 likes
                          Last Post cupir2
                          by cupir2
                           
                          Started by reynoldsn, Today, 07:23 AM
                          6 responses
                          20 views
                          1 like
                          Last Post reynoldsn  
                          Working...
                          X