Announcement

Collapse
No announcement yet.

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, 10: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, 11:40 AM.

            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 i2w8am9ii2, Today, 04:36 PM
              2 responses
              13 views
              0 likes
              Last Post i2w8am9ii2  
              Started by WeyldFalcon, Today, 02:07 PM
              2 responses
              13 views
              0 likes
              Last Post WeyldFalcon  
              Started by hfwiley, Today, 03:02 PM
              2 responses
              18 views
              0 likes
              Last Post hfwiley
              by hfwiley
               
              Started by pdennis, Today, 02:34 PM
              3 responses
              21 views
              0 likes
              Last Post NinjaTrader_ChrisL  
              Started by tonynt, Today, 01:47 PM
              3 responses
              24 views
              0 likes
              Last Post NinjaTrader_Kate  
              Working...
              X