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

bool statement

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

    bool statement

    I have a 3rd party indicator with locked code but gives us functions for us to make our own indicators and strategies.

    One such function looks like this: ThirdPartyInd.Test[barsAgo]. This paints the bar a certain color based on the value created in the 3rd party indicator. I do not have access to this value or code.

    What I want to do is put this function in an IF bool statement. Something like:

    if (CurrentBars[0] == ThirdPartyInd.Test[0]
    { DrawText(etc......)}

    This IF statement does not work, but I think you see what I'm trying to say.

    I'd appreciate any advice.
    Thank you.

    #2
    Originally posted by imalil View Post
    I have a 3rd party indicator with locked code but gives us functions for us to make our own indicators and strategies.

    One such function looks like this: ThirdPartyInd.Test[barsAgo]. This paints the bar a certain color based on the value created in the 3rd party indicator. I do not have access to this value or code.

    What I want to do is put this function in an IF bool statement. Something like:

    if (CurrentBars[0] == ThirdPartyInd.Test[0]
    { DrawText(etc......)}

    This IF statement does not work, but I think you see what I'm trying to say.

    I'd appreciate any advice.
    Thank you.
    Try examining ThirdPartyInd.Test[0] with a Print() statement to the OutputWindow.

    What does: " This IF statement does not work" mean? What happens? Error message? When?

    Comment


      #3
      Hello,
      In addition to what Koganam has asked, please advise the following:
      Can you provide exactly what you are trying to compare with your If statement?
      Cody B.NinjaTrader Customer Service

      Comment


        #4
        I can't print because I keep getting compile errors: CS0119, "not valid in given context". Then when I try to make a variable I get CS1002, 0270, 1519. I'm clearly missing a crucial step.

        I'll try to be clearer by giving you a conceptual example since I can't see the code: the 3rd party ind will look at volume. Let's say it gets 100 for the current bar. The ThirdPartyInd.Test[0] function says 'if current bar volume > 50, then paint the bar pink.'

        So what I'm trying to do: if the current bar == ThirdPartyInd.Test[0], (meaning "if the current bar has volume > 50"), then my ind will print its results via drawtext.

        I realize my logic is way off on this, but I do know many people use these functions to add to their own inds and strategies. That is what I'm trying to do.

        Thanks for the help.

        Comment


          #5
          Originally posted by imalil View Post
          I can't print because I keep getting compile errors: CS0119, "not valid in given context". Then when I try to make a variable I get CS1002, 0270, 1519. I'm clearly missing a crucial step.

          I'll try to be clearer by giving you a conceptual example since I can't see the code: the 3rd party ind will look at volume. Let's say it gets 100 for the current bar. The ThirdPartyInd.Test[0] function says 'if current bar volume > 50, then paint the bar pink.'

          So what I'm trying to do: if the current bar == ThirdPartyInd.Test[0], (meaning "if the current bar has volume > 50"), then my ind will print its results via drawtext.

          I realize my logic is way off on this, but I do know many people use these functions to add to their own inds and strategies. That is what I'm trying to do.

          Thanks for the help.
          To help resolve those kind of errors we have to see the actual lines that you are writing. You can, of course, hide the real name and call to the third-party indicator, but we do have to see the actual syntax of your lines.

          Comment


            #6
            Hello,
            As Koganam says it would be very useful if we can see what code you are writing exactly so that we can assist further as this is most likely an issue with the syntax.
            I do just want to clarify that CurrentBar returns the number of the bar from the first bar being 0 and and each subsequent bar from left to right is incremented by 1.
            If you are wanting you get the Volume you would need to use the Volume method. For example if you wanted to check if the Volume of the current bar is greater than 100 you would do the following:

            Code:
             if(VOL()[0] > 100)
            {
                //Do Something
            }
            For more information on CurrentBar property please see the following link: http://ninjatrader.com/support/helpG...currentbar.htm

            For more information on the Volume method please see the following link: http://ninjatrader.com/support/helpG...oscillator.htm
            Cody B.NinjaTrader Customer Service

            Comment


              #7
              There's no doubt it's a syntax or logic problem on my part. The error I get on the IF statement line is CS0119. This is the first time I've tried to use a function from another ind. in my ind.

              if (CurrentBars[0] == ThirdPartyInd.Test[0] && + imbalance > Buyimbal)
              { DrawText("imbalance" + CurrentBar, AutoScale, (+ imbalance).ToString(), 0, Low[0], -47,
              Color.Pink, ChartControl.Font, StringAlignment.Center, Color.Transparent, Color.Transparent, 0);
              DrawText("AvgTradeSize" + CurrentBar, AutoScale, (String.Format("{0:0.0}", avgtradesize)), 0, Low[0], -64,
              Color.DodgerBlue, ChartControl.Font, StringAlignment.Center, Color.Transparent, Color.Transparent, 0);}
              Thanks for the help.

              Comment


                #8
                if (CurrentBars[0] == ThirdPartyInd.Test[0] && + imbalance > Buyimbal)
                What is in red is almost certainly a logic error that will never be true. CurrentBars[0] is an int; ThirdPartyInd.Test[0] is a double.
                What is in blue simply is a syntax error. What are you even trying to say there?

                Comment


                  #9
                  Hello,
                  As Koganam has outlined CurrentBars[0] == ThirdParty.Test[0] is indeed a logic error.
                  Can you clarify what you are trying to call with CurrentBars[0] as it is likely you need to call something else here.

                  &&+ is not an operator. Can you clarify what you are trying to call here as well?

                  I look forward to your reply.
                  Cody B.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_CodyB View Post
                    Hello,
                    As Koganam has outlined CurrentBars[0] == ThirdParty.Test[0] is indeed a logic error.
                    Can you clarify what you are trying to call with CurrentBars[0] as it is likely you need to call something else here.

                    &&+ is not an operator. Can you clarify what you are trying to call here as well?

                    I look forward to your reply.
                    Can you link me something that explains what something like ThirdParty.Test[0] is? What tells you this is a double? I don't know enough about it to ask a clear question.

                    Thanks.

                    Comment


                      #11
                      Hello,
                      I do not have a link on information on ThirdPartyIndicator.Test as this is a custom method from the third party product. Koganam may be able to elaborate on how he deduced it is double. It is likely that it is a double as most indicator methods return a variable. To get the best information on this you will need to contact the vendor though so they can elaborate on their custom method.
                      Cody B.NinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by imalil View Post
                        Can you link me something that explains what something like ThirdParty.Test[0] is? What tells you this is a double? I don't know enough about it to ask a clear question.

                        Thanks.
                        I deduce that ThirdParty.Test[0] is most likely a double because the variable is indexed, implying that it belongs to some kind of "collection/NT series". Very few developers expose an IntSeries rather than a Plot. All Plots would be made of doubles by definition. This was reinforced by the questions that you are asking. Basically, given the level of ability exposed by your questions, if you can manage to reference it, it is most likely to be a Plot, rather than an IntSeries, which takes a better understanding, to be able to access.

                        Why I know that it is probably a logic error is simply from what CurrentBars[0] portends arithmetically. It is a monotonically increasing value with no real upper limit. Hence, we deduce that it is unlikely that any Plot will manage to reach the upper values of CurrentBars[0], at which time, your filter will always return false. A filter that will get pinned probably is a logic error, as, as soon as it gets pinned, it ceases to be a filter.

                        Comment


                          #13
                          Originally posted by NinjaTrader_CodyB View Post
                          Hello,
                          I do not have a link on information on ThirdPartyIndicator.Test as this is a custom method from the third party product. Koganam may be able to elaborate on how he deduced it is double. It is likely that it is a double as most indicator methods return a variable. To get the best information on this you will need to contact the vendor though so they can elaborate on their custom method.
                          Please don't misunderstand, I'm not asking for an explanation on ThirdPartyIndicator.Test, which is impossible for you to do, I'm asking for an explanation about its type. As Koganam says: "if you can manage to reference it, it is most likely to be a Plot, rather than an IntSeries". I'm asking for a way to research referencing a plot from a 3rd party ind. I know other inds supply such functions, so there must be, generally speaking, a recognized protocol or way to incorporate them in an ind. I simply want to educate myself on how this is done.

                          Thank you.

                          Comment


                            #14
                            Hello,
                            Referencing parts of an indicator really depend on how the indicator is set up. There is not a general protocol for this though. It depends on if the indicator has the plots exposed,if the indicator has multiple plots, and how the overload methods are set up for this. I highly recommend that you contact the third party vendor on how you can call this indicator and its overload methods in NinjaTrader. If you would like to learn more on calling indicators in general I'd recommend to take a look at the indicator methods section of the help guide: http://ninjatrader.com/support/helpG...indicators.htm
                            Cody B.NinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by imalil View Post
                              Please don't misunderstand, I'm not asking for an explanation on ThirdPartyIndicator.Test, which is impossible for you to do, I'm asking for an explanation about its type. As Koganam says: "if you can manage to reference it, it is most likely to be a Plot, rather than an IntSeries". I'm asking for a way to research referencing a plot from a 3rd party ind. I know other inds supply such functions, so there must be, generally speaking, a recognized protocol or way to incorporate them in an ind. I simply want to educate myself on how this is done.

                              Thank you.
                              Your question translates to: "How do I reference the properties or methods of an object?

                              Ultimately, to reference anything from an object, that object needs to expose that entity for public access. There are more restrictive access methods, between private and public, that may be used, but public is the level most often used. You will have to read the literature on OOP principles.

                              Here is one reference: https://www.google.com/search?q=c%23...utf-8&oe=utf-8

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by ZenCortexCLICK, Today, 04:58 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post ZenCortexCLICK  
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              172 responses
                              2,281 views
                              0 likes
                              Last Post sidlercom80  
                              Started by Irukandji, Yesterday, 02:53 AM
                              2 responses
                              18 views
                              0 likes
                              Last Post Irukandji  
                              Started by adeelshahzad, Today, 03:54 AM
                              0 responses
                              8 views
                              0 likes
                              Last Post adeelshahzad  
                              Started by Barry Milan, Yesterday, 10:35 PM
                              3 responses
                              13 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Working...
                              X