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

Help with code please.

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

    Help with code please.

    Hi,
    Once again I have become frustrated and defeated in my quest to code this simple indicator. I just need a bit of guidance please. I have uploaded the indicator in question, it compiles ok, but only plots red, with no change. Please have a look at it. I have commented it for easier understanding of what is going on.
    Across 2 days I have tried many different ways to code this having read a heap of material from NT help files as well as MSDN and other sources.
    Putting all the up trend bool variables in an array and the down trend bool variables in another array, then testing for all true in either, was one of the ways I tried. The main hurdle there was I didn't understand the concept of the "predicate<T>delegate".
    Any way I would appreciate your expert help please.
    The simplest way would suit me best. But I will be guided by you. I always learn a lot doing this and am improving. Every time it is something new, I haven't tackled before that trips me up.
    Thanks,
    Ken.
    Attached Files

    #2
    You forgot to reset your booleans on each OnBarUpdate iteration.
    Once your cbBP?Bar variables were set to true, your "down" condition will remain true even if the "up" condition was true as well.

    Code:
    caBPcurBar = caBP1Bar = caBP2Bar = cbBPcurBar = cbBP1Bar = cbBP2Bar = false;
    A friendly advice:
    NinjaTrader Output is your best friend. Use Print. A lot!

    Comment


      #3
      Thanks

      Originally posted by uvblue View Post
      You forgot to reset your booleans on each OnBarUpdate iteration.
      Once your cbBP?Bar variables were set to true, your "down" condition will remain true even if the "up" condition was true as well.

      Code:
      caBPcurBar = caBP1Bar = caBP2Bar = cbBPcurBar = cbBP1Bar = cbBP2Bar = false;
      Thanks, I'll give it a go.

      A friendly advice:
      NinjaTrader Output is your best friend. Use Print. A lot!
      I tried this the other day but couldn't work out how to go about it? Nothing would print.

      Comment


        #4
        Hello KennyK,

        Thanks for your post.

        Member uvblue has provided the solution for you and good advice concerning the use of Print.

        To use the print statement you would need to open the output window via New>Ninjascript Output

        To send information to the output window you would use Print (); https://ninjatrader.com/support/help...-us/?print.htm The helpguide provide several examples.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Wonderful

          Thanks Guys, That is all working well now.

          Something else I was wondering about is how to have the indicator panel automatically via coding appear at a reduced height. And stay at that height if other indicator panels are added. Please see attached pic showing the panels in question.
          I was checking this out, but not sure about it, or even where it would be placed in the code?

          Your assistance would be appreciated, thank you.
          Attached Files
          Last edited by KennyK; 11-09-2017, 05:00 PM. Reason: Forgot something

          Comment


            #6
            Hello KennyK,

            Thanks for your post.

            There does not appear to be a way to set the panel height.

            Looking at your screenshot, one possible way to do this (in one panel) would be to add a user input parameter where you set the value of the dots. In your code, you are setting them at 0.0. if you made it adjustable when adding the indicator you could set one instance of the indicator at 0, another a value of say 5 and so on. Then you can put all the indicators into one panel because you would have vertically spaced the dots for each one.
            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Barry Milan, Yesterday, 10:35 PM
            5 responses
            16 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by DanielSanMartin, Yesterday, 02:37 PM
            2 responses
            13 views
            0 likes
            Last Post DanielSanMartin  
            Started by DJ888, 04-16-2024, 06:09 PM
            4 responses
            12 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by terofs, Today, 04:18 PM
            0 responses
            11 views
            0 likes
            Last Post terofs
            by terofs
             
            Started by nandhumca, Today, 03:41 PM
            0 responses
            8 views
            0 likes
            Last Post nandhumca  
            Working...
            X