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

Problems With Paint Bar Indicator

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

    Problems With Paint Bar Indicator

    Hello. I have tried to write my own custom indicator which paints the price bars one of five different colors based on the slope of a user specified SMA. I had no problems with this by hard coding the number of periods. But when I tried to revise it to allow the user to specify the periods I ran into all kinds of compile errors. Can anyone take a look at my code to give me some pointers? How best can I upload this? Thanks in advance.

    Regards
    Chuck

    #2
    Chuck, you can attach your code directly to your replies. Start by clicking "Go Advanced" to get to the post editor. Then click the paper clip icon, directly above the text entry window, click browse on the new window that pops up, find your file, click upload, and then you can submit your reply and the file should be attached. Please let us know if you have any other questions.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Austin View Post
      Chuck, you can attach your code directly to your replies. Start by clicking "Go Advanced" to get to the post editor. Then click the paper clip icon, directly above the text entry window, click browse on the new window that pops up, find your file, click upload, and then you can submit your reply and the file should be attached. Please let us know if you have any other questions.
      Hello Austin. I was unable to export the indicator because it had compile errors so I can't attach it. Is it possible to find the indicator somewhere in the NinjaTrader7 directory structure? Or is there some other way to get the code posted?

      Regards
      Chuck

      Comment


        #4
        Originally posted by NinjaTrader_Austin View Post
        Chuck, you can attach your code directly to your replies. Start by clicking "Go Advanced" to get to the post editor. Then click the paper clip icon, directly above the text entry window, click browse on the new window that pops up, find your file, click upload, and then you can submit your reply and the file should be attached. Please let us know if you have any other questions.
        Austin, I found it. Attached is the indicator. Thanks in advance!

        Regards
        Chuck
        Attached Files

        Comment


          #5
          Chuck, please try again with your variable named something other than Period. This is a NinjaTrader specific variable, and all of the errors in your script are occurring because of this name. You can name it something as simple as SMAPeriod or something like that.
          AustinNinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_Austin View Post
            Chuck, please try again with your variable named something other than Period. This is a NinjaTrader specific variable, and all of the errors in your script are occurring because of this name. You can name it something as simple as SMAPeriod or something like that.
            Hello Austin. Can you educate me a bit? I looked at many other indicators (both custom and native to NT) and found many instances where "period" was declared as a variable. Why didn't that work in my code?

            Per your suggestion I declared the variable as "smaper" and changed all the associated lines of code. That seems to have worked BUT now I'm having a problem in the "Properties" section. I also declared the variable in that section as "smaper" instead of "period". But now I'm getting an error message which states "Your indicator likely holds one or more recursive properties which could cause ninja trader to crash smaper. Do you want to edit these properties?"

            I have attached the file. Could you take a look and advise? Thanks a lot.
            Attached Files

            Comment


              #7
              Your first property has the function name "smaper" and the program variable is also named "smaper". The function and the variable cannot be the same name or you do get that message.

              That's why the NT convention that the function starts with an uppercase character, and the variable is the same thing with a lowercase first character. Try calling your function "Smaper"

              --EV

              Comment


                #8
                HI,

                Take a look at attached, I adjusted the property name and made sure that the indicator does not try an calculate the SMA until it has the minimum number of bars available, that seems to do the trick.

                Regards,
                Guy
                Attached Files
                TraderGuy
                NinjaTrader Ecosystem Vendor - EMS

                Comment


                  #9
                  Originally posted by TraderGuy View Post
                  HI,

                  Take a look at attached, I adjusted the property name and made sure that the indicator does not try an calculate the SMA until it has the minimum number of bars available, that seems to do the trick.

                  Regards,
                  Guy
                  TraderGuy, thanks for the help. I downloaded the indicator and tried applying it to a monthly chart generated from a daily yahoo file. My guess is that I have to modify the code a bit for this but I have no idea where to start.

                  Regards
                  Chuck

                  Comment


                    #10
                    Originally posted by maxreturn View Post
                    Trader Guy, thanks for the help. I downloaded the indicator and tried applying it to a monthly chart generated from a daily yahoo file. My guess is that I have to modify the code a bit for this but I have no idea where to start.

                    Regards
                    Chuck

                    Shouldn't have to modify the code. I applied to to monthly bars with no problem, see attached. Looks like something local to your PC.

                    Regards,
                    Guy
                    Attached Files
                    TraderGuy
                    NinjaTrader Ecosystem Vendor - EMS

                    Comment


                      #11
                      Chuck, what happened when you tried applying it to a monthly chart? Did it give you an error? Did it show nothing at all?

                      Guy - is that adjusted data? Makes me wish I bought some AAPL in 2004...
                      AustinNinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_Austin View Post
                        Chuck, what happened when you tried applying it to a monthly chart? Did it give you an error? Did it show nothing at all?

                        Guy - is that adjusted data? Makes me wish I bought some AA PL in 2004...
                        You and me both, it's straight off of Kinetick. No local adjustments set on Ninja.
                        TraderGuy
                        NinjaTrader Ecosystem Vendor - EMS

                        Comment


                          #13
                          Originally posted by NinjaTrader_Austin View Post
                          Chuck, what happened when you tried applying it to a monthly chart? Did it give you an error? Did it show nothing at all?

                          Guy - is that adjusted data? Makes me wish I bought some AAPL in 2004...
                          Austin, the indicator compiled just fine. But when I applied it to the chart nothing happened to the price bars. No error messages or anything. It just flat out did not work. Confused as to why it would work for TraderGuy but not me.

                          Regards
                          Chuck

                          Comment


                            #14
                            Chuck, the code in post #8 also worked for me. How are you applying the indicator?
                            Attached Files
                            AustinNinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_Austin View Post
                              Chuck, the code in post #8 also worked for me. How are you applying the indicator?
                              Austin, I've attached a screenshot of the settings I use when applying the indicator and another screenshot which shows the result. This is very confusing to me...why it works for you guys and not me. I'm just wondering, when TraderGuy posted the code I did not "import" it into Ninja Trader but rather dragged and dropped in the indicator into the NT7/Bin/Custom/Indicator folder. I did this because the file was a ".CS" file and I didn't think I could import it in the normal fashion. Please advise.

                              Regards
                              Chuck
                              Attached Files

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by trilliantrader, Yesterday, 03:01 PM
                              3 responses
                              30 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by cmtjoancolmenero, Yesterday, 03:58 PM
                              4 responses
                              26 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by Brevo, Today, 01:45 AM
                              1 response
                              14 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by rjbtrade1, 11-30-2023, 04:38 PM
                              2 responses
                              74 views
                              0 likes
                              Last Post DavidHP
                              by DavidHP
                               
                              Started by suroot, 04-10-2017, 02:18 AM
                              5 responses
                              3,022 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Working...
                              X