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

Very Basic Indicator Help

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

    Very Basic Indicator Help

    I'm trying to create a custom indicator in NinjaTrader but I'm running into a very odd problem. In the .onBarUpdate() method it won't let me have ANYTHING in the function and the only variable it wont display any Close[x] value if its greater than 0.

    If i put anything in the function ex:

    protected override void OnBarUpdate()
    {
    double x = Close[1];


    GRPlot.Set( Close[0] );
    }
    In my indicator window this won't display anything, neither will this:

    protected override void OnBarUpdate()
    {
    GRPlot.Set( Open[1] );
    }


    It appears that it's having a serious problem getting any information past the reference point of '0'. Anyone got any advice?

    #2
    Basically, if i have anything but Close[0] (ie Close[1] or Close[6]) it completely crashes my indicator and doesn't display anything.

    Comment


      #3
      Originally posted by milemke08 View Post
      Basically, if i have anything but Close[0] (ie Close[1] or Close[6]) it completely crashes my indicator and doesn't display anything.
      "Completely crashes my indicator"

      That would be understood as a run time error.

      Without seeing what GRPlot does, I could only guess at the moment it might be something to do with barsrequired:



      I would suggest opening the output window, and doing a Print statement in your code for Close[0] and Close[1] .. Close[x]... and see what it says the value is.

      You might see/throw some runtime errors you can debug (like BarsRequired issues).

      good luck

      Comment


        #4
        Originally posted by milemke08 View Post
        Basically, if i have anything but Close[0] (ie Close[1] or Close[6]) it completely crashes my indicator and doesn't display anything.
        You have to escape all the bars that come before the first bar that you want to process. So if your reference is to DataSeries[y] for example, the at the start of OnBarUpdate(), you want to escape y bars with:

        Code:
         
        if (CurrentBar < y) return;

        Comment


          #5
          Thank you so much! I tried to figure this out for hours last nigh, who knew it was one line of code lol. What does it mean that you have to 'escape' the bars though?

          Comment


            #6
            Originally posted by milemke08 View Post
            Thank you so much! I tried to figure this out for hours last nigh, who knew it was one line of code lol. What does it mean that you have to 'escape' the bars though?
            NinjaTrader handles streaming data. It cannot process bars that do not exist. So, at the start of the indicator, you have to not process anything until you have enough bars to reference.
            Last edited by koganam; 10-13-2012, 08:01 PM. Reason: Corrected spelling.

            Comment


              #7
              Reverse Simple Moving Average

              Hello,
              To simplify my chart analysis I would like to use a SMA that charts the Opposite value. For instance as the VIX value falls there will usually be rising prices in the Index. If I could look at a reverse moving average of the VIX it would move in the same direction as the price of the Index.
              I tried fooling around with the code and came up dry - nothing useful. It seems so simple - but I can't do it. I am able to edit and compile but I don't know which terms to tweak. If anyone could at least drop a screen shot in the forum of which term to modify I can do the rest.
              Thank you
              Last edited by JohnPS; 06-15-2012, 11:21 PM.

              Comment


                #8
                Code your buy/sell SMA logic in reverse.


                Originally posted by JohnPS View Post
                Hello,
                To simplify my chart analysis I would like to use a SMA that charts the Opposite value. For instance as the VIX value falls there will usually be rising prices in the Index. If I could look at a reverse moving average of the VIX it would move in the same direction as the price of the Index.
                I tried fooling around with the code and came up dry - nothing useful. It seems so simple - but I can't do it. I am able to edit and compile but I don't know which terms to tweak. If anyone could at least drop a screen shot in the forum of which term to modify I can do the rest.
                Thank you

                Comment


                  #9
                  Reverse Simple Moving Average

                  OK makes sense - but I have not written anything like this, Can I try this thru the NT Indicator wizard? I have looked at the Indicator wizard and I don't see that kind of option to reverse terms as you suggest.
                  Problem is I have never coded an Indicator.
                  I am willing to do this and learn the structure - not sure where to start, could you suggest an indicator that would lend it self to this modification?
                  Thank you,

                  Comment


                    #10
                    We have a fully documented help guide which will help you get started with Ninja Script. You will find language references to all of the methods and functions you will be using. You will also see a tutorial section which will help you create your first indicator and get you started with some of these concepts.

                    A link to our Help Guide can be found below: http://www.ninjatrader.com/support/h...stribution.htm

                    I am also linking you to the Educational Resources section of the Help Guide to help you get started with NinjaScript: http://www.ninjatrader.com/support/h..._resources.htm

                    We also have some Reference Samples online as well as some Tips and Tricks for both indicators and strategies:
                    Click here to see our NinjaScript Reference Samples
                    Click here to see our NinjaScript Tips

                    These samples can be downloaded, installed and modified from NinjaTrader and hopefully serve as a good base for your custom works.

                    There is a also a growing library of user submitted custom indicators (100+) that can be downloaded from our support form. Please look in the NinjaScript File Sharing section of our support forum as you may find what you are looking for there.

                    If you have limited time or programming capabilities, you can discuss your requirements with any of our certified NinjaScript consultants.
                    Click here for a list of certified NinjaScript Consultants
                    MatthewNinjaTrader Product Management

                    Comment


                      #11
                      that is very . good

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by funk10101, Today, 09:43 PM
                      0 responses
                      6 views
                      0 likes
                      Last Post funk10101  
                      Started by pkefal, 04-11-2024, 07:39 AM
                      11 responses
                      37 views
                      0 likes
                      Last Post jeronymite  
                      Started by bill2023, Yesterday, 08:51 AM
                      8 responses
                      44 views
                      0 likes
                      Last Post bill2023  
                      Started by yertle, Today, 08:38 AM
                      6 responses
                      26 views
                      0 likes
                      Last Post ryjoga
                      by ryjoga
                       
                      Started by algospoke, Yesterday, 06:40 PM
                      2 responses
                      24 views
                      0 likes
                      Last Post algospoke  
                      Working...
                      X