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

how to keep one dateseries unchanged?

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

    how to keep one dateseries unchanged?

    hi, I created a indicator, which used two dataseries. One is the close price, the other is chosen when using the indicator for the strategy. But, when I input RSI or CCI when creating a new strategy with this indicator, the close price is replaced with the RSI or CCI during calculation. What should I do if I want the close price keep unreplaced?

    Thank you very much!

    #2
    Hello,

    Do you mean the RSI and CCI are replaced with the close value? If so, that is the default when a value is not found. I suggest posting some code snippets and let us give you some pointers.
    DenNinjaTrader Customer Service

    Comment


      #3
      No, it's not replaced by close price. Following is part of my code:

      if((Input[1]-Input[date2])/Input[date2]>=0.1&&Close[date2]>Close[1])
      {test=1;}

      When I'm building a strategy, I put "RSI(14)" in Input box. I guess when calculating, the "Input[]" should be replaced by "RSI(14)[]". But the "Close[]" here is also replaced by "RSI(14)[]", which is not expected. What should I do to keep "Close[]" unchanged?

      Comment


        #4
        This is expected as both parts respond to your date2 input paramter in the snipped you posted, so best would be to use a new input for the second part of your snippet.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          I have tried to replace Close[date2] with Close[date22], in which date22 it just equal to date2. But the system still use the input dataseries to substitute the close price. Do you have any other suggestions?

          Comment


            #6
            scyche, as explained in your other thread, Input refer to the main input series used for the indicator calculations, this will be Close per default if you don't set PriceTypeSupported to true in Initialize() - for your use create a new data series object for your RSI or just use the RSI(14) directly in the code like -

            Code:
             
            if (Input[1] - RSI(14, 1)[date2] > 0)
            {do your thing}
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Thank you for your suggestion. My problem is that, I need to use two dataseries in my calculation. One is an indicator, RSI, CCI, EMA, whatever. The other is close price. I want use the former one as my main input, so I think I can use Input[] in stead of those indicators. But for close prices, I want them to be constant no matter what my input is. But the problem is that it seems the close price is changing accordingly. I have tried to create a new dataseries to contain the close price. But when I use "AAA.Set=Close[0]", AAA actually equals to my main input - for the close prices are already changed.

              Do you have some other ideas? I would be very happy to have a try!

              Thank you very much!

              Comment


                #8
                scyche, sorry don't really follow you - if you want it to be constant, just hard code it in to always use the Close, there's then no need to feed this into a separate dataseries, as it already is a dataseries object by default. Best would be you post the full updated code you use now, so we can take a look.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Thank you very much! Here's my code.

                  public class Compareslopes : Indicator
                  {
                  #region Variables

                  private int n = 1;
                  #endregion


                  protected override void Initialize()
                  {
                  CalculateOnBarClose = true;
                  Overlay= true;
                  PriceTypeSupported = false;
                  }



                  protected override void OnBarUpdate()
                  {
                  int i=0;
                  int j=0;
                  int k=0;
                  int l=0;
                  int m=0;
                  double temp0=0;
                  double temp1=0;
                  double temp2=0;
                  int date=0;
                  int date2=0;
                  int date3=0;
                  int[] tops;
                  int test=0;
                  tops = new int[50];

                  if(CurrentBar<=n)
                  return;
                  else

                  {
                  date=HighestBar(Input, n-1);
                  for(i=n-2;i>=0;i--)
                  {
                  if(Input[i+1]-Input[i+2]>=0&&Input[i+1]-Input[i]>=0)
                  {
                  tops[j]=i+1;

                  if(tops[j]==date)
                  m=j;

                  j++;
                  }
                  }


                  if(date == 1)
                  {
                  if(date<tops[0])
                  {
                  temp1=Slope(Input, tops[0], 1);
                  date2=tops[0];
                  for(k=0;k<j-1;k++)
                  {
                  if(Slope(Input, tops[k], date)<temp1)
                  {
                  temp1=Slope(Input, tops[k], 1);
                  date2=tops[k];
                  }
                  }

                  if((Input[1]-Input[date2])/Input[date2]>=0.1&&Close[date2]>Close[1])
                  test=1;
                  }

                  }

                  else
                  {
                  if (tops[0]==0||date==0||date==1)
                  {;}
                  else
                  {
                  if(date>tops[j-1]&&tops[j-1]==1)
                  {
                  temp2=Slope(Input, date, 1);

                  for(l=m+1;l<=j-1;l++)
                  {
                  if(Slope(Input, date, tops[l])>temp2)
                  date3=1;

                  }

                  if(date3==0&&(Input[date]-Input[1])/Input[1]>=0.1&&Close[1]<Close[date])
                  test=-1;
                  }
                  }
                  }
                  }
                  Value.Set(test);
                  }
                  Last edited by scyche; 07-15-2009, 10:50 AM.

                  Comment


                    #10
                    scyche, while Bertrand is away, I'll toss in a comment. When he gets back he'll add something if necessary.

                    Can you try replacing all the Input[] with the value you actually want? For example if you want to use close prices, use Close[0]. If you want to use RSI, use RSI(14, 1)[0].

                    Sometimes when using Input for everything, the value that comes from Input isn't what you expect it to be.
                    Last edited by NinjaTrader_Austin; 07-15-2009, 11:27 AM.
                    AustinNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by funk10101, Yesterday, 09:43 PM
                    1 response
                    13 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by TheWhiteDragon, 01-21-2019, 12:44 PM
                    5 responses
                    551 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by rtwave, 04-12-2024, 09:30 AM
                    5 responses
                    37 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by funk10101, Today, 12:02 AM
                    1 response
                    11 views
                    0 likes
                    Last Post NinjaTrader_LuisH  
                    Started by GLFX005, Today, 03:23 AM
                    1 response
                    6 views
                    0 likes
                    Last Post NinjaTrader_Erick  
                    Working...
                    X