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 creating an index indicator

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

    Help creating an index indicator

    Hey guys,

    I apologize if the answer to this question is already on the forum somewhere, but I was unable to find an answer.

    I am trying to create my first indicator, and and I am struggling a little bit with the data series.

    What I would like to accomplish is creating an index counting buys or sells out of the past 100 signals. So for instance using SMA if there were 25 crosses belows and 75 crosses above the index value would be 75. I figured the easiest way to do this would be to make the cross below value 0 and the cross above value 1 and sum the series. But I don't know how to do this, or have it keep only the past 100 values.

    Thanks in advance for any help you can provide.

    -CFP

    #2
    Hello cfp462,
    Unfortunately we can only assist on specific NinjaScript scenario and do not custom code NinjaScript codes.

    I will leave the thread open for our forum members who can share their valuable inputs.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Hmmm, I think we need to clarify more here

      When you mention crosses, you can't have one without the other.50-50+-1?

      Do you mean trades at a price point above the sma and trades at a price point below?

      so if a bar has traded at 5 price points above, that's 5.
      If 3 were above, that's 3 vs 2.. and then do for 100 bars back?



      Originally posted by cfp462 View Post
      Hey guys,

      I apologize if the answer to this question is already on the forum somewhere, but I was unable to find an answer.

      I am trying to create my first indicator, and and I am struggling a little bit with the data series.

      What I would like to accomplish is creating an index counting buys or sells out of the past 100 signals. So for instance using SMA if there were 25 crosses belows and 75 crosses above the index value would be 75. I figured the easiest way to do this would be to make the cross below value 0 and the cross above value 1 and sum the series. But I don't know how to do this, or have it keep only the past 100 values.

      Thanks in advance for any help you can provide.

      -CFP

      Comment


        #4
        Originally posted by sledge View Post
        When you mention crosses, you can't have one without the other.50-50+-1?
        Sledge, what I understand is that cfp462 wants to count crosses above 1 and crosses below 0, just like the overbought/oversold 80/20 levels in the stochastics indicator.
        Because there is a neutral area between the 2 levels the up- and down crosses do not have to be the same.

        CFP, I attached an indicator that could be a starting point for you. It counts the NET up/downcrosses from the stochastics indicator on the 80/20 levels. Because it counts net up and downcrosses dynamically it does not do exactly the same as you described in your first post where you wanted the total of up crosses over the last 100, but this may be a good starting point.

        Don't know your programming skills, but you should be able to modify it to use another indicator as stochastics. But feel free to ask for further help

        Marco
        Attached Files
        Last edited by marcow; 01-04-2013, 11:34 PM.

        Comment


          #5
          Marcow that is exactly what I am trying to do, create an overbought oversold indicator. I only briefly looked at the code, but will try and re-write it tonight.

          Will let you know how it goes, thank you so much for the help so far. I will keep you guys posted!

          Comment


            #6
            Ok so here is where I am at, I finally coded my first indicator! But it is not working properly.

            Here is the important bit of code:
            ************************************************** ************************************************** ****
            protected override void OnBarUpdate()
            {
            if (BarsInProgress == 0)
            {
            if (FirstTickOfBar)
            {
            draw = false;
            }
            // if certain condition is met
            {
            down -= 1;
            base.DrawText("txt" + CurrentBar,down.ToString(),0,Low[0] + TickSize,Color.Blue);
            draw = true;
            }
            // if other condition is met
            {
            up += 1;
            base.DrawText("txt" + CurrentBar,up.ToString(),0,Low[0] + TickSize,Color.Black);
            draw = true;
            }
            }


            Line.Set(up + down);
            ************************************************** ******************************************

            Now this whole thing works but I only want the last 100 values. I tried doing a SMA of it but was running into issues with data types that I did not understand. Does anyone have any suggestions to just call the last 100 values?


            Edit: Turns out SMA won't work as I want (just figure out how to do that). Is there anyway to maybe use the .Count function? I am just brainstorming here since I don't know how to finish this indicator.
            Last edited by cfp462; 01-10-2013, 12:40 PM.

            Comment


              #7
              Have been preparing something because the problem of calculating the average of the last 100 occurances of an event not related to the Bars-dataseries got me sort of interested to try something new with the C# List class

              Please find attached the modified Netcrosses indicator I posted before.
              To calculate the average of the last 10 stochastics crosses it stores all the crosses in a List. So the List holds all the crosses and only the 10 latest are used to calculate the average of up-down crosses.

              Let me know if this works for you

              Maybe there are better ways of doing this, if so then please comment...

              Marco
              Attached Files

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by bortz, 11-06-2023, 08:04 AM
              47 responses
              1,602 views
              0 likes
              Last Post aligator  
              Started by jaybedreamin, Today, 05:56 PM
              0 responses
              8 views
              0 likes
              Last Post jaybedreamin  
              Started by DJ888, 04-16-2024, 06:09 PM
              6 responses
              18 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by Jon17, Today, 04:33 PM
              0 responses
              4 views
              0 likes
              Last Post Jon17
              by Jon17
               
              Started by Javierw.ok, Today, 04:12 PM
              0 responses
              12 views
              0 likes
              Last Post Javierw.ok  
              Working...
              X